Class MGCardInfoEncryptor

java.lang.Object
com.gemalto.mfs.mwsdk.mobilegateway.utils.MGCardInfoEncryptor

public class MGCardInfoEncryptor extends Object
A utility class to encrypt the contactless card information using the public key embedded in MG SDK.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    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, 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[]
    parseHex(String hexString)
    A utility method to convert a hexadecimal string to byte array representation.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public static byte[] parseHex(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, IOException
      Throws:
      org.bouncycastle.cms.CMSException
      IOException