Class EcTestResources


  • public final class EcTestResources
    extends java.lang.Object
    Lists 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.curves property, 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 of SUPPORTED_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, see getKeyPairGeneratorCurves().

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String CURVES_PROPERTY
      Property listing the curves exercised by the test suite.
      static java.lang.String DEFAULT_CURVES
      Default curves: the supported curves minus secp192r1, secp224r1 and secp256k1, which recent JDKs dropped.
      static java.lang.String KEY_PAIR_GENERATOR_CURVES_PROPERTY
      Optional property restricting CURVES_PROPERTY for the key pair generation tests.
      static java.lang.String SUPPORTED_CURVES
      Every curve the test resources hold material for, hence every curve CURVES_PROPERTY may list.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      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.
      static java.lang.String certificatePath​(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_PROPERTY when set, otherwise getCurves().
      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.
      static java.lang.String protectedPrivateKeyPath​(java.lang.String curveName)
      Gets the resource path of the private key of privateKeyPath(String), encrypted as PKCS#8 DER with the password changeit.
      static java.lang.String publicKeyPath​(java.lang.String curveName)
      Gets the resource path of the X.509 DER public key matching privateKeyPath(String).
      static java.lang.String signaturePath​(java.lang.String curveName)
      Gets the resource path of the SHA256withECDSA signature of the data4096.bin resource, computed with privateKeyPath(String).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 restricting CURVES_PROPERTY for 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 curve CURVES_PROPERTY may 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_PROPERTY when set, otherwise getCurves().
        Returns:
        the curves to generate
        Throws:
        java.lang.IllegalStateException - if the property lists a curve that is not in getCurves()
      • 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 of privateKeyPath(String), encrypted as PKCS#8 DER with the password changeit.
        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 matching privateKeyPath(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 the data4096.bin resource, computed with privateKeyPath(String).
        Parameters:
        curveName - the Java standard curve name
        Returns:
        the signature resource path