Exemplo n.º 1
0
            public IGeneratePinOffsetResponse GeneratePinOffsetFromPinBlock(string encryptedPinBlock, string accountNumber, PinBlockFormats encryptedPinBlockFormat)
            {
                if (string.IsNullOrEmpty(encryptedPinBlock))
                {
                    throw new ArgumentNullException("encryptedPin");
                }
                if (string.IsNullOrEmpty(accountNumber))
                {
                    throw new ArgumentNullException("accountNumber");
                }
                if (accountNumber.Length > 12)
                {
                    throw new ArgumentException("accountNumber is longer than 12-digits");
                }

                //configure Parameters
                var parameters = new List <string>()
                {
                    "001",
                    PinConfigurationManager.HsmConfig.ZPK_LMK,
                    PinConfigurationManager.HsmConfig.PinVerificationKey,
                    encryptedPinBlock,
                    ((int)encryptedPinBlockFormat).ToString().PadLeft(2, '0'),
                    "04",
                    accountNumber.PadLeft(12, '0'),
                    PinConfigurationManager.HsmConfig.DecimalisationTable,
                    PinConfigurationManager.HsmConfig.PinValidationData
                }; //5145851169N5

                //configure Response Format
                var responseFormat = new MessageFields();

                responseFormat.Fields.Add(new MessageField()
                {
                    Name = "offset", Length = 12
                });

                var hsmResponse = _theHsm.Send("BK", parameters, responseFormat);

                IGeneratePinOffsetResponse response = new GeneratePinOffsetResponse();

                response.Offset = hsmResponse.Item("offset");

                return(response);
            }
Exemplo n.º 2
0
            public IPinGenerationResponse TranslatePinFromOneZPKEncryptionToAnother(string SourceZPK, string DestinationZPK, string SourcePinBlock, PinBlockFormats pinBlockFormat, string accountNumber)
            {
                if (string.IsNullOrEmpty(SourceZPK))
                {
                    throw new ArgumentNullException("pinEncryptionKey");
                }
                if (string.IsNullOrEmpty(accountNumber))
                {
                    throw new ArgumentNullException("accountNumber");
                }
                if (string.IsNullOrEmpty(DestinationZPK))
                {
                    throw new ArgumentNullException("zpk is empty");
                }
                if (string.IsNullOrEmpty(SourcePinBlock))
                {
                    throw new ArgumentNullException("Source Pin Block is empty");
                }

                if (accountNumber.Length > 12)
                {
                    throw new ArgumentException("accountNumber is longer than 12-digits");
                }

                //configure Parameters
                var parameters = new List <string>()
                {
                    SourceZPK,
                    DestinationZPK,
                    "12",
                    SourcePinBlock,
                    ((int)pinBlockFormat).ToString().PadLeft(2, '0'),
                    ((int)pinBlockFormat).ToString().PadLeft(2, '0'),
                    accountNumber.PadLeft(12, '0'),
                };

                //configure Response Format
                var responseFormat = new MessageFields();

                responseFormat.Fields.Add(new MessageField()
                {
                    Name = "encryptedPin", Length = 18
                });

                var hsmResponse = _theHsm.Send("CC", parameters, responseFormat);
                IPinGenerationResponse response = new PinGeneratorResponse();

                response.EncryptedPin = hsmResponse.Item("encryptedPin").Substring(0, 16);

                return(response);
            }
Exemplo n.º 3
0
 public IPinTranslationResponse TranslateFromPinEncryptionKeyToAnother(bool isInterchange, string sourcePinEncryptionKey, string destinationPinEncryptionKey, int maxPinLength, string pinBlock, PinBlockFormats sourcePinBlockFormat, PinBlockFormats destinationPinBlockFormat, string accountNumber)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 4
0
            public IPinGenerationResponse TranslatePinFromEncryptionUnderInterchangeKeyToLMKEncryption(string zpk, string EncryptedPin, PinBlockFormats pinBlockFormat, string accountNumber)
            {
                if (string.IsNullOrEmpty(EncryptedPin))
                {
                    throw new ArgumentNullException("pinEncryptionKey");
                }
                if (string.IsNullOrEmpty(accountNumber))
                {
                    throw new ArgumentNullException("accountNumber");
                }
                if (string.IsNullOrEmpty(zpk))
                {
                    throw new ArgumentNullException("zpk is empty");
                }

                if (accountNumber.Length > 12)
                {
                    throw new ArgumentException("accountNumber is longer than 12-digits");
                }

                //configure Parameters
                var parameters = new List <string>()
                {
                    zpk,
                    EncryptedPin,
                    ((int)pinBlockFormat).ToString().PadLeft(2, '0'),
                    accountNumber.PadLeft(12, '0'),
                };

                //configure Response Format
                var responseFormat = new MessageFields();

                responseFormat.Fields.Add(new MessageField()
                {
                    Name = "encryptedPin", Length = _theHsm._encryptedPinLength
                });

                var hsmResponse = _theHsm.Send("JE", parameters, responseFormat);
                IPinGenerationResponse response = new PinGeneratorResponse();

                response.EncryptedPin = hsmResponse.Item("encryptedPin");

                return(response);
            }
Exemplo n.º 5
0
            /// <summary>
            ///
            /// </summary>
            /// <param name="isInterchange"></param>
            /// <param name="pinEncryptionKey">zpk_lmk</param>
            /// <param name="pinVerificationKey">pvk</param>
            /// <param name="encryptedPinBlock">encrypted pin from the hsm</param>
            /// <param name="encryptedPinBlockFormat"></param>
            /// <param name="minPinLength">5</param>
            /// <param name="accountNumber">12 digit right most digit excluding the check digit</param>
            /// <param name="pinValidationData"></param>
            /// <param name="offset"></param>
            public void VerifyPIN(bool isInterchange, string pinEncryptionKey, string pinVerificationKey, string encryptedPinBlock, PinBlockFormats encryptedPinBlockFormat, int minPinLength, string accountNumber, string pinValidationData, string offset)
            {
                if (string.IsNullOrEmpty(pinVerificationKey))
                {
                    throw new ArgumentNullException("pinVerificationKey");
                }
                if (string.IsNullOrEmpty(pinEncryptionKey))
                {
                    throw new ArgumentNullException("pinEncryptionKey");
                }
                if (string.IsNullOrEmpty(encryptedPinBlock))
                {
                    throw new ArgumentNullException("encryptedPinBlock");
                }
                if (string.IsNullOrEmpty(accountNumber))
                {
                    throw new ArgumentNullException("accountNumber");
                }
                if (accountNumber.Length > 12)
                {
                    throw new ArgumentException("accountNumber is longer than 12-digits");
                }
                if (pinValidationData.Length != 12)
                {
                    throw new ArgumentException("pinValidationData is not 12-digits");
                }

                //string decTable = new PinTranslation(new ThalesHsm()).TranslateDecimalizationTableFromOldToNewLMK();

                //configure Parameters
                var parameters = new List <string>()
                {
                    pinEncryptionKey,
                    pinVerificationKey,
                    "12", //(minPinLength+8).ToString().PadLeft(2,'0'),
                    encryptedPinBlock,
                    ((int)encryptedPinBlockFormat).ToString().PadLeft(2, '0'),
                    minPinLength.ToString().PadLeft(2, '0'),
                    accountNumber.PadLeft(12, '0'),
                    // decTable,
                    PinConfigurationManager.HsmConfig.DecimalisationTable,
                    pinValidationData,
                    offset
                };

                //configure Response Format
                var responseFormat = new MessageFields();

                var hsmResponse = _theHsm.Send(isInterchange ? "EA" : "DA", parameters, responseFormat);
            }