Class JdkDelegatingPrivateKeyMethod

  • All Implemented Interfaces:
    io.netty.internal.tcnative.SSLPrivateKeyMethod

    final class JdkDelegatingPrivateKeyMethod
    extends java.lang.Object
    implements io.netty.internal.tcnative.SSLPrivateKeyMethod
    Implementation of OpenSslAsyncPrivateKeyMethod that delegates cryptographic operations to JDK signature providers for keys that cannot be accessed directly by OpenSSL.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static InternalLogger logger  
      private java.security.PrivateKey privateKey  
      private java.lang.String privateKeyTypeName  
      private static java.util.concurrent.ConcurrentMap<JdkDelegatingPrivateKeyMethod.CacheKey,​java.lang.String> PROVIDER_CACHE  
      private static IntObjectMap<java.lang.String> SSL_TO_JDK_SIGNATURE_ALGORITHM  
      • Fields inherited from interface io.netty.internal.tcnative.SSLPrivateKeyMethod

        SSL_SIGN_ECDSA_SECP256R1_SHA256, SSL_SIGN_ECDSA_SECP384R1_SHA384, SSL_SIGN_ECDSA_SECP521R1_SHA512, SSL_SIGN_ECDSA_SHA1, SSL_SIGN_ED25519, SSL_SIGN_RSA_PKCS1_MD5_SHA1, SSL_SIGN_RSA_PKCS1_SHA1, SSL_SIGN_RSA_PKCS1_SHA256, SSL_SIGN_RSA_PKCS1_SHA384, SSL_SIGN_RSA_PKCS1_SHA512, SSL_SIGN_RSA_PSS_RSAE_SHA256, SSL_SIGN_RSA_PSS_RSAE_SHA384, SSL_SIGN_RSA_PSS_RSAE_SHA512
    • Constructor Summary

      Constructors 
      Constructor Description
      JdkDelegatingPrivateKeyMethod​(java.security.PrivateKey privateKey)
      Creates a new JDK delegating async private key method.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static void configureOpenSslAlgorithmParameters​(java.security.Signature signature, int opensslAlgorithm)  
      private static void configurePssParameters​(java.security.Signature signature, java.security.spec.MGF1ParameterSpec mgfSpec, int saltLength)  
      private java.security.Signature createSignature​(int opensslAlgorithm)  
      byte[] decrypt​(long ssl, byte[] input)  
      private java.security.Signature findCompatibleSignature​(int opensslAlgorithm, java.lang.String jdkAlgorithm)  
      byte[] sign​(long ssl, int signatureAlgorithm, byte[] input)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • SSL_TO_JDK_SIGNATURE_ALGORITHM

        private static final IntObjectMap<java.lang.String> SSL_TO_JDK_SIGNATURE_ALGORITHM
      • privateKey

        private final java.security.PrivateKey privateKey
      • privateKeyTypeName

        private final java.lang.String privateKeyTypeName
    • Constructor Detail

      • JdkDelegatingPrivateKeyMethod

        JdkDelegatingPrivateKeyMethod​(java.security.PrivateKey privateKey)
        Creates a new JDK delegating async private key method.
        Parameters:
        privateKey - the private key to use for cryptographic operations
    • Method Detail

      • sign

        public byte[] sign​(long ssl,
                           int signatureAlgorithm,
                           byte[] input)
                    throws java.lang.Exception
        Specified by:
        sign in interface io.netty.internal.tcnative.SSLPrivateKeyMethod
        Throws:
        java.lang.Exception
      • decrypt

        public byte[] decrypt​(long ssl,
                              byte[] input)
        Specified by:
        decrypt in interface io.netty.internal.tcnative.SSLPrivateKeyMethod
      • createSignature

        private java.security.Signature createSignature​(int opensslAlgorithm)
                                                 throws java.security.NoSuchAlgorithmException
        Throws:
        java.security.NoSuchAlgorithmException
      • findCompatibleSignature

        private java.security.Signature findCompatibleSignature​(int opensslAlgorithm,
                                                                java.lang.String jdkAlgorithm)
                                                         throws java.security.NoSuchAlgorithmException
        Throws:
        java.security.NoSuchAlgorithmException
      • configureOpenSslAlgorithmParameters

        private static void configureOpenSslAlgorithmParameters​(java.security.Signature signature,
                                                                int opensslAlgorithm)
                                                         throws java.security.InvalidAlgorithmParameterException
        Throws:
        java.security.InvalidAlgorithmParameterException
      • configurePssParameters

        private static void configurePssParameters​(java.security.Signature signature,
                                                   java.security.spec.MGF1ParameterSpec mgfSpec,
                                                   int saltLength)
                                            throws java.security.InvalidAlgorithmParameterException
        Throws:
        java.security.InvalidAlgorithmParameterException