Package com.microej.crypto.test.util
Class RsaTestResources
- java.lang.Object
-
- com.microej.crypto.test.util.RsaTestResources
-
public final class RsaTestResources extends java.lang.ObjectLists the RSA key sizes exercised by the test suite and locates the pre-generated test material (key pairs, self-signed certificate and signature) of a key size.The key sizes are read from the
com.microej.crypto.test.rsa.keysizesproperty, a comma separated list of sizes in bits, shared by the key pair generation, cipher, signature and certificate tests. Each listed size must have its material in the test resources, named after the size (rsa_<size>.crt,rsa_<size>_priv.der, ...). The key pair generation tests can restrict the list further with their own property, seegetKeyPairGeneratorKeySizes().
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_KEY_SIZESDefault key sizes: every size the test resources hold material for, hence every sizeKEY_SIZES_PROPERTYmay list.static java.lang.StringKEY_PAIR_GENERATOR_KEY_SIZES_PROPERTYOptional property restrictingKEY_SIZES_PROPERTYfor the key pair generation tests.static java.lang.StringKEY_SIZES_PROPERTYProperty listing the key sizes exercised by the test suite.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringalternatePublicKeyPath(int keySize)Gets the resource path of an X.509 DER public key of the given key size that is unrelated to the certificate.static java.lang.StringcertificatePath(int keySize)Gets the resource path of the DER self-signed certificate of the given key size.static int[]getKeyPairGeneratorKeySizes()Gets the key sizes generated by the key pair generation tests:KEY_PAIR_GENERATOR_KEY_SIZES_PROPERTYwhen set, otherwisegetKeySizes().static int[]getKeySizes()Gets the key sizes exercised by the test suite.static java.lang.StringprivateKeyPath(int keySize)Gets the resource path of the PKCS#8 DER private key that signed the certificate of the given key size.static java.lang.StringprotectedPrivateKeyPath(int keySize)Gets the resource path of the private key ofprivateKeyPath(int), encrypted as PKCS#8 DER with the passwordchangeit.static java.lang.StringpublicKeyPath(int keySize)Gets the resource path of the X.509 DER public key matchingprivateKeyPath(int).static java.lang.StringsignaturePath(int keySize)Gets the resource path of the SHA256withRSA signature of thedata4096.binresource, computed withprivateKeyPath(int).
-
-
-
Field Detail
-
KEY_SIZES_PROPERTY
public static final java.lang.String KEY_SIZES_PROPERTY
Property listing the key sizes exercised by the test suite.- See Also:
- Constant Field Values
-
KEY_PAIR_GENERATOR_KEY_SIZES_PROPERTY
public static final java.lang.String KEY_PAIR_GENERATOR_KEY_SIZES_PROPERTY
Optional property restrictingKEY_SIZES_PROPERTYfor the key pair generation tests.- See Also:
- Constant Field Values
-
DEFAULT_KEY_SIZES
public static final java.lang.String DEFAULT_KEY_SIZES
Default key sizes: every size the test resources hold material for, hence every sizeKEY_SIZES_PROPERTYmay list. A VEE Port whose backend lacks one of them restricts the list through the property.- See Also:
- Constant Field Values
-
-
Method Detail
-
getKeySizes
public static int[] getKeySizes()
Gets the key sizes exercised by the test suite.- Returns:
- the configured key sizes, or the default ones when the property is not set
- Throws:
java.lang.IllegalStateException- if the property is set to an empty list
-
getKeyPairGeneratorKeySizes
public static int[] getKeyPairGeneratorKeySizes()
Gets the key sizes generated by the key pair generation tests:KEY_PAIR_GENERATOR_KEY_SIZES_PROPERTYwhen set, otherwisegetKeySizes().- Returns:
- the key sizes to generate
- Throws:
java.lang.IllegalStateException- if the property lists a size that is not ingetKeySizes()
-
certificatePath
public static java.lang.String certificatePath(int keySize)
Gets the resource path of the DER self-signed certificate of the given key size.- Parameters:
keySize- the key size in bits- Returns:
- the certificate resource path
-
privateKeyPath
public static java.lang.String privateKeyPath(int keySize)
Gets the resource path of the PKCS#8 DER private key that signed the certificate of the given key size.- Parameters:
keySize- the key size in bits- Returns:
- the private key resource path
-
protectedPrivateKeyPath
public static java.lang.String protectedPrivateKeyPath(int keySize)
Gets the resource path of the private key ofprivateKeyPath(int), encrypted as PKCS#8 DER with the passwordchangeit.- Parameters:
keySize- the key size in bits- Returns:
- the encrypted private key resource path
-
publicKeyPath
public static java.lang.String publicKeyPath(int keySize)
Gets the resource path of the X.509 DER public key matchingprivateKeyPath(int).- Parameters:
keySize- the key size in bits- Returns:
- the public key resource path
-
alternatePublicKeyPath
public static java.lang.String alternatePublicKeyPath(int keySize)
Gets the resource path of an X.509 DER public key of the given key size that is unrelated to the certificate.- Parameters:
keySize- the key size in bits- Returns:
- the alternate public key resource path
-
signaturePath
public static java.lang.String signaturePath(int keySize)
Gets the resource path of the SHA256withRSA signature of thedata4096.binresource, computed withprivateKeyPath(int).RSA PKCS#1 v1.5 signing is deterministic, so this file is also the expected output of signing that resource with that key, and can be compared byte for byte.
- Parameters:
keySize- the key size in bits- Returns:
- the signature resource path
-
-