Class KeyPairGeneratorTest


  • public class KeyPairGeneratorTest
    extends java.lang.Object
    • Constructor Detail

      • KeyPairGeneratorTest

        public KeyPairGeneratorTest()
    • Method Detail

      • testRSAKeyPairGeneration

        public void testRSAKeyPairGeneration()
                                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • testRSAGeneratedKeyPairSigningCapabilities

        public void testRSAGeneratedKeyPairSigningCapabilities()
                                                        throws java.security.GeneralSecurityException
        Throws:
        java.security.GeneralSecurityException
      • testRSAGeneratedKeyPairEncryptionCapabilities

        public void testRSAGeneratedKeyPairEncryptionCapabilities()
                                                           throws java.security.GeneralSecurityException
        Checks that a generated RSA key pair encrypts and decrypts with every RSA padding scheme.

        A generated key may be held by the implementation in a form that differs from a key loaded through a KeyFactory, so the cipher path of RSACipherTest, which loads its keys, does not cover it.

        Throws:
        java.security.GeneralSecurityException - if the key generation, the encryption or the decryption fails
      • testRSAValidateGeneratedKeyPairEncoding

        public void testRSAValidateGeneratedKeyPairEncoding()
                                                     throws java.security.GeneralSecurityException
        Throws:
        java.security.GeneralSecurityException
      • testECKeyPairGeneration

        public void testECKeyPairGeneration()
                                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • testECGeneratedKeyPairSigningCapabilities

        public void testECGeneratedKeyPairSigningCapabilities()
                                                       throws java.security.GeneralSecurityException
        Throws:
        java.security.GeneralSecurityException
      • testECGeneratedKeyPairKeyAgreementCapabilities

        public void testECGeneratedKeyPairKeyAgreementCapabilities()
                                                            throws java.security.GeneralSecurityException
        Checks that two generated EC key pairs of the same curve agree on an ECDH shared secret.

        A generated key may be held by the implementation in a form that differs from a key loaded through a KeyFactory, so KeyAgreementTest, which loads its keys, does not cover it.

        Throws:
        java.security.GeneralSecurityException - if the key generation or the key agreement fails
      • testECValidateGeneratedKeyPairEncoding

        public void testECValidateGeneratedKeyPairEncoding()
                                                    throws java.security.GeneralSecurityException
        Throws:
        java.security.GeneralSecurityException
      • testInvalidAlgorithm

        public void testInvalidAlgorithm()
        Ensure invalid algorithm are handled correctly
      • testUnsupportedEcCurveIsRejected

        public void testUnsupportedEcCurveIsRejected()
                                              throws java.lang.Exception
        A curve the backend does not support is reported as an InvalidParameterException, not collapsed into a generic failure. The library raises that exception only for the error code the abstraction layer declares for an unsupported parameter.

        The companion positive case lives in testECKeyPairGeneration(): a backend that rejected every curve would fail there, so this test does not repeat a generation to guard against it.

        Throws:
        java.lang.Exception
      • testUnsupportedRsaKeySizeIsRejected

        public void testUnsupportedRsaKeySizeIsRejected()
                                                 throws java.lang.Exception
        An RSA key size the backend does not support is reported as an InvalidParameterException.

        The companion positive case lives in testRSAKeyPairGeneration().

        Throws:
        java.lang.Exception