Package net.i2p.data

Class 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:
  • Field Details

    • HEADER_LENGTH

      public static final int HEADER_LENGTH
      See Also:
    • Ed25519_PAYLOAD

      static final byte[] Ed25519_PAYLOAD
      ElG + Ed25519
      Since:
      0.9.22 pkg private for Certificate.create()
    • ECDSA256_PAYLOAD

      static final byte[] ECDSA256_PAYLOAD
      ElG + P256
      Since:
      0.9.22 pkg private for Certificate.create()
    • X25519_Ed25519_PAYLOAD

      static final byte[] X25519_Ed25519_PAYLOAD
      X25519 + Ed25519
      Since:
      0.9.54
    • 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
    • X25519_Ed25519_CERT

      public static final KeyCertificate X25519_Ed25519_CERT
      An immutable X25519/Ed25519 certificate.
      Since:
      0.9.54
  • Constructor Details

    • 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(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. EncType lengths greater than 256 not supported.
      Parameters:
      spk - non-null data non-null
      pk - non-null
      Throws:
      IllegalArgumentException
      Since:
      0.9.42
    • 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(SigType type, EncType etype)
      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-null
      etype - non-null
      Throws:
      IllegalArgumentException
      Since:
      0.9.42
    • 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 Details

    • 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
    • getEncType

      public EncType 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

      public KeyCertificate toKeyCertificate()
      Description copied from class: Certificate
      Up-convert this to a KeyCertificate
      Overrides:
      toKeyCertificate in class Certificate
    • toString

      public String toString()
      Overrides:
      toString in class Certificate