Package com.microej.crypto.test
Class KeyFactoryTest
- java.lang.Object
-
- com.microej.crypto.test.KeyFactoryTest
-
public class KeyFactoryTest extends java.lang.ObjectThis test class can be used to validate aKeyFactorylow-level implementation.Currently, only the
ECPublicKeyNamedCurveSpecparameter is tested.
-
-
Constructor Summary
Constructors Constructor Description KeyFactoryTest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidtestExportPrivateKeyToPkcs8()voidtestGeneratePrivateRejectsInvalidEncoding()Encoded private key bytes the backend cannot decode are reported with the checked exception the JCA declares, not with a runtime exception an Application following the JCA contract would not catch.voidtestGeneratePublicKeyFromECNamedCurveAndAffineCoordinates()voidtestGeneratePublicRejectsInvalidEncoding()Encoded public key bytes the backend cannot decode are reported with the checked exception the JCA declares.voidtestGeneratePublicRejectsUnknownCurve()A named-curve public key spec the backend cannot use is reported with the checked exception the JCA declares.voidtestPrivateKeyGetEncodedReturnsDefensiveCopy()Verifies that thePrivateKeyreturned by aKeyFactoryhands back a fresh defensive copy fromKey.getEncoded()on every call, so a caller that mutates the returned array cannot corrupt the key's cached encoding.voidtestPublicKeyGetEncodedReturnsDefensiveCopy()Verifies that thePublicKeyreturned by aKeyFactoryhands back a fresh defensive copy fromKey.getEncoded()on every call, so a caller that mutates the returned array cannot corrupt the key's cached encoding.
-
-
-
Method Detail
-
testExportPrivateKeyToPkcs8
public void testExportPrivateKeyToPkcs8() throws java.lang.Exception- Throws:
java.lang.Exception
-
testGeneratePublicKeyFromECNamedCurveAndAffineCoordinates
public void testGeneratePublicKeyFromECNamedCurveAndAffineCoordinates() throws java.lang.Exception- Throws:
java.lang.Exception
-
testGeneratePrivateRejectsInvalidEncoding
public void testGeneratePrivateRejectsInvalidEncoding() throws java.lang.ExceptionEncoded private key bytes the backend cannot decode are reported with the checked exception the JCA declares, not with a runtime exception an Application following the JCA contract would not catch.- Throws:
java.lang.Exception
-
testGeneratePublicRejectsInvalidEncoding
public void testGeneratePublicRejectsInvalidEncoding() throws java.lang.ExceptionEncoded public key bytes the backend cannot decode are reported with the checked exception the JCA declares.- Throws:
java.lang.Exception
-
testGeneratePublicRejectsUnknownCurve
public void testGeneratePublicRejectsUnknownCurve() throws java.lang.ExceptionA named-curve public key spec the backend cannot use is reported with the checked exception the JCA declares.An unknown curve name is used rather than coordinates off the curve: not every backend checks that the point lies on the curve when importing it.
- Throws:
java.lang.Exception
-
testPrivateKeyGetEncodedReturnsDefensiveCopy
public void testPrivateKeyGetEncodedReturnsDefensiveCopy() throws java.lang.ExceptionVerifies that thePrivateKeyreturned by aKeyFactoryhands back a fresh defensive copy fromKey.getEncoded()on every call, so a caller that mutates the returned array cannot corrupt the key's cached encoding.- Throws:
java.lang.Exception
-
testPublicKeyGetEncodedReturnsDefensiveCopy
public void testPublicKeyGetEncodedReturnsDefensiveCopy() throws java.lang.ExceptionVerifies that thePublicKeyreturned by aKeyFactoryhands back a fresh defensive copy fromKey.getEncoded()on every call, so a caller that mutates the returned array cannot corrupt the key's cached encoding.- Throws:
java.lang.Exception
-
-