Class ECDSAPublicKeyEntryDecoder

    • Constructor Detail

      • ECDSAPublicKeyEntryDecoder

        public ECDSAPublicKeyEntryDecoder()
    • Method Detail

      • decodePublicKey

        public java.security.interfaces.ECPublicKey decodePublicKey​(SessionContext session,
                                                                    java.lang.String keyType,
                                                                    java.io.InputStream keyData,
                                                                    java.util.Map<java.lang.String,​java.lang.String> headers)
                                                             throws java.io.IOException,
                                                                    java.security.GeneralSecurityException
        Parameters:
        session - The SessionContext for invoking this command - may be null if not invoked within a session context (e.g., offline tool or session unknown).
        keyType - The reported / encode key type
        keyData - The key data bytes stream positioned after the key type decoding and making sure it is one of the supported types
        headers - Any headers that may have been available when data was read
        Returns:
        The decoded PublicKey
        Throws:
        java.io.IOException - If failed to read from the data stream
        java.security.GeneralSecurityException - If failed to generate the key
      • decodePublicKey

        java.security.interfaces.ECPublicKey decodePublicKey​(ECCurves curve,
                                                             java.io.InputStream keyData)
                                                      throws java.io.IOException,
                                                             java.security.GeneralSecurityException
        Throws:
        java.io.IOException
        java.security.GeneralSecurityException
      • clonePublicKey

        public java.security.interfaces.ECPublicKey clonePublicKey​(java.security.interfaces.ECPublicKey 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 java.security.interfaces.ECPrivateKey clonePrivateKey​(java.security.interfaces.ECPrivateKey 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
      • encodePublicKey

        public java.lang.String encodePublicKey​(java.io.OutputStream s,
                                                java.security.interfaces.ECPublicKey key)
                                         throws java.io.IOException
        Description copied from interface: PublicKeyEntryDecoder
        Encodes the PublicKey using the OpenSSH format - same one used by the decodePublicKey method(s)
        Parameters:
        s - The OutputStream to write the data to
        key - The PublicKey - may not be null
        Returns:
        The key type value - one of the KeyTypeNamesSupport.getSupportedKeyTypes()
        Throws:
        java.io.IOException - If failed to generate the encoding
      • encodePublicKey

        static void encodePublicKey​(java.io.OutputStream s,
                                    java.lang.String keyType,
                                    ECCurves curve,
                                    java.security.spec.ECPoint w)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • 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
      • generateKeyPair

        public java.security.KeyPair generateKeyPair​(int keySize)
                                              throws java.security.GeneralSecurityException
        Parameters:
        keySize - Key size in bits
        Returns:
        A KeyPair with the specified key size
        Throws:
        java.security.GeneralSecurityException - if unable to generate the pair
      • 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