Ejemplo n.º 1
0
        void ComputeIccContext()
        {
            var issuerModulusLength = new BigInteger(issuerPrivateKey.Modulus, 16).BitLength / 8;
            var iccPublicKey        = certificateData.IccPrivateKey.GetPublicKey();
            var iccModulusLength    = new BigInteger(iccPublicKey.Modulus, 16).BitLength / 8;

            var iccPublicKeyCertificate = new IccPublicKeyCertificate
            {
                HashAlgorithmIndicator      = certificateData.HashAlgorithmIndicator.FromHexa().First(),
                ApplicationPan              = certificateData.ApplicationPan.FromHexa(),
                CertificateExpirationDate   = certificateData.ExpirationDate.FromHexa(),
                CertificateSerialNumber     = certificateData.SerialNumber.FromHexa(),
                PublicKeyAlgorithmIndicator = certificateData.PublicKeyAlgorithmIndicator.FromHexa().First(),
                IccPublicKey = iccPublicKey
            };

            IccContext = new EmvIccContext()
            {
                ApplicationPan = certificateData.ApplicationPan,
                IccPrivateKey  = certificateData.IccPrivateKey
            };

            // 9F46 ICC Public Key Certificate (Nca)
            IccContext.IccPublicKeyCertificate = iccPublicKeyCertificate.GenerateCertificate(issuerPrivateKey.GetPrivateKey()).ToHexa();

            // 9F48 ICC Public Key Remainder (Ni-Nca+42)
            if (iccModulusLength > issuerModulusLength - 42)
            {
                IccContext.IccPublicKeyRemainder = iccPublicKey.Modulus.FromHexa().Skip(issuerModulusLength - 42).ToArray().ToHexa();
            }

            // 9F47 ICC Public Key Exponent (1 or 3)
            IccContext.IccPrivateKey.PublicExponent = iccPublicKey.Exponent.FromHexa().ToHexa();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance.
 /// </summary>
 /// <param name="model">Card DGI model.</param>
 /// <param name="data">Card data.</param>
 /// <param name="issuerContext"></param>
 /// <param name="iccContext"></param>
 public DgiBuilder(EmvPersonalizationModel model, EmvPersonalizationData data, EmvIssuerContext issuerContext, EmvIccContext iccContext)
 {
     this.data          = data;
     this.model         = model;
     this.issuerContext = issuerContext;
     this.iccContext    = iccContext;
 }