Class MGCardInfoEncryptor
java.lang.Object
com.gemalto.mfs.mwsdk.mobilegateway.utils.MGCardInfoEncryptor
A utility class to encrypt the contactless card information using the public key embedded in MG SDK.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]encrypt(byte[] key, byte[] identifier, byte[] pan, byte[] expiry, byte[] cvv2) A utility method to encrypt the contactless card details (PAN, expiry date and CVV) using the TSH public key in PKCS#7 format.static byte[]encryptCardInfo(byte[] publicKey, byte[] subjectKeyIdentifier, byte[] pan, byte[] expiry, byte[] cvv2) static byte[]encryptCardInfo(byte[] publicKey, byte[] subjectKeyIdentifier, byte[] pan, byte[] expiry, byte[] cvv2, byte[] nonce) static byte[]encryptPKCS7(byte[] subjectKeyIdentifier, byte[] publicKeyBytes, byte[] plainData) static byte[]A utility method to convert a hexadecimal string to byte array representation.
-
Constructor Details
-
MGCardInfoEncryptor
public MGCardInfoEncryptor()
-
-
Method Details
-
encrypt
public static byte[] encrypt(byte[] key, byte[] identifier, byte[] pan, byte[] expiry, byte[] cvv2) A utility method to encrypt the contactless card details (PAN, expiry date and CVV) using the TSH public key in PKCS#7 format.- Parameters:
key- The key to use for encryption. Typically, a TSH public key.identifier- The subject key identifier used during encryption.pan- The card primary account number.expiry- The card expiry date in "MMYY" format.cvv2- The card CVV (in 3 or 4 digits).- Returns:
- The encrypted card information.
- Throws:
RuntimeException- An exception will be thrown if an error occurs.
-
parseHex
A utility method to convert a hexadecimal string to byte array representation.- Parameters:
hexString-- Returns:
-
encryptCardInfo
public static byte[] encryptCardInfo(byte[] publicKey, byte[] subjectKeyIdentifier, byte[] pan, byte[] expiry, byte[] cvv2) -
encryptCardInfo
public static byte[] encryptCardInfo(byte[] publicKey, byte[] subjectKeyIdentifier, byte[] pan, byte[] expiry, byte[] cvv2, byte[] nonce) -
encryptPKCS7
public static byte[] encryptPKCS7(byte[] subjectKeyIdentifier, byte[] publicKeyBytes, byte[] plainData) throws org.bouncycastle.cms.CMSException, IOException - Throws:
org.bouncycastle.cms.CMSExceptionIOException
-