Interface EdDSASupport<PUB extends java.security.PublicKey,​PRV extends java.security.PrivateKey>

  • Type Parameters:
    PUB - type of the public key supported by the security provider
    PRV - type of the private key supported by the security provider
    All Known Implementing Classes:
    BouncyCastleEdDSASupport, NetI2pCryptoEdDSASupport

    public interface EdDSASupport<PUB extends java.security.PublicKey,​PRV extends java.security.PrivateKey>
    Provides generic operations required of a security provider to support EdDSA and Ed25519.
    • Method Detail

      • decodeEd25519KeyPair

        static java.security.KeyPair decodeEd25519KeyPair​(byte[] keyData)
                                                   throws java.io.IOException,
                                                          java.security.GeneralSecurityException
        Parameters:
        keyData - the raw private key bytes.
        Returns:
        a KeyPair from the given raw private key data.
        Throws:
        java.io.IOException
        java.security.GeneralSecurityException
      • decodeEdDSAPrivateKey

        static java.security.PrivateKey decodeEdDSAPrivateKey​(byte[] keyData)
                                                       throws java.io.IOException,
                                                              java.security.GeneralSecurityException
        Parameters:
        keyData - the raw private key bytes.
        Returns:
        the associated private key.
        Throws:
        java.io.IOException
        java.security.GeneralSecurityException
      • getEDDSAPublicKeyEntryDecoder

        PublicKeyEntryDecoder<PUB,​PRV> getEDDSAPublicKeyEntryDecoder()
        Returns:
        the public key entry decoder implementation associated with the security provider.
      • getOpenSSHEDDSAPrivateKeyEntryDecoder

        PrivateKeyEntryDecoder<PUB,​PRV> getOpenSSHEDDSAPrivateKeyEntryDecoder()
        Returns:
        the private key entry decoder implementation associated with the security provider.
      • getEDDSASigner

        Signature getEDDSASigner()
        Returns:
        the signature implementation associated with the security provider.
      • getEDDSAKeySize

        int getEDDSAKeySize​(java.security.Key key)
        Parameters:
        key - the key to get the size of.
        Returns:
        the size of the key if it is an EdDSA key, -1 otherwise.
      • getEDDSAPublicKeyType

        java.lang.Class<PUB> getEDDSAPublicKeyType()
        Returns:
        the public key class type associated with the security provider.
      • getEDDSAPrivateKeyType

        java.lang.Class<PRV> getEDDSAPrivateKeyType()
        Returns:
        the private key class type associated with the security provider.
      • compareEDDSAPPublicKeys

        boolean compareEDDSAPPublicKeys​(java.security.PublicKey k1,
                                        java.security.PublicKey k2)
        Parameters:
        k1 - the first key
        k2 - the second key
        Returns:
        true if both keys are instances of the public key type associated with the security provider and they are equal.
      • compareEDDSAPrivateKeys

        boolean compareEDDSAPrivateKeys​(java.security.PrivateKey k1,
                                        java.security.PrivateKey k2)
        Parameters:
        k1 - the first key
        k2 - the second key
        Returns:
        true if both keys are instances of the private key type associated with the security provider and they are equal.
      • recoverEDDSAPublicKey

        PUB recoverEDDSAPublicKey​(java.security.PrivateKey key)
                           throws java.security.GeneralSecurityException
        Parameters:
        key - the private key
        Returns:
        the public key associated with the private key.
        Throws:
        java.security.GeneralSecurityException
      • generateEDDSAPublicKey

        PUB generateEDDSAPublicKey​(byte[] seed)
                            throws java.security.GeneralSecurityException
        Parameters:
        seed - the raw public key bytes
        Returns:
        the associated public key
        Throws:
        java.security.GeneralSecurityException
      • generateEDDSAPrivateKey

        PRV generateEDDSAPrivateKey​(byte[] seed)
                             throws java.security.GeneralSecurityException,
                                    java.io.IOException
        Parameters:
        seed - the raw private key bytes
        Returns:
        the associated private key
        Throws:
        java.security.GeneralSecurityException
        java.io.IOException
      • putRawEDDSAPublicKey

        <B extends Buffer> B putRawEDDSAPublicKey​(B buffer,
                                                  java.security.PublicKey key)
        Type Parameters:
        B - type of the buffer
        Parameters:
        buffer - the buffer to insert the public key into
        key - the public key to be inserted into the buffer
        Returns:
        the buffer that was passed in
      • putEDDSAKeyPair

        <B extends Buffer> B putEDDSAKeyPair​(B buffer,
                                             java.security.PublicKey pubKey,
                                             java.security.PrivateKey prvKey)
        Type Parameters:
        B - type of the buffer
        Parameters:
        buffer - the buffer to insert the keys into
        pubKey - the public key to be inserted into the buffer
        prvKey - the private key to be inserted into the buffer
        Returns:
        the buffer that was passed in
      • createPublicKeySpec

        java.security.spec.KeySpec createPublicKeySpec​(PUB publicKey)
        Parameters:
        publicKey - the public key
        Returns:
        a key spec from the public key
      • createPrivateKeySpec

        java.security.spec.KeySpec createPrivateKeySpec​(PRV privateKey)
        Parameters:
        privateKey - the private key
        Returns:
        a key spec from the private key
      • getPublicKeyData

        byte[] getPublicKeyData​(PUB publicKey)
        Parameters:
        publicKey - the public key
        Returns:
        the raw public key bytes associated with the key
      • getPrivateKeyData

        byte[] getPrivateKeyData​(PRV privateKey)
                          throws java.io.IOException
        Parameters:
        privateKey - the private key
        Returns:
        the raw private key bytes associated with the key
        Throws:
        java.io.IOException
      • getKeyFactoryAlgorithm

        java.lang.String getKeyFactoryAlgorithm()
        Returns:
        the algorithm name used by the provider's KeyFactory.