Package com.microej.crypto.test
Class CertificateTest
- java.lang.Object
-
- com.microej.crypto.test.CertificateTest
-
public class CertificateTest extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description CertificateTest()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidbeforeClass()voidcheckValidityDoesNotThrowExceptionForValidCertificate()Uses a known certificate valid for a long time, uses current time to check the certificate validity.
The test succeeds if there is no exception.voidcheckValidityThrowsExceptionForCertificateNotYetValid()Uses a known valid in the future certificate, uses current time to check the certificate validity.
The test expects a CertificateNotYetValidException exception.voidcheckValidityThrowsExceptionForExpiredCertificate()Uses a known old certificate, uses current time to check the certificate validity.
The test expects a CertificateExpiredException exception.voidtestCertEC()Checks that the encoded form of the certificate of every configured Elliptic Curve is the DER resource it was loaded from.voidtestCertPem()Checks that the encoded form of a certificate read in PEM is the PEM resource it was loaded from.voidtestCertRSA()Checks that the encoded form of the certificate of every configured RSA key size is the DER resource it was loaded from.voidverifyCertificateWithInvalidKey_EC()Verifies the signature of a certificate using an unrelated public key.voidverifyCertificateWithInvalidKey_RSA()Verifies the signature of a certificate using an unrelated public key.voidverifyCertificateWithValidKey_EC()Verifies the signature of a certificate using the public part of the key that was used to sign it.voidverifyCertificateWithValidKey_RSA()Verifies the signature of a certificate using the public part of the key that was used to sign it.
-
-
-
Method Detail
-
beforeClass
public static void beforeClass()
-
testCertRSA
public void testCertRSA() throws java.security.cert.CertificateException, java.io.IOExceptionChecks that the encoded form of the certificate of every configured RSA key size is the DER resource it was loaded from.- Throws:
java.io.IOExceptionjava.security.cert.CertificateException
-
testCertPem
public void testCertPem() throws java.security.cert.CertificateException, java.io.IOExceptionChecks that the encoded form of a certificate read in PEM is the PEM resource it was loaded from.The expectation is derived from the resource rather than written out, so that regenerating the test material does not require editing this test. Line separators are removed on both sides because the file is stored in git and its line endings depend on the checkout.
- Throws:
java.io.IOExceptionjava.security.cert.CertificateException
-
testCertEC
public void testCertEC() throws java.security.cert.CertificateException, java.io.IOExceptionChecks that the encoded form of the certificate of every configured Elliptic Curve is the DER resource it was loaded from.- Throws:
java.io.IOExceptionjava.security.cert.CertificateException
-
checkValidityDoesNotThrowExceptionForValidCertificate
public void checkValidityDoesNotThrowExceptionForValidCertificate() throws java.security.cert.CertificateException, java.io.IOExceptionUses a known certificate valid for a long time, uses current time to check the certificate validity.
The test succeeds if there is no exception.- Throws:
java.security.cert.CertificateException- for any certificate related errorjava.io.IOException- for any file related error
-
checkValidityThrowsExceptionForCertificateNotYetValid
public void checkValidityThrowsExceptionForCertificateNotYetValid() throws java.security.cert.CertificateException, java.io.IOExceptionUses a known valid in the future certificate, uses current time to check the certificate validity.
The test expects a CertificateNotYetValidException exception.- Throws:
java.security.cert.CertificateException- for any certificate related errorjava.io.IOException- for any file related error
-
checkValidityThrowsExceptionForExpiredCertificate
public void checkValidityThrowsExceptionForExpiredCertificate() throws java.security.cert.CertificateException, java.io.IOExceptionUses a known old certificate, uses current time to check the certificate validity.
The test expects a CertificateExpiredException exception.- Throws:
java.security.cert.CertificateException- for any certificate related errorjava.io.IOException- for any file related error
-
verifyCertificateWithValidKey_EC
public void verifyCertificateWithValidKey_EC() throws java.lang.ExceptionVerifies the signature of a certificate using the public part of the key that was used to sign it. The test succeed if the signature is valid. PK: EC, every configured curve- Throws:
java.lang.Exception
-
verifyCertificateWithValidKey_RSA
public void verifyCertificateWithValidKey_RSA() throws java.lang.ExceptionVerifies the signature of a certificate using the public part of the key that was used to sign it. The test succeed if the signature is valid PK: RSA, every configured key size- Throws:
java.lang.Exception
-
verifyCertificateWithInvalidKey_EC
public void verifyCertificateWithInvalidKey_EC() throws java.lang.ExceptionVerifies the signature of a certificate using an unrelated public key. The test succeed if the signature is invalid. PK: EC, every configured curve- Throws:
java.lang.Exception
-
verifyCertificateWithInvalidKey_RSA
public void verifyCertificateWithInvalidKey_RSA() throws java.lang.ExceptionVerifies the signature of a certificate using an unrelated public key. The test succeed if the signature is invalid. PK: RSA, every configured key size- Throws:
java.lang.Exception
-
-