Package com.microej.crypto.test
Class KeyPairGeneratorTest
- java.lang.Object
-
- com.microej.crypto.test.KeyPairGeneratorTest
-
public class KeyPairGeneratorTest extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description KeyPairGeneratorTest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidtestECGeneratedKeyPairKeyAgreementCapabilities()Checks that two generated EC key pairs of the same curve agree on an ECDH shared secret.voidtestECGeneratedKeyPairSigningCapabilities()voidtestECKeyPairGeneration()voidtestECValidateGeneratedKeyPairEncoding()voidtestInvalidAlgorithm()Ensure invalid algorithm are handled correctlyvoidtestRSAGeneratedKeyPairEncryptionCapabilities()Checks that a generated RSA key pair encrypts and decrypts with every RSA padding scheme.voidtestRSAGeneratedKeyPairSigningCapabilities()voidtestRSAKeyPairGeneration()voidtestRSAValidateGeneratedKeyPairEncoding()voidtestUnsupportedEcCurveIsRejected()A curve the backend does not support is reported as anInvalidParameterException, not collapsed into a generic failure.voidtestUnsupportedRsaKeySizeIsRejected()An RSA key size the backend does not support is reported as anInvalidParameterException.
-
-
-
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.GeneralSecurityExceptionChecks 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 ofRSACipherTest, 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.GeneralSecurityExceptionChecks 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, soKeyAgreementTest, 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.ExceptionA curve the backend does not support is reported as anInvalidParameterException, 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.ExceptionAn RSA key size the backend does not support is reported as anInvalidParameterException.The companion positive case lives in
testRSAKeyPairGeneration().- Throws:
java.lang.Exception
-
-