Package org.bouncycastle.bcpg
Class SecretKeyPacket
java.lang.Object
org.bouncycastle.bcpg.Packet
org.bouncycastle.bcpg.ContainedPacket
org.bouncycastle.bcpg.SecretKeyPacket
- All Implemented Interfaces:
PacketTags
,PublicKeyAlgorithmTags
,org.bouncycastle.util.Encodable
- Direct Known Subclasses:
SecretSubkeyPacket
basic packet for a PGP secret key
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
AEAD.static final int
Deprecated.Use of MalleableCFB is deprecated.static final int
Unprotected.static final int
CFB.Fields inherited from interface org.bouncycastle.bcpg.PacketTags
AEAD_ENC_DATA, COMPRESSED_DATA, EXPERIMENTAL_1, EXPERIMENTAL_2, EXPERIMENTAL_3, EXPERIMENTAL_4, LITERAL_DATA, MARKER, MOD_DETECTION_CODE, ONE_PASS_SIGNATURE, PADDING, PUBLIC_KEY, PUBLIC_KEY_ENC_SESSION, PUBLIC_SUBKEY, RESERVED, SECRET_KEY, SECRET_SUBKEY, SIGNATURE, SYM_ENC_INTEGRITY_PRO, SYMMETRIC_KEY_ENC, SYMMETRIC_KEY_ENC_SESSION, TRUST, USER_ATTRIBUTE, USER_ID
Fields inherited from interface org.bouncycastle.bcpg.PublicKeyAlgorithmTags
DIFFIE_HELLMAN, DSA, EC, ECDH, ECDSA, Ed25519, Ed448, EDDSA, EDDSA_LEGACY, ELGAMAL_ENCRYPT, ELGAMAL_GENERAL, EXPERIMENTAL_1, EXPERIMENTAL_10, EXPERIMENTAL_11, EXPERIMENTAL_2, EXPERIMENTAL_3, EXPERIMENTAL_4, EXPERIMENTAL_5, EXPERIMENTAL_6, EXPERIMENTAL_7, EXPERIMENTAL_8, EXPERIMENTAL_9, RSA_ENCRYPT, RSA_GENERAL, RSA_SIGN, X25519, X448
-
Constructor Summary
ConstructorsConstructorDescriptionSecretKeyPacket
(PublicKeyPacket pubKeyPacket, int encAlgorithm, int s2kUsage, S2K s2k, byte[] iv, byte[] secKeyData) SecretKeyPacket
(PublicKeyPacket pubKeyPacket, int encAlgorithm, S2K s2k, byte[] iv, byte[] secKeyData) -
Method Summary
Modifier and TypeMethodDescriptionvoid
encode
(BCPGOutputStream out) int
int
byte[]
byte[]
getIV()
getS2K()
int
byte[]
Methods inherited from class org.bouncycastle.bcpg.ContainedPacket
getEncoded
Methods inherited from class org.bouncycastle.bcpg.Packet
getPacketTag, isCritical
-
Field Details
-
USAGE_NONE
public static final int USAGE_NONEUnprotected.- See Also:
-
USAGE_CHECKSUM
public static final int USAGE_CHECKSUMDeprecated.Use of MalleableCFB is deprecated. For v4 keys, useUSAGE_SHA1
instead. For v6 keys useUSAGE_AEAD
instead.Malleable CFB. Malleable-CFB-encrypted keys are vulnerable to corruption attacks that can cause leakage of secret data when the secret key is used.- See Also:
-
USAGE_SHA1
public static final int USAGE_SHA1CFB. CFB-encrypted keys are vulnerable to corruption attacks that can cause leakage of secret data when the secret key is use.- See Also:
-
USAGE_AEAD
public static final int USAGE_AEADAEAD. This usage protects against above-mentioned attacks. Passphrase-protected secret key material in a v6 Secret Key or v6 Secret Subkey packet SHOULD be protected with AEAD encryption unless it will be transferred to an implementation that is known to not support AEAD. Users should migrate to AEAD with all due speed.- See Also:
-
-
Constructor Details
-
SecretKeyPacket
public SecretKeyPacket(PublicKeyPacket pubKeyPacket, int encAlgorithm, S2K s2k, byte[] iv, byte[] secKeyData) - Parameters:
pubKeyPacket
-encAlgorithm
-s2k
-iv
-secKeyData
-
-
SecretKeyPacket
public SecretKeyPacket(PublicKeyPacket pubKeyPacket, int encAlgorithm, int s2kUsage, S2K s2k, byte[] iv, byte[] secKeyData)
-
-
Method Details
-
getEncAlgorithm
public int getEncAlgorithm() -
getAeadAlgorithm
public int getAeadAlgorithm() -
getS2KUsage
public int getS2KUsage() -
getIV
public byte[] getIV() -
getS2K
-
getPublicKeyPacket
-
getSecretKeyData
public byte[] getSecretKeyData() -
getEncodedContents
- Throws:
IOException
-
encode
- Specified by:
encode
in classContainedPacket
- Throws:
IOException
-