Class OpenSSHEd25519PrivateKeyEntryDecoder

    • Constructor Detail

      • OpenSSHEd25519PrivateKeyEntryDecoder

        public OpenSSHEd25519PrivateKeyEntryDecoder()
    • Method Detail

      • decodePrivateKey

        public net.i2p.crypto.eddsa.EdDSAPrivateKey decodePrivateKey​(SessionContext session,
                                                                     java.lang.String keyType,
                                                                     FilePasswordProvider passwordProvider,
                                                                     java.io.InputStream keyData)
                                                              throws java.io.IOException,
                                                                     java.security.GeneralSecurityException
        Parameters:
        session - The SessionContext for invoking this load command - may be null if not invoked within a session context (e.g., offline tool or session unknown).
        keyType - The reported / encode key type
        passwordProvider - The FilePasswordProvider to use in case the data is encrypted - may be null if no encrypted data is expected
        keyData - The key data bytes stream positioned after the key type decoding and making sure it is one of the supported types
        Returns:
        The decoded PrivateKey
        Throws:
        java.io.IOException - If failed to read from the data stream
        java.security.GeneralSecurityException - If failed to generate the key
      • encodePrivateKey

        public java.lang.String encodePrivateKey​(java.io.OutputStream s,
                                                 net.i2p.crypto.eddsa.EdDSAPrivateKey key)
                                          throws java.io.IOException
        Description copied from interface: PrivateKeyEntryDecoder
        Encodes the PrivateKey using the OpenSSH format - same one used by the decodePublicKey method(s)
        Parameters:
        s - The OutputStream to write the data to
        key - The PrivateKey - may not be null
        Returns:
        The key type value - one of the KeyTypeNamesSupport.getSupportedKeyTypes() or null if encoding not supported
        Throws:
        java.io.IOException - If failed to generate the encoding
      • isPublicKeyRecoverySupported

        public boolean isPublicKeyRecoverySupported()
      • recoverPublicKey

        public net.i2p.crypto.eddsa.EdDSAPublicKey recoverPublicKey​(net.i2p.crypto.eddsa.EdDSAPrivateKey prvKey)
                                                             throws java.security.GeneralSecurityException
        Description copied from interface: PrivateKeyEntryDecoder
        Attempts to recover the public key given the private one
        Parameters:
        prvKey - The PrivateKey
        Returns:
        The recovered PublicKey - null if cannot recover it
        Throws:
        java.security.GeneralSecurityException - If failed to generate the public key
      • clonePublicKey

        public net.i2p.crypto.eddsa.EdDSAPublicKey clonePublicKey​(net.i2p.crypto.eddsa.EdDSAPublicKey key)
                                                           throws java.security.GeneralSecurityException
        Parameters:
        key - The PublicKey to clone - ignored if null
        Returns:
        The cloned key (or null if no original key)
        Throws:
        java.security.GeneralSecurityException - If failed to clone the key
      • clonePrivateKey

        public net.i2p.crypto.eddsa.EdDSAPrivateKey clonePrivateKey​(net.i2p.crypto.eddsa.EdDSAPrivateKey key)
                                                             throws java.security.GeneralSecurityException
        Parameters:
        key - The PrivateKey to clone - ignored if null
        Returns:
        The cloned key (or null if no original key)
        Throws:
        java.security.GeneralSecurityException - If failed to clone the key
      • getKeyPairGenerator

        public java.security.KeyPairGenerator getKeyPairGenerator()
                                                           throws java.security.GeneralSecurityException
        Returns:
        A KeyPairGenerator suitable for this decoder
        Throws:
        java.security.GeneralSecurityException - If failed to create the generator
      • getKeyFactoryInstance

        public java.security.KeyFactory getKeyFactoryInstance()
                                                       throws java.security.GeneralSecurityException
        Returns:
        A KeyFactory suitable for the specific decoder type
        Throws:
        java.security.GeneralSecurityException - If failed to create one