Class OpenSSHRSAPrivateKeyDecoder

    • Field Detail

      • DEFAULT_PUBLIC_EXPONENT

        public static final java.math.BigInteger DEFAULT_PUBLIC_EXPONENT
    • Constructor Detail

      • OpenSSHRSAPrivateKeyDecoder

        public OpenSSHRSAPrivateKeyDecoder()
    • Method Detail

      • decodePrivateKey

        public java.security.interfaces.RSAPrivateKey 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
      • isPublicKeyRecoverySupported

        public boolean isPublicKeyRecoverySupported()
      • recoverPublicKey

        public java.security.interfaces.RSAPublicKey recoverPublicKey​(java.security.interfaces.RSAPrivateKey privateKey)
                                                               throws java.security.GeneralSecurityException
        Description copied from interface: PrivateKeyEntryDecoder
        Attempts to recover the public key given the private one
        Parameters:
        privateKey - The PrivateKey
        Returns:
        The recovered PublicKey - null if cannot recover it
        Throws:
        java.security.GeneralSecurityException - If failed to generate the public key
      • clonePublicKey

        public java.security.interfaces.RSAPublicKey clonePublicKey​(java.security.interfaces.RSAPublicKey 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.RSAPrivateKey clonePrivateKey​(java.security.interfaces.RSAPrivateKey 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