Package net.i2p.data

Class KeysAndCert

  • All Implemented Interfaces:
    Serializable, DataStructure
    Direct Known Subclasses:
    Destination, RouterIdentity

    public class KeysAndCert
    extends DataStructureImpl
    KeysAndCert has a public key, a signing key, and a certificate. In that order. We also store a cached Hash. Implemented in 0.8.2 and retrofitted over Destination and RouterIdentity. There's actually no difference between the two of them. As of 0.9.9 this data structure is immutable after the two keys and the certificate are set; attempts to change them will throw an IllegalStateException.
    Since:
    0.8.2
    Author:
    zzz
    See Also:
    Serialized Form
    • Constructor Detail

      • KeysAndCert

        public KeysAndCert()
    • Method Detail

      • getSigType

        public SigType getSigType()
        Returns:
        null if not set or unknown
        Since:
        0.9.17
      • getEncType

        public EncType getEncType()
        Returns:
        null if not set or unknown
        Since:
        0.9.42
      • getPublicKey

        public PublicKey getPublicKey()
      • getPadding

        public byte[] getPadding()
        Since:
        0.9.16
      • setPadding

        public void setPadding​(byte[] padding)
        Throws:
        IllegalStateException - if was already set
        Since:
        0.9.12
      • readBytes

        public void readBytes​(InputStream in)
                       throws DataFormatException,
                              IOException
        Description copied from interface: DataStructure
        Load up the current object with data from the given stream. Data loaded this way must match the I2P data structure specification. Warning - many classes will throw IllegalStateException if data is already set.
        Parameters:
        in - stream to read from
        Throws:
        IllegalStateException - if data already set
        DataFormatException - if the data is improperly formatted
        IOException - if there was a problem reading the stream
      • combinePadding

        protected static byte[] combinePadding​(byte[] pad1,
                                               byte[] pad2)
        Returns:
        null if both are null
        Since:
        0.9.42
      • writeBytes

        public void writeBytes​(OutputStream out)
                        throws DataFormatException,
                               IOException
        Description copied from interface: DataStructure
        Write out the data structure to the stream, using the format defined in the I2P data structure specification.
        Parameters:
        out - stream to write to
        Throws:
        DataFormatException - if the data was incomplete or not yet ready to be written
        IOException - if there was a problem writing to the stream
      • hashCode

        public int hashCode()
        the signing key has enough randomness in it to use it by itself for speed
        Overrides:
        hashCode in class Object
      • getHash

        public Hash getHash()
        Throws IllegalStateException if keys and cert are not initialized, as of 0.9.12. Prior to that, returned null.
        Throws:
        IllegalStateException