Class PSSParameters


  • public final class PSSParameters
    extends java.security.AlgorithmParametersSpi
    This class implements encoding and decoding of RSA-PSS parameters as specified in RFC 3447

    ASN.1 from RFC 3279 follows. Note that X9.62 (2005) has added some additional options.

     Its ASN.1 definition in PKCS#1 standard is described below:
    
     RSASSA-PSS-params ::= SEQUENCE {
     hashAlgorithm      [0] OAEP-PSSDigestAlgorithms  DEFAULT sha1,
     maskGenAlgorithm   [1] PKCS1MGFAlgorithms  DEFAULT mgf1SHA1,
     saltLength         [2] INTEGER  DEFAULT 20,
     trailerField       [3] INTEGER  DEFAULT 1
     }
    
    
     where
    
     OAEP-PSSDigestAlgorithms    ALGORITHM-IDENTIFIER ::= {
     { OID id-sha1 PARAMETERS NULL   }|
     { OID id-sha256 PARAMETERS NULL }|
     { OID id-sha384 PARAMETERS NULL }|
     { OID id-sha512 PARAMETERS NULL },
     ...  -- Allows for future expansion --
     }
    
     PKCS1MGFAlgorithms    ALGORITHM-IDENTIFIER ::= {
     { OID id-mgf1 PARAMETERS OAEP-PSSDigestAlgorithms },
     ...  -- Allows for future expansion --
     }
    
     
    The PSSParameterSpec class also has a member for storing mgf parameters.
    • Constructor Summary

      Constructors 
      Constructor Description
      PSSParameters()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected com.ibm.security.util.DerValue encodeHashAlg​(com.ibm.security.x509.AlgorithmId hashAlgorithm)
      Encodes hash algorithm CONTEXT_CONSTRUCTED_0 UNIVERSAL_CONSTRUCTED_SEQUENCE UNIVERSAL_PRIMITIVE_OBJECT_ID UNIVERSAL_PRIMITIVE_NULL
      protected com.ibm.security.util.DerValue encodeMaskGenAlg​(com.ibm.security.x509.AlgorithmId maskGenAlgorithm, java.security.spec.AlgorithmParameterSpec mgf1ParameterSpec)
      UNIVERSAL_CONSTRUCTED_SEQUENCE UNIVERSAL_PRIMITIVE_OBJECT_ID UNIVERSAL_CONSTRUCTRED_SEQUENCE UNIVERSAL_PRIMITIVE_OBJECT_ID UNIVERSAL_PRIMITIVE_NULL Encode MaskGenrationfunction and the digest algorithm used by mgf1
      protected com.ibm.security.util.DerValue encodeMgfParameterSpec​(java.security.spec.AlgorithmParameterSpec mgfParameterSpec)
      encode MGF'1 digest UNIVERSAL_CONSTRUCTRED_SEQUENCE UNIVERSAL_PRIMITIVE_OBJECT_ID UNIVERSAL_PRIMITIVE_NULL
      protected com.ibm.security.util.DerValue encodeSalt​(int salt)
      Encodes non default salt length
      protected com.ibm.security.util.DerValue encodeTrailerField​(int trailerField)
      Encodes non default TrailerField
      protected byte[] engineGetEncoded()
      Returns the parameters in encoded bytes.
      protected byte[] engineGetEncoded​(java.lang.String encodingMethod)
      Returns the parameters in encoded bytes with encoding method specified.
      protected <T extends java.security.spec.AlgorithmParameterSpec>
      T
      engineGetParameterSpec​(java.lang.Class<T> paramSpec)
      Return the parameter spec used by this parameter instance.
      protected void engineInit​(byte[] params)
      Initialize the PSSParameters by encoded bytes
      protected void engineInit​(byte[] params, java.lang.String format)
      Initialize the PSSParameters by encoded bytes with the specified decoding method.
      protected void engineInit​(java.security.spec.AlgorithmParameterSpec paramSpec)
      Initialize the PSSParameters by a PSSParameterSpec
      protected java.lang.String engineToString()  
      protected static java.security.AlgorithmParameters getAlgorithmParameters​(java.security.spec.PSSParameterSpec spec)
      Get Algorithmic parameters
      • Methods inherited from class java.lang.Object

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

      • hashAlgorithm

        protected com.ibm.security.x509.AlgorithmId hashAlgorithm
      • maskGenAlgorithm

        protected com.ibm.security.x509.AlgorithmId maskGenAlgorithm
      • mgfParameterSpec

        protected java.security.spec.AlgorithmParameterSpec mgfParameterSpec
      • saltLength

        protected int saltLength
      • trailerField

        protected int trailerField
    • Constructor Detail

      • PSSParameters

        public PSSParameters()
    • Method Detail

      • engineInit

        protected void engineInit​(java.security.spec.AlgorithmParameterSpec paramSpec)
                           throws java.security.spec.InvalidParameterSpecException
        Initialize the PSSParameters by a PSSParameterSpec
        Specified by:
        engineInit in class java.security.AlgorithmParametersSpi
        Parameters:
        paramSpec - the RSAPSS algorithm parameter spec for this instance.
        Throws:
        java.security.spec.InvalidParameterSpecException
      • engineInit

        protected void engineInit​(byte[] params)
                           throws java.io.IOException
        Initialize the PSSParameters by encoded bytes
        Specified by:
        engineInit in class java.security.AlgorithmParametersSpi
        Parameters:
        params - the encoded bytes of the parameters.
        Throws:
        java.io.IOException
      • engineInit

        protected void engineInit​(byte[] params,
                                  java.lang.String format)
                           throws java.io.IOException
        Initialize the PSSParameters by encoded bytes with the specified decoding method.
        Specified by:
        engineInit in class java.security.AlgorithmParametersSpi
        Parameters:
        params - the encoded bytes of the parameters.
        format - the decoding method to be used.
        Throws:
        java.io.IOException
      • engineGetEncoded

        protected byte[] engineGetEncoded()
                                   throws java.io.IOException
        Returns the parameters in encoded bytes.

        Only non default values will be encoded. With a single non default value, the encoding for hash looks as follows; CONTEXT_CONSTRUCTED_0 UNIVERSAL_CONSTRUCTED_SEQUENCE UNIVERSAL_PRIMITIVE_OBJECT_ID UNIVERSAL_PRIMITIVE_NULL

        CONTEXT_CONSTRUCTED_1 UNIVERSAL_CONSTRUCTED_SEQUENCE UNIVERSAL_PRIMITIVE_OBJECT_ID UNIVERSAL_CONSTRUCTRED_SEQUENCE UNIVERSAL_PRIMITIVE_OBJECT_ID UNIVERSAL_PRIMITIVE_NULL

        CONTEXT_CONSTRUCTED_2 UNIVERSAL_PRIMITIVE_INTEGER

        CONTEXT_CONSTRUCTED_3 UNIVERSAL_PRIMITIVE_INTEGER

        Specified by:
        engineGetEncoded in class java.security.AlgorithmParametersSpi
        Returns:
        byte[] the encoded parameters
        Throws:
        java.io.IOException
      • encodeSalt

        protected com.ibm.security.util.DerValue encodeSalt​(int salt)
                                                     throws java.io.IOException
        Encodes non default salt length
        Parameters:
        salt -
        Returns:
        Throws:
        java.io.IOException - CONTEXT_CONSTRUCTED_2 UNIVERSAL PRIMARY INTEGER
      • encodeTrailerField

        protected com.ibm.security.util.DerValue encodeTrailerField​(int trailerField)
                                                             throws java.io.IOException
        Encodes non default TrailerField
        Parameters:
        trailerField -
        Returns:
        Throws:
        java.io.IOException - CONTEXT_CONSTRUCTED_3 UNIVERSAL PRIMARY INTEGER
      • encodeHashAlg

        protected com.ibm.security.util.DerValue encodeHashAlg​(com.ibm.security.x509.AlgorithmId hashAlgorithm)
                                                        throws java.io.IOException
        Encodes hash algorithm CONTEXT_CONSTRUCTED_0 UNIVERSAL_CONSTRUCTED_SEQUENCE UNIVERSAL_PRIMITIVE_OBJECT_ID UNIVERSAL_PRIMITIVE_NULL
        Parameters:
        hashAlgorithm -
        Returns:
        Throws:
        java.io.IOException
      • encodeMaskGenAlg

        protected com.ibm.security.util.DerValue encodeMaskGenAlg​(com.ibm.security.x509.AlgorithmId maskGenAlgorithm,
                                                                  java.security.spec.AlgorithmParameterSpec mgf1ParameterSpec)
                                                           throws java.io.IOException
        UNIVERSAL_CONSTRUCTED_SEQUENCE UNIVERSAL_PRIMITIVE_OBJECT_ID UNIVERSAL_CONSTRUCTRED_SEQUENCE UNIVERSAL_PRIMITIVE_OBJECT_ID UNIVERSAL_PRIMITIVE_NULL Encode MaskGenrationfunction and the digest algorithm used by mgf1
        Parameters:
        maskGenAlgorithm -
        mgf1ParameterSpec -
        Returns:
        Throws:
        java.io.IOException
      • encodeMgfParameterSpec

        protected com.ibm.security.util.DerValue encodeMgfParameterSpec​(java.security.spec.AlgorithmParameterSpec mgfParameterSpec)
                                                                 throws java.io.IOException
        encode MGF'1 digest UNIVERSAL_CONSTRUCTRED_SEQUENCE UNIVERSAL_PRIMITIVE_OBJECT_ID UNIVERSAL_PRIMITIVE_NULL
        Returns:
        Throws:
        java.io.IOException
      • engineGetEncoded

        protected byte[] engineGetEncoded​(java.lang.String encodingMethod)
                                   throws java.io.IOException
        Returns the parameters in encoded bytes with encoding method specified.
        Specified by:
        engineGetEncoded in class java.security.AlgorithmParametersSpi
        Returns:
        byte[] encoded parameters.
        Throws:
        java.io.IOException
      • engineGetParameterSpec

        protected <T extends java.security.spec.AlgorithmParameterSpec> T engineGetParameterSpec​(java.lang.Class<T> paramSpec)
                                                                                          throws java.security.spec.InvalidParameterSpecException
        Return the parameter spec used by this parameter instance.
        Specified by:
        engineGetParameterSpec in class java.security.AlgorithmParametersSpi
        Parameters:
        paramSpec - the parameter spec class to be returned
        Returns:
        AlgorithmParameterSpec the newly generated parameterSpec
        Throws:
        java.security.spec.InvalidParameterSpecException
      • engineToString

        protected java.lang.String engineToString()
        Specified by:
        engineToString in class java.security.AlgorithmParametersSpi
      • getAlgorithmParameters

        protected static java.security.AlgorithmParameters getAlgorithmParameters​(java.security.spec.PSSParameterSpec spec)
                                                                           throws java.security.InvalidKeyException,
                                                                                  java.security.spec.InvalidParameterSpecException
        Get Algorithmic parameters
        Parameters:
        spec -
        Returns:
        Throws:
        java.security.InvalidKeyException
        java.security.spec.InvalidParameterSpecException