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_PAYLOADstatic KeyCertificateELG_ECDSA256_CERTAn immutable ElG/ECDSA-P256 certificate.static KeyCertificateELG_Ed25519_CERTAn immutable ElG/Ed25519 certificate.static intHEADER_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(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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetCryptoTypeCode()byte[]getExtraKeyData()Signing Key extra data, if any, is first in the array.byte[]getExtraSigningKeyData()Signing Key extra data, if any.SigTypegetSigType()intgetSigTypeCode()KeyCertificatetoKeyCertificate()Up-convert this to a KeyCertificateStringtoString()-
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 Detail
-
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
public static final KeyCertificate ELG_ECDSA256_CERT
An immutable ElG/ECDSA-P256 certificate.
-
ELG_Ed25519_CERT
public static final KeyCertificate ELG_Ed25519_CERT
An immutable ElG/Ed25519 certificate.- Since:
- 0.9.22
-
-
Constructor Detail
-
KeyCertificate
public KeyCertificate(byte[] payload) throws DataFormatException- Parameters:
payload- 4 bytes minimum if non-null- Throws:
DataFormatException
-
KeyCertificate
public KeyCertificate(SigningPublicKey spk)
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
public KeyCertificate(SigType type)
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
public KeyCertificate(Certificate cert) throws DataFormatException
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 Detail
-
getSigTypeCode
public int getSigTypeCode()
- Returns:
- -1 if unset
-
getCryptoTypeCode
public int getCryptoTypeCode()
- Returns:
- -1 if unset
-
getSigType
public SigType getSigType()
- Returns:
- null if unset or unknown
-
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
public KeyCertificate toKeyCertificate()
Description copied from class:CertificateUp-convert this to a KeyCertificate- Overrides:
toKeyCertificatein classCertificate
-
toString
public String toString()
- Overrides:
toStringin classCertificate
-
-