java.lang.Object
net.i2p.data.DataStructureImpl
net.i2p.data.Certificate
net.i2p.data.KeyCertificate
net.i2p.data.KeyCertificate.ECDSA256Cert
- All Implemented Interfaces:
Serializable, DataStructure
- Enclosing class:
KeyCertificate
An immutable ElG/ECDSA-256 certificate.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final intThe cached hash code.private static final byte[]The fixed bytes of the ECDSA 256 certificate.private static final intLength of the ECDSA 256 certificate bytes.Fields inherited from class KeyCertificate
ECDSA256_PAYLOAD, Ed25519_PAYLOAD, ELG_ECDSA256_CERT, ELG_Ed25519_CERT, HEADER_LENGTH, X25519_Ed25519_CERT, X25519_Ed25519_PAYLOADModifier and TypeFieldDescription(package private) static final byte[]ElG + P256.(package private) static final byte[]ElG + Ed25519.static final KeyCertificateAn immutable ElG/ECDSA-P256 certificate.static final KeyCertificateAn immutable ElG/Ed25519 certificate.static final intKey certificate header length in bytes.static final KeyCertificateAn immutable X25519/Ed25519 certificate.(package private) static final byte[]X25519 + Ed25519.Fields inherited from class Certificate
_payload, _type, CERTIFICATE_LENGTH_SIGNED_WITH_HASH, CERTIFICATE_TYPE_HIDDEN, CERTIFICATE_TYPE_KEY, CERTIFICATE_TYPE_MULTIPLE, CERTIFICATE_TYPE_NULL, CERTIFICATE_TYPE_SIGNED, NULL_CERTModifier and TypeFieldDescriptionprotected byte[]Certificate payload data.protected intCertificate type identifier.static final intLength of signed certificate with hash (signature + hash).static final intWe should not be used for anything (don't use us in the netDb, in tunnels, or tell others about us).static final intKey certificate type.static final intContains multiple certs.static final intSpecifies a null certificate type with no payload.static final intSigned with 40-byte Signature and (optional) 32-byte hash.static final CertificateNull certificate singleton.Constructor Summary
ConstructorsMethod Summary
All MethodsModifier and TypeMethodDescriptioninthashCode()Overridden for efficiency.intreadBytes(byte[] source, int offset) Prevent mutation of the immutable certificate.voidreadBytes(InputStream in) Prevent mutation of the immutable certificate.voidsetCertificateType(int type) Prevent mutation of the immutable certificate.voidsetPayload(byte[] payload) Prevent mutation of the immutable certificate.intsize()Overridden for efficiency.intwriteBytes(byte[] target, int offset) Overridden for efficiency.voidwriteBytes(OutputStream out) Overridden for efficiency.Methods inherited from class KeyCertificate
getCryptoTypeCode, getEncType, getExtraKeyData, getExtraSigningKeyData, getSigType, getSigTypeCode, toKeyCertificate, toStringModifier and TypeMethodDescriptionintGets the crypto type code from the certificate.Gets the encryption type from the certificate.byte[]Signing Key extra data, if any, is first in the array.byte[]Signing Key extra data, if any.Gets the signature type from the certificate.intGets the signature type code from the certificate.Returns this certificate as a KeyCertificate.toString()Returns a string representation of this KeyCertificate.Methods inherited from class Certificate
create, create, equals, getCertificateType, getPayloadModifier and TypeMethodDescriptionstatic Certificatecreate(byte[] data, int off) If null, P256 key, or Ed25519 key cert, return immutable static instance, else create new.static Certificatecreate(InputStream in) If null, P256 key, or Ed25519 key cert, return immutable static instance, else create new.booleanintCertificate type.byte[]Payload carried by this certificate.Methods inherited from class DataStructureImpl
calculateHash, fromBase64, fromByteArray, read, toBase64, toByteArrayModifier and TypeMethodDescriptionCalculate the SHA256 value of this object (useful for a few scenarios).voidfromBase64(String data) Load the structure from the provided base64 string.voidfromByteArray(byte[] data) Loads structure from the data providedprotected intread(InputStream in, byte[] target) Repeated reads until buffer is full or IOException is thrown.toBase64()Render the structure into modified base 64 notation.byte[]Convert the structure to a byte array.
Field Details
ECDSA256_DATA
private static final byte[] ECDSA256_DATAThe fixed bytes of the ECDSA 256 certificate.ECDSA256_LENGTH
private static final int ECDSA256_LENGTHLength of the ECDSA 256 certificate bytes._hashcode
private final int _hashcodeThe cached hash code.
Constructor Details
ECDSA256Cert
Creates an immutable ElG/ECDSA-P256 certificate.- Throws:
DataFormatException- if the built certificate data is invalid
Method Details
setCertificateType
public void setCertificateType(int type) Prevent mutation of the immutable certificate.- Overrides:
setCertificateTypein classCertificate- Parameters:
type- the certificate type to set
setPayload
public void setPayload(byte[] payload) Prevent mutation of the immutable certificate.- Overrides:
setPayloadin classCertificate- Parameters:
payload- the payload to set
readBytes
Prevent mutation of the immutable certificate.- Specified by:
readBytesin interfaceDataStructure- Overrides:
readBytesin classCertificate- Parameters:
in- stream to read from- Throws:
DataFormatException- if the data is improperly formattedIOException- if there was a problem reading the stream
writeBytes
Overridden for efficiency.- Specified by:
writeBytesin interfaceDataStructure- Overrides:
writeBytesin classCertificate- Parameters:
out- stream to write to- Throws:
IOException- if there was a problem writing to the stream
writeBytes
public int writeBytes(byte[] target, int offset) Overridden for efficiency.- Overrides:
writeBytesin classCertificate- Parameters:
target- the output arrayoffset- the starting offset in the target- Returns:
- the written length (NOT the new offset)
readBytes
Prevent mutation of the immutable certificate.- Overrides:
readBytesin classCertificate- Parameters:
source- the array holding the certificate dataoffset- the starting offset in the source- Returns:
- the bytes consumed
- Throws:
DataFormatException- if the data is malformed
size
public int size()Overridden for efficiency.- Overrides:
sizein classCertificate- Returns:
- the size in bytes: 3 plus the payload length
hashCode