Class X509CertSupportNatives
- java.lang.Object
-
- com.microej.crypto.internal.natives.X509CertSupportNatives
-
public class X509CertSupportNatives extends java.lang.ObjectMock implementation of the LLAPI: LLSEC_X509
-
-
Field Summary
Fields Modifier and Type Field Description protected static intJ_SEC_NO_ERRORNot an errorprotected static intJ_UNKNOWN_ERRORUnknown errorprotected static intJ_X509_CERT_EXPIRED_ERRORX509 certificate checkValidity error: expiredprotected static intJ_X509_CERT_NOT_YET_VALID_ERRORX509 certificate checkValidity error: not yet valid
-
Constructor Summary
Constructors Constructor Description X509CertSupportNatives()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intappendCertToPath(int cpv, byte[] x509)static intappendTrustedCertificate(int cpv, byte[] x509)static intcheckValidity(byte[] cert, int certLen)Checks that the certificate is currently valid, i.e.static voidcloseCertPathValidator(int cpv)static booleanexpectForwardCertPath()static intgetKeyData(byte[] cert, int certLen)Extracts the public key from the given certificate and registers it as a native resource.static intgetX500PrincipalData(byte[] cert, int certLen, byte[] principalData, int principalDataLength, boolean getIssuer)static intnativeGetCloseKeyId()static intnewCertPathValidator()static intparse(byte[] cert, int off, int len)Parses the given certificate to validate it and returns its encoded format type.static intvalidateCertPath(int cpv)static intverify(byte[] cert, int certLength, int nativeId)
-
-
-
Field Detail
-
J_SEC_NO_ERROR
protected static final int J_SEC_NO_ERROR
Not an error- See Also:
- Constant Field Values
-
J_UNKNOWN_ERROR
protected static final int J_UNKNOWN_ERROR
Unknown error- See Also:
- Constant Field Values
-
J_X509_CERT_EXPIRED_ERROR
protected static final int J_X509_CERT_EXPIRED_ERROR
X509 certificate checkValidity error: expired- See Also:
- Constant Field Values
-
J_X509_CERT_NOT_YET_VALID_ERROR
protected static final int J_X509_CERT_NOT_YET_VALID_ERROR
X509 certificate checkValidity error: not yet valid- See Also:
- Constant Field Values
-
-
Method Detail
-
parse
public static int parse(byte[] cert, int off, int len)Parses the given certificate to validate it and returns its encoded format type.- Parameters:
cert- the certificate bufferoff- the offset in the buffer at which the certificate content startslen- the certificate content length- Returns:
- the certificate encoded format type (0 if PEM format or 1 if DER format);
J_CERT_PARSE_ERRORif the certificate is not valid or an error occurs.
-
getKeyData
public static int getKeyData(byte[] cert, int certLen) throws ej.sni.NativeExceptionExtracts the public key from the given certificate and registers it as a native resource.- Parameters:
cert- the certificate buffercertLen- the certificate content length- Returns:
- the registered native resource id holding the certificate's public key.
- Throws:
ej.sni.NativeException- on error.
-
verify
public static int verify(byte[] cert, int certLength, int nativeId) throws ej.sni.NativeException- Throws:
ej.sni.NativeException
-
getX500PrincipalData
public static int getX500PrincipalData(byte[] cert, int certLen, byte[] principalData, int principalDataLength, boolean getIssuer) throws ej.sni.NativeException- Throws:
ej.sni.NativeException
-
nativeGetCloseKeyId
public static int nativeGetCloseKeyId()
-
checkValidity
public static int checkValidity(byte[] cert, int certLen) throws ej.sni.NativeExceptionChecks that the certificate is currently valid, i.e. the current time is within the specified validity period.- Parameters:
cert- the encoded certificate datacertLen- encoded data length- Returns:
J_SEC_NO_ERRORon success,J_X509_CERT_EXPIRED_ERRORif certificate expired,J_X509_CERT_NOT_YET_VALID_ERRORif certificate is not yet valid- Throws:
ej.sni.NativeException- on error
-
newCertPathValidator
public static int newCertPathValidator()
-
appendTrustedCertificate
public static int appendTrustedCertificate(int cpv, byte[] x509)
-
expectForwardCertPath
public static boolean expectForwardCertPath()
-
appendCertToPath
public static int appendCertToPath(int cpv, byte[] x509)
-
validateCertPath
public static int validateCertPath(int cpv) throws java.security.GeneralSecurityException- Throws:
java.security.GeneralSecurityException
-
closeCertPathValidator
public static void closeCertPathValidator(int cpv)
-
-