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
public class KeyCertificate extends Certificate
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:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description (package private) static byte[]
ECDSA256_PAYLOAD
(package private) static byte[]
Ed25519_PAYLOAD
static KeyCertificate
ELG_ECDSA256_CERT
An immutable ElG/ECDSA-P256 certificate.static KeyCertificate
ELG_Ed25519_CERT
An immutable ElG/Ed25519 certificate.static int
HEADER_LENGTH
Fields 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
Constructors Constructor Description KeyCertificate(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 classKeyCertificate(SigningPublicKey spk)
A 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 Type Method Description int
getCryptoTypeCode()
EncType
getEncType()
byte[]
getExtraKeyData()
Signing Key extra data, if any, is first in the array.byte[]
getExtraSigningKeyData()
Signing Key extra data, if any.SigType
getSigType()
int
getSigTypeCode()
KeyCertificate
toKeyCertificate()
Up-convert this to a KeyCertificateString
toString()
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:
- Constant Field Values
-
Ed25519_PAYLOAD
static final byte[] Ed25519_PAYLOAD- Since:
- 0.9.22 pkg private for Certificate.create()
-
ECDSA256_PAYLOAD
static final byte[] ECDSA256_PAYLOAD- Since:
- 0.9.22 pkg private for Certificate.create()
-
ELG_ECDSA256_CERT
An immutable ElG/ECDSA-P256 certificate. -
ELG_Ed25519_CERT
An immutable ElG/Ed25519 certificate.- Since:
- 0.9.22
-
-
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
-