public class SecretKeyPacket extends ContainedPacket implements PublicKeyAlgorithmTags
| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_EXTERNAL_LOCATOR_HINT_LEN
Maximum accepted length of the external key locator hint of a version 4 secret key packet, whose
hint is not length-prefixed and so is bounded only by the packet.
|
static int |
MAX_S2K_ENCODING_LEN |
static int |
MAX_V6_EXTERNAL_LOCATOR_HINT_LEN
Maximum length of the external key locator hint of a version 5 or 6 secret key packet, whose
conditional parameters are prefixed with a one-octet count (RFC 9580 sec. 5.5.3).
|
static int |
USAGE_AEAD
S2K-usage octet indicating that the secret key material is protected using an AEAD scheme.
|
static int |
USAGE_CHECKSUM
Deprecated.
Use of MalleableCFB is deprecated.
For v4 keys, use
USAGE_SHA1 instead.
For v6 keys use USAGE_AEAD instead. |
static int |
USAGE_EXTERNAL
Externally-backed secret key material.
|
static int |
USAGE_NONE
S2K-usage octet indicating that the secret key material is unprotected.
|
static int |
USAGE_SHA1
S2K-usage octet indicating that the secret key material is protected using a cipher in CFB mode.
|
AEDH, AEDSA, 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, MLDSA65_Ed25519, MLDSA87_Ed448, MLKEM1024_X448, MLKEM768_X25519, RSA_ENCRYPT, RSA_GENERAL, RSA_SIGN, SLHDSA_SHAKE_128f, SLHDSA_SHAKE_128s, SLHDSA_SHAKE_256s, X25519, X448AEAD_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| Modifier | Constructor and Description |
|---|---|
protected |
SecretKeyPacket(int keyTag,
PublicKeyPacket pubKeyPacket,
byte[] locatorHint)
Create a SecretKeyPacket representing an external secret key (
USAGE_EXTERNAL). |
|
SecretKeyPacket(PublicKeyPacket pubKeyPacket,
byte[] locatorHint)
Create a SecretKeyPacket representing an external secret key (
USAGE_EXTERNAL). |
|
SecretKeyPacket(PublicKeyPacket pubKeyPacket,
int encAlgorithm,
int aeadAlgorithm,
int s2kUsage,
S2K s2k,
byte[] iv,
byte[] secKeyData)
Construct a
SecretKeyPacket or SecretSubkeyPacket. |
|
SecretKeyPacket(PublicKeyPacket pubKeyPacket,
int encAlgorithm,
int s2kUsage,
S2K s2k,
byte[] iv,
byte[] secKeyData)
Construct a
SecretKeyPacket or SecretSubkeyPacket. |
|
SecretKeyPacket(PublicKeyPacket pubKeyPacket,
int encAlgorithm,
S2K s2k,
byte[] iv,
byte[] secKeyData)
Construct a
SecretKeyPacket. |
| Modifier and Type | Method and Description |
|---|---|
void |
encode(BCPGOutputStream out)
Encode the packet into the given
BCPGOutputStream. |
int |
getAeadAlgorithm()
Return the algorithm ID of the AEAD algorithm that was used to protect the secret key material.
|
int |
getEncAlgorithm()
Return the algorithm ID of the symmetric key algorithm that was used to encrypt the secret key material.
|
byte[] |
getEncodedContents()
Return the encoded packet content without packet frame.
|
byte[] |
getExternalKeyLocatorHint()
If the key has external private key material (s2k usage
USAGE_EXTERNAL), return the locator hint data. |
byte[] |
getIV()
Return the IV that was used to protect the secret key material.
|
PublicKeyPacket |
getPublicKeyPacket()
Return the public key packet corresponding to the secret key packet.
|
S2K |
getS2K()
Return the S2K identifier describing, how to derive the symmetric key to protect the secret key material with.
|
int |
getS2KUsage()
Return the S2K usage mode indicating how the secret key material is protected.
|
byte[] |
getSecretKeyData()
Return the encrypted/checksum'd secret key data.
|
getEncoded, getEncodedgetPacketTag, hasNewPacketFormat, isCriticalpublic static final int MAX_S2K_ENCODING_LEN
public static final int USAGE_NONE
public static final int USAGE_CHECKSUM
USAGE_SHA1 instead.
For v6 keys use USAGE_AEAD instead.public static final int USAGE_SHA1
public static final int USAGE_AEAD
public static final int USAGE_EXTERNAL
S2K.GNU_DUMMY_S2K mechanism.
NOTE: this code point is provisional. draft-dkg-openpgp-external-secrets-03 sec. 2 records it as "TBD (252?)" and IANA has not yet assigned it, so the value here tracks the draft's suggestion and is subject to change if a different octet is allocated. Do not rely on it for long-term storage.
public static final int MAX_EXTERNAL_LOCATOR_HINT_LEN
SignaturePacket.MAX_SUBPACKET_LEN.public static final int MAX_V6_EXTERNAL_LOCATOR_HINT_LEN
public SecretKeyPacket(PublicKeyPacket pubKeyPacket, byte[] locatorHint)
USAGE_EXTERNAL).pubKeyPacket - public key packetlocatorHint - optional external key locator hintprotected SecretKeyPacket(int keyTag,
PublicKeyPacket pubKeyPacket,
byte[] locatorHint)
USAGE_EXTERNAL).keyTag - key packet typepubKeyPacket - public key packetlocatorHint - optional external key locator hintpublic SecretKeyPacket(PublicKeyPacket pubKeyPacket, int encAlgorithm, S2K s2k, byte[] iv, byte[] secKeyData)
SecretKeyPacket.
Note: secKeyDataneeds to be prepared by applying encryption/checksum beforehand.
pubKeyPacket - pubkey packet corresponding to this secret key packet.encAlgorithm - algorithm id of the symmetric key algorithm that was used to encrypt the secret key materials2k - s2k identifier for deriving a key from a passphraseiv - IV that was used to encrypt the secret key materialsecKeyData - encrypted/checksum'd secret key materialpublic SecretKeyPacket(PublicKeyPacket pubKeyPacket, int encAlgorithm, int s2kUsage, S2K s2k, byte[] iv, byte[] secKeyData)
SecretKeyPacket or SecretSubkeyPacket.
Note: secKeyDataneeds to be prepared by applying encryption/checksum beforehand.
pubKeyPacket - pubkey packet corresponding to this secret key packet.encAlgorithm - algorithm id of the symmetric key algorithm that was used to encrypt the secret key materials2kUsage - octet indicating, how the secert key material was protecteds2k - s2k identifier for deriving a key from a passphraseiv - IV that was used to encrypt the secret key materialsecKeyData - encrypted/checksum'd secret key materialpublic SecretKeyPacket(PublicKeyPacket pubKeyPacket, int encAlgorithm, int aeadAlgorithm, int s2kUsage, S2K s2k, byte[] iv, byte[] secKeyData)
SecretKeyPacket or SecretSubkeyPacket.
Note: secKeyDataneeds to be prepared by applying encryption/checksum beforehand.
pubKeyPacket - pubkey packet corresponding to this secret key packet.encAlgorithm - algorithm id of the symmetric key algorithm that was used to encrypt the secret key materialaeadAlgorithm - AEAD algorithm scheme used to protect the secret key materials2kUsage - octet indicating how the secret key material was encrypteds2k - s2k identifier for deriving a key from a passphraseiv - IV that was used to encrypt the secret key materialsecKeyData - encrypted/checksum'd secret key materialpublic int getEncAlgorithm()
public int getAeadAlgorithm()
public int getS2KUsage()
public byte[] getIV()
public S2K getS2K()
public PublicKeyPacket getPublicKeyPacket()
public byte[] getSecretKeyData()
public byte[] getExternalKeyLocatorHint()
USAGE_EXTERNAL), return the locator hint data.
If the locator hint is empty, it is referred to as "best effort".
Otherwise, the first octet indicates the type of locator hint.public byte[] getEncodedContents()
throws java.io.IOException
java.io.IOExceptionpublic void encode(BCPGOutputStream out) throws java.io.IOException
BCPGOutputStream.
If the packet output stream has PacketFormat.ROUNDTRIP set, the packet format to encode the packet length
with depends on the result of Packet.hasNewPacketFormat().
Otherwise, the packet output stream dictates the packet format.encode in class ContainedPacketout - packet output streamjava.io.IOException