Class MGCardInfoEncryptor
- java.lang.Object
-
- com.gemalto.mfs.mwsdk.mobilegateway.utils.MGCardInfoEncryptor
-
public class MGCardInfoEncryptor extends java.lang.Object
A utility class to encrypt the Contactless Card Information using the public key embedded in the MG SDK.
-
-
Constructor Summary
Constructors Constructor Description MGCardInfoEncryptor()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]
encrypt(byte[] key, byte[] identifier, byte[] pan, byte[] expiry, byte[] cvv2)
A utility method to encrypt the contactless card details (PAN, exp 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[]
parseHex(java.lang.String hexString)
A utility method to convert a hexadecimal string to byte array representation
-
-
-
Method Detail
-
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, exp and cvv) using the TSH public key in PKCS#7 format.- Parameters:
key
- key to use for encryption. (usually TSH public key)identifier
- subject key identifier used during encryptionpan
- the Card Primary Account Number.expiry
- the Card expiry date with format "MMYY"cvv2
- the Card CVV (3 or 4 digit)- Returns:
- the encrypted card info
- Throws:
java.lang.RuntimeException
- an exception will be thrown in case of an error
-
parseHex
public static byte[] parseHex(java.lang.String hexString)
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, java.io.IOException
- Throws:
org.bouncycastle.cms.CMSException
java.io.IOException
-
-