Package com.microej.crypto.test.util
Class EcTestResources
- java.lang.Object
-
- com.microej.crypto.test.util.EcTestResources
-
public final class EcTestResources extends java.lang.ObjectLists the elliptic curves exercised by the test suite and locates the pre-generated test material (key pairs, self-signed certificate and signature) of a curve.The curves are read from the
com.microej.crypto.test.ec.curvesproperty, a comma separated list of Java standard curve names, shared by the key pair generation, signature and certificate tests. Each listed curve must be one ofSUPPORTED_CURVES, the curves with material in the test resources, named after the curve (ec_<curve>.crt,ec_<curve>_priv.der, ...). The key pair generation tests can restrict the list further with their own property, seegetKeyPairGeneratorCurves().
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCURVES_PROPERTYProperty listing the curves exercised by the test suite.static java.lang.StringDEFAULT_CURVESDefault curves: the supported curves minus secp192r1, secp224r1 and secp256k1, which recent JDKs dropped.static java.lang.StringKEY_PAIR_GENERATOR_CURVES_PROPERTYOptional property restrictingCURVES_PROPERTYfor the key pair generation tests.static java.lang.StringSUPPORTED_CURVESEvery curve the test resources hold material for, hence every curveCURVES_PROPERTYmay list.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringalternatePublicKeyPath(java.lang.String curveName)Gets the resource path of an X.509 DER public key of the given curve that is unrelated to the certificate.static java.lang.StringcertificatePath(java.lang.String curveName)Gets the resource path of the DER self-signed certificate of the given curve.static java.lang.String[]getCurves()Gets the curves exercised by the test suite.static java.lang.String[]getKeyPairGeneratorCurves()Gets the curves generated by the key pair generation tests:KEY_PAIR_GENERATOR_CURVES_PROPERTYwhen set, otherwisegetCurves().static java.lang.StringprivateKeyPath(java.lang.String curveName)Gets the resource path of the PKCS#8 DER private key that signed the certificate of the given curve.static java.lang.StringprotectedPrivateKeyPath(java.lang.String curveName)Gets the resource path of the private key ofprivateKeyPath(String), encrypted as PKCS#8 DER with the passwordchangeit.static java.lang.StringpublicKeyPath(java.lang.String curveName)Gets the resource path of the X.509 DER public key matchingprivateKeyPath(String).static java.lang.StringsignaturePath(java.lang.String curveName)Gets the resource path of the SHA256withECDSA signature of thedata4096.binresource, computed withprivateKeyPath(String).
-
-
-
Field Detail
-
CURVES_PROPERTY
public static final java.lang.String CURVES_PROPERTY
Property listing the curves exercised by the test suite.- See Also:
- Constant Field Values
-
KEY_PAIR_GENERATOR_CURVES_PROPERTY
public static final java.lang.String KEY_PAIR_GENERATOR_CURVES_PROPERTY
Optional property restrictingCURVES_PROPERTYfor the key pair generation tests.- See Also:
- Constant Field Values
-
SUPPORTED_CURVES
public static final java.lang.String SUPPORTED_CURVES
Every curve the test resources hold material for, hence every curveCURVES_PROPERTYmay list.- See Also:
- Constant Field Values
-
DEFAULT_CURVES
public static final java.lang.String DEFAULT_CURVES
Default curves: the supported curves minus secp192r1, secp224r1 and secp256k1, which recent JDKs dropped.- See Also:
- Constant Field Values
-
-
Method Detail
-
getCurves
public static java.lang.String[] getCurves()
Gets the curves exercised by the test suite.An empty list would make every curve loop pass without checking anything, so it is rejected: a VEE Port whose backend has no EC support excludes the EC test classes instead.
- Returns:
- the configured curve names, or the default ones when the property is not set
- Throws:
java.lang.IllegalStateException- if the property is set to an empty list
-
getKeyPairGeneratorCurves
public static java.lang.String[] getKeyPairGeneratorCurves()
Gets the curves generated by the key pair generation tests:KEY_PAIR_GENERATOR_CURVES_PROPERTYwhen set, otherwisegetCurves().- Returns:
- the curves to generate
- Throws:
java.lang.IllegalStateException- if the property lists a curve that is not ingetCurves()
-
certificatePath
public static java.lang.String certificatePath(java.lang.String curveName)
Gets the resource path of the DER self-signed certificate of the given curve.- Parameters:
curveName- the Java standard curve name- Returns:
- the certificate resource path
-
privateKeyPath
public static java.lang.String privateKeyPath(java.lang.String curveName)
Gets the resource path of the PKCS#8 DER private key that signed the certificate of the given curve.- Parameters:
curveName- the Java standard curve name- Returns:
- the private key resource path
-
protectedPrivateKeyPath
public static java.lang.String protectedPrivateKeyPath(java.lang.String curveName)
Gets the resource path of the private key ofprivateKeyPath(String), encrypted as PKCS#8 DER with the passwordchangeit.- Parameters:
curveName- the Java standard curve name- Returns:
- the encrypted private key resource path
-
publicKeyPath
public static java.lang.String publicKeyPath(java.lang.String curveName)
Gets the resource path of the X.509 DER public key matchingprivateKeyPath(String).- Parameters:
curveName- the Java standard curve name- Returns:
- the public key resource path
-
alternatePublicKeyPath
public static java.lang.String alternatePublicKeyPath(java.lang.String curveName)
Gets the resource path of an X.509 DER public key of the given curve that is unrelated to the certificate.- Parameters:
curveName- the Java standard curve name- Returns:
- the alternate public key resource path
-
signaturePath
public static java.lang.String signaturePath(java.lang.String curveName)
Gets the resource path of the SHA256withECDSA signature of thedata4096.binresource, computed withprivateKeyPath(String).- Parameters:
curveName- the Java standard curve name- Returns:
- the signature resource path
-
-