Class BouncyCastleEdDSASupport

java.lang.Object
org.apache.sshd.common.util.security.eddsa.bouncycastle.BouncyCastleEdDSASupport
All Implemented Interfaces:
EdDSASupport<org.bouncycastle.jcajce.interfaces.EdDSAPublicKey,org.bouncycastle.jcajce.interfaces.EdDSAPrivateKey>

public class BouncyCastleEdDSASupport extends Object implements EdDSASupport<org.bouncycastle.jcajce.interfaces.EdDSAPublicKey,org.bouncycastle.jcajce.interfaces.EdDSAPrivateKey>
  • Constructor Details

    • BouncyCastleEdDSASupport

      public BouncyCastleEdDSASupport()
  • Method Details

    • getEDDSAPublicKeyEntryDecoder

      public PublicKeyEntryDecoder<org.bouncycastle.jcajce.interfaces.EdDSAPublicKey,org.bouncycastle.jcajce.interfaces.EdDSAPrivateKey> getEDDSAPublicKeyEntryDecoder()
      Specified by:
      getEDDSAPublicKeyEntryDecoder in interface EdDSASupport<org.bouncycastle.jcajce.interfaces.EdDSAPublicKey,org.bouncycastle.jcajce.interfaces.EdDSAPrivateKey>
      Returns:
      the public key entry decoder implementation associated with the security provider.
    • getOpenSSHEDDSAPrivateKeyEntryDecoder

      public PrivateKeyEntryDecoder<org.bouncycastle.jcajce.interfaces.EdDSAPublicKey,org.bouncycastle.jcajce.interfaces.EdDSAPrivateKey> getOpenSSHEDDSAPrivateKeyEntryDecoder()
      Specified by:
      getOpenSSHEDDSAPrivateKeyEntryDecoder in interface EdDSASupport<org.bouncycastle.jcajce.interfaces.EdDSAPublicKey,org.bouncycastle.jcajce.interfaces.EdDSAPrivateKey>
      Returns:
      the private key entry decoder implementation associated with the security provider.
    • getEDDSASigner

      public Signature getEDDSASigner()
      Specified by:
      getEDDSASigner in interface EdDSASupport<org.bouncycastle.jcajce.interfaces.EdDSAPublicKey,org.bouncycastle.jcajce.interfaces.EdDSAPrivateKey>
      Returns:
      the signature implementation associated with the security provider.
    • getEDDSAKeySize

      public int getEDDSAKeySize(Key key)
      Specified by:
      getEDDSAKeySize in interface EdDSASupport<org.bouncycastle.jcajce.interfaces.EdDSAPublicKey,org.bouncycastle.jcajce.interfaces.EdDSAPrivateKey>
      Parameters:
      key - the key to get the size of.
      Returns:
      the size of the key if it is an EdDSA key, -1 otherwise.
    • getEDDSAPublicKeyType

      public Class<org.bouncycastle.jcajce.interfaces.EdDSAPublicKey> getEDDSAPublicKeyType()
      Specified by:
      getEDDSAPublicKeyType in interface EdDSASupport<org.bouncycastle.jcajce.interfaces.EdDSAPublicKey,org.bouncycastle.jcajce.interfaces.EdDSAPrivateKey>
      Returns:
      the public key class type associated with the security provider.
    • getEDDSAPrivateKeyType

      public Class<org.bouncycastle.jcajce.interfaces.EdDSAPrivateKey> getEDDSAPrivateKeyType()
      Specified by:
      getEDDSAPrivateKeyType in interface EdDSASupport<org.bouncycastle.jcajce.interfaces.EdDSAPublicKey,org.bouncycastle.jcajce.interfaces.EdDSAPrivateKey>
      Returns:
      the private key class type associated with the security provider.
    • compareEDDSAPPublicKeys

      public boolean compareEDDSAPPublicKeys(PublicKey k1, PublicKey k2)
      Specified by:
      compareEDDSAPPublicKeys in interface EdDSASupport<org.bouncycastle.jcajce.interfaces.EdDSAPublicKey,org.bouncycastle.jcajce.interfaces.EdDSAPrivateKey>
      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

      public boolean compareEDDSAPrivateKeys(PrivateKey k1, PrivateKey k2)
      Specified by:
      compareEDDSAPrivateKeys in interface EdDSASupport<org.bouncycastle.jcajce.interfaces.EdDSAPublicKey,org.bouncycastle.jcajce.interfaces.EdDSAPrivateKey>
      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

      public org.bouncycastle.jcajce.interfaces.EdDSAPublicKey recoverEDDSAPublicKey(PrivateKey key) throws GeneralSecurityException
      Specified by:
      recoverEDDSAPublicKey in interface EdDSASupport<org.bouncycastle.jcajce.interfaces.EdDSAPublicKey,org.bouncycastle.jcajce.interfaces.EdDSAPrivateKey>
      Parameters:
      key - the private key
      Returns:
      the public key associated with the private key.
      Throws:
      GeneralSecurityException
    • generateEDDSAPublicKey

      public org.bouncycastle.jcajce.interfaces.EdDSAPublicKey generateEDDSAPublicKey(byte[] seed) throws GeneralSecurityException
      Specified by:
      generateEDDSAPublicKey in interface EdDSASupport<org.bouncycastle.jcajce.interfaces.EdDSAPublicKey,org.bouncycastle.jcajce.interfaces.EdDSAPrivateKey>
      Parameters:
      seed - the raw public key bytes
      Returns:
      the associated public key
      Throws:
      GeneralSecurityException
    • generateEDDSAPrivateKey

      public org.bouncycastle.jcajce.interfaces.EdDSAPrivateKey generateEDDSAPrivateKey(byte[] seed) throws GeneralSecurityException, IOException
      Specified by:
      generateEDDSAPrivateKey in interface EdDSASupport<org.bouncycastle.jcajce.interfaces.EdDSAPublicKey,org.bouncycastle.jcajce.interfaces.EdDSAPrivateKey>
      Parameters:
      seed - the raw private key bytes
      Returns:
      the associated private key
      Throws:
      GeneralSecurityException
      IOException
    • putRawEDDSAPublicKey

      public <B extends Buffer> B putRawEDDSAPublicKey(B buffer, PublicKey key)
      Specified by:
      putRawEDDSAPublicKey in interface EdDSASupport<org.bouncycastle.jcajce.interfaces.EdDSAPublicKey,org.bouncycastle.jcajce.interfaces.EdDSAPrivateKey>
      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

      public <B extends Buffer> B putEDDSAKeyPair(B buffer, PublicKey pubKey, PrivateKey prvKey)
      Specified by:
      putEDDSAKeyPair in interface EdDSASupport<org.bouncycastle.jcajce.interfaces.EdDSAPublicKey,org.bouncycastle.jcajce.interfaces.EdDSAPrivateKey>
      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

      public KeySpec createPublicKeySpec(org.bouncycastle.jcajce.interfaces.EdDSAPublicKey publicKey)
      Specified by:
      createPublicKeySpec in interface EdDSASupport<org.bouncycastle.jcajce.interfaces.EdDSAPublicKey,org.bouncycastle.jcajce.interfaces.EdDSAPrivateKey>
      Parameters:
      publicKey - the public key
      Returns:
      a key spec from the public key
    • createPrivateKeySpec

      public KeySpec createPrivateKeySpec(org.bouncycastle.jcajce.interfaces.EdDSAPrivateKey privateKey)
      Specified by:
      createPrivateKeySpec in interface EdDSASupport<org.bouncycastle.jcajce.interfaces.EdDSAPublicKey,org.bouncycastle.jcajce.interfaces.EdDSAPrivateKey>
      Parameters:
      privateKey - the private key
      Returns:
      a key spec from the private key
    • getPublicKeyData

      public byte[] getPublicKeyData(org.bouncycastle.jcajce.interfaces.EdDSAPublicKey publicKey)
      Specified by:
      getPublicKeyData in interface EdDSASupport<org.bouncycastle.jcajce.interfaces.EdDSAPublicKey,org.bouncycastle.jcajce.interfaces.EdDSAPrivateKey>
      Parameters:
      publicKey - the public key
      Returns:
      the raw public key bytes associated with the key
    • getPrivateKeyData

      public byte[] getPrivateKeyData(org.bouncycastle.jcajce.interfaces.EdDSAPrivateKey privateKey) throws IOException
      Specified by:
      getPrivateKeyData in interface EdDSASupport<org.bouncycastle.jcajce.interfaces.EdDSAPublicKey,org.bouncycastle.jcajce.interfaces.EdDSAPrivateKey>
      Parameters:
      privateKey - the private key
      Returns:
      the raw private key bytes associated with the key
      Throws:
      IOException
    • getKeyFactoryAlgorithm

      public String getKeyFactoryAlgorithm()
      Specified by:
      getKeyFactoryAlgorithm in interface EdDSASupport<org.bouncycastle.jcajce.interfaces.EdDSAPublicKey,org.bouncycastle.jcajce.interfaces.EdDSAPrivateKey>
      Returns:
      the algorithm name used by the provider's KeyFactory.