Package net.i2p.data
Class KeyCertificate
java.lang.Object
net.i2p.data.DataStructureImpl
net.i2p.data.Certificate
net.i2p.data.KeyCertificate
- All Implemented Interfaces:
Serializable
,DataStructure
This certificate type gets its own class because it's going to be used a lot.
Format is: 2 byte sig type, 2 byte crypto type, excess sig data, excess crypto data.
The crypto type is assumed to be always 0x0000 (ElG) for now.
- Since:
- 0.9.12
- See Also:
-
Field Summary
Modifier and TypeFieldDescription(package private) static final byte[]
ElG + P256(package private) static final byte[]
ElG + Ed25519static final KeyCertificate
An immutable ElG/ECDSA-P256 certificate.static final KeyCertificate
An immutable ElG/Ed25519 certificate.static final int
static final KeyCertificate
An immutable X25519/Ed25519 certificate.(package private) static final byte[]
X25519 + Ed25519Fields inherited from class net.i2p.data.Certificate
_payload, _type, CERTIFICATE_LENGTH_SIGNED_WITH_HASH, CERTIFICATE_TYPE_HASHCASH, CERTIFICATE_TYPE_HIDDEN, CERTIFICATE_TYPE_KEY, CERTIFICATE_TYPE_MULTIPLE, CERTIFICATE_TYPE_NULL, CERTIFICATE_TYPE_SIGNED, NULL_CERT
-
Constructor Summary
ConstructorDescriptionKeyCertificate
(byte[] payload) KeyCertificate
(SigType type) A KeyCertificate with crypto type 0 (ElGamal) and the signature type as specified.KeyCertificate
(SigType type, EncType etype) A KeyCertificate with crypto type and the signature type as specified.KeyCertificate
(Certificate cert) Up-convert a cert to this classA KeyCertificate with crypto type 0 (ElGamal) and the signature type and extra data from the given public key.KeyCertificate
(SigningPublicKey spk, PublicKey pk) A KeyCertificate with enc type from the given public key, and the signature type and extra data from the given public key. -
Method Summary
Modifier and TypeMethodDescriptionint
byte[]
Signing Key extra data, if any, is first in the array.byte[]
Signing Key extra data, if any.int
Up-convert this to a KeyCertificatetoString()
Methods inherited from class net.i2p.data.Certificate
create, create, equals, getCertificateType, getPayload, hashCode, readBytes, readBytes, setCertificateType, setPayload, size, writeBytes, writeBytes
Methods inherited from class net.i2p.data.DataStructureImpl
calculateHash, fromBase64, fromByteArray, read, toBase64, toByteArray
-
Field Details
-
HEADER_LENGTH
public static final int HEADER_LENGTH- See Also:
-
Ed25519_PAYLOAD
static final byte[] Ed25519_PAYLOADElG + Ed25519- Since:
- 0.9.22 pkg private for Certificate.create()
-
ECDSA256_PAYLOAD
static final byte[] ECDSA256_PAYLOADElG + P256- Since:
- 0.9.22 pkg private for Certificate.create()
-
X25519_Ed25519_PAYLOAD
static final byte[] X25519_Ed25519_PAYLOADX25519 + Ed25519- Since:
- 0.9.54
-
ELG_ECDSA256_CERT
An immutable ElG/ECDSA-P256 certificate. -
ELG_Ed25519_CERT
An immutable ElG/Ed25519 certificate.- Since:
- 0.9.22
-
X25519_Ed25519_CERT
An immutable X25519/Ed25519 certificate.- Since:
- 0.9.54
-
-
Constructor Details
-
KeyCertificate
- Parameters:
payload
- 4 bytes minimum if non-null- Throws:
DataFormatException
-
KeyCertificate
A KeyCertificate with crypto type 0 (ElGamal) and the signature type and extra data from the given public key.- Parameters:
spk
- non-null data non-null- Throws:
IllegalArgumentException
-
KeyCertificate
A KeyCertificate with enc type from the given public key, and the signature type and extra data from the given public key. EncType lengths greater than 256 not supported.- Parameters:
spk
- non-null data non-nullpk
- non-null- Throws:
IllegalArgumentException
- Since:
- 0.9.42
-
KeyCertificate
A KeyCertificate with crypto type 0 (ElGamal) and the signature type as specified. Payload is created. If type.getPubkeyLen() is greater than 128, caller MUST fill in the extra key data in the payload.- Parameters:
type
- non-null- Throws:
IllegalArgumentException
-
KeyCertificate
A KeyCertificate with crypto type and the signature type as specified. Payload is created. If type.getPubkeyLen() is greater than 128, caller MUST fill in the extra key data in the payload. EncType lengths greater than 256 not supported.- Parameters:
type
- non-nulletype
- non-null- Throws:
IllegalArgumentException
- Since:
- 0.9.42
-
KeyCertificate
Up-convert a cert to this class- Parameters:
cert
- payload 4 bytes minimum if non-null- Throws:
DataFormatException
- if cert type != CERTIFICATE_TYPE_KEY
-
-
Method Details
-
getSigTypeCode
public int getSigTypeCode()- Returns:
- -1 if unset
-
getCryptoTypeCode
public int getCryptoTypeCode()- Returns:
- -1 if unset
-
getSigType
- Returns:
- null if unset or unknown
-
getEncType
- Returns:
- null if unset or unknown
- Since:
- 0.9.42
-
getExtraKeyData
public byte[] getExtraKeyData()Signing Key extra data, if any, is first in the array. Crypto Key extra data, if any, is second in the array, at offset max(0, getSigType().getPubkeyLen() - 128)- Returns:
- null if unset or none
-
getExtraSigningKeyData
public byte[] getExtraSigningKeyData()Signing Key extra data, if any.- Returns:
- null if unset or none
- Throws:
UnsupportedOperationException
- if the sig type is unsupported
-
toKeyCertificate
Description copied from class:Certificate
Up-convert this to a KeyCertificate- Overrides:
toKeyCertificate
in classCertificate
-
toString
- Overrides:
toString
in classCertificate
-