SelectAppChosen(CardQProcessor cardInterfaceManager, TerminalSupportedKernelAidTransactionTypeCombination supportedKernelAidCombination, CardKernelAidCombination candidate) { string finalAdfName = Formatting.ByteArrayToHexString(candidate.AdfNameTag.Value); ApduResponse cardResponse = cardInterfaceManager.SendCommand(new EMVSelectApplicationRequest(finalAdfName)) as EMVSelectApplicationResponse; EMVSelectApplicationResponse response; if (cardResponse is EMVSelectApplicationResponse) { response = (EMVSelectApplicationResponse)cardResponse; } else { throw new EMVProtocolException("Pre-processing transmit error: try again"); } if (!response.Succeeded) { return(Tuple.Create( new EMVTerminalProcessingOutcome() { NextProcessState = EMVTerminalPreProcessingStateEnum.CombinationSelection_StartC }, response, supportedKernelAidCombination)); } //TLV ttqInPDOL = response.GetPDOLTags().Get(EMVTagsEnum.TERMINAL_TRANSACTION_QUALIFIERS_TTQ_9F66_KRN.Tag); return(Tuple.Create( new EMVTerminalProcessingOutcome() { NextProcessState = EMVTerminalPreProcessingStateEnum.KernelActivation_StartD }, response, supportedKernelAidCombination)); }
public override string ToString() { bool asXML = false; StringBuilder sb = new StringBuilder(); sb.AppendLine(string.Format("{0}:{1}", "DGI:" + Formatting.ByteArrayToHexString(DGI), DGIMeta.Description)); int depth = 0; if (Data != null) { if (asXML) { sb.Append(TLVListXML.XmlSerialize(Data)); } else { sb.Append(Data.ToPrintString(ref depth)); } } else { sb.Append(string.Format("{0,-30}:{1}", "DGIBytes", Formatting.ByteArrayToHexString(DataBytes))); } return(sb.ToString()); }
private bool CheckIfCertInCertRevocationList(CAPublicKeyCertificate capk) { int found = RevokedCAPublicKeyCertificates.Count(x => { DateTime dt = DateTime.ParseExact(Formatting.BcdToString(x.ExpiryDate), "MMyy", System.Globalization.CultureInfo.InvariantCulture); if (x.RID == capk.RID && x.Index == capk.Index && dt < DateTime.Now) { return(true); } else { return(false); } }); if (found > 0) { Logger.Log("Certificate is revoked, index:" + Formatting.ByteArrayToHexString(new byte[] { capk.Index })); return(true); } else { return(false); } }
internal bool ValidateHash() { byte[] concatenated = Formatting.ConcatArrays( new byte[] { CertificateFormat }, IssuerIdentifier, ExpiryDate, CertificateSerialNumber, new byte[] { HashAlgorithmIndicator }, new byte[] { PublicKeyAlgorithmIndicator }, new byte[] { IssuerPublicKeyLength }, new byte[] { IssuerPublicKeyExponentLength }, IssuerPublicKeyorLeftmostDigitsofIssuerPublicKey, IssuerPublicKeyRemainder, Exponent ); byte[] hash = SHA1.Create().ComputeHash(concatenated); if (Formatting.ByteArrayToHexString(HashResult) != Formatting.ByteArrayToHexString(hash)) { return(false); } return(true); }
public List <string> GetADFNames() { try { if (GetTLVResponse().Tag.TagLable != EMVTagsEnum.FILE_CONTROL_INFORMATION_FCI_TEMPLATE_6F_KRN.Tag) { throw new EMVProtocolException("No FILE_CONTROL_INFO_TEMPLATE_6F tag found"); } TLV y = GetTLVResponse().Children.Get(EMVTagsEnum.FILE_CONTROL_INFORMATION_FCI_ISSUER_DISCRETIONARY_DATA_BF0C_KRN.Tag); TLV z = y.Children.Get(EMVTagsEnum.FILE_CONTROL_INFORMATION_FCI_ISSUER_DISCRETIONARY_DATA_BF0C_KRN.Tag); TLVList a = z.Children.FindAll(EMVTagsEnum.APPLICATION_TEMPLATE_61_KRN.Tag); List <string> result = new List <string>(); foreach (TLV tlv in a) { result.Add(Formatting.ByteArrayToHexString(tlv.Children.Get(EMVTagsEnum.APPLICATION_DEDICATED_FILE_ADF_NAME_4F_KRN.Tag).Value)); } return(result); } catch (Exception ex) { throw new EMVProtocolException("APPLICATION_IDENTIFIER_CARD_4F Tag not found:" + ex.Message); } }
public override string ToPrintString(ref int depth) { StringBuilder sb = new StringBuilder(); string tagName = TLVMetaDataSourceSingleton.Instance.DataSource.GetName(Tag.TagLable); string formatter = "{0,-75}"; sb.AppendLine(string.Format(formatter, Tag.ToString() + " " + tagName + " L:[" + Val.GetLength().ToString() + "]")); sb.AppendLine("V:["); sb.AppendLine("\tStatus->" + Value.Status); sb.AppendLine("\tStart->" + Value.Start); sb.AppendLine("\tOnlineResponseData->" + Value.OnlineResponseData); sb.AppendLine("\tCVM->" + Value.CVM); sb.AppendLine("\tUIRequestOnOutcomePresent->" + Value.UIRequestOnOutcomePresent); sb.AppendLine("\tUIRequestOnRestartPresent->" + Value.UIRequestOnRestartPresent); sb.AppendLine("\tDataRecordPresent->" + Value.DataRecordPresent); sb.AppendLine("\tDiscretionaryDataPresent->" + Value.DiscretionaryDataPresent); sb.AppendLine("\tReceipt->" + Value.Receipt); sb.AppendLine("\tAlternateInterfacePreference->" + Value.AlternateInterfacePreference); sb.AppendLine("\tFieldOffRequest->" + Formatting.ByteArrayToHexString(new byte[] { Value.FieldOffRequest })); sb.AppendLine("\tRemovalTimeout->" + Formatting.ByteArrayToHexString(new byte[] { Value.RemovalTimeout })); sb.AppendLine("]"); return(sb.ToString()); }
public virtual string ToPrintString() { int depth = 0; string header = "Start ADPU Response:" + this.GetType().Name; string status = "Status: " + SWTranslation; string body; if (GetTLVResponse() == null) { if (ResponseData == null || ResponseData.Length == 0) { body = "[No tags - No Data]"; } else { body = "[No tags - Raw Data:" + Formatting.ByteArrayToHexString(ResponseData) + "]"; } } else { body = GetTLVResponse().ToPrintString(ref depth); } string footer = "End ADPU Response:" + this.GetType().Name; StringBuilder sb = new StringBuilder(); sb.AppendLine(header).AppendLine(status).AppendLine(body).Append(footer); return(sb.ToString()); }
CreateCandidateListFromPSERecords(TLVList directoryEntries) { List <Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> > candidateList = new List <Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> >(); foreach (TLV tlv in directoryEntries) { TLV adfNameTag = tlv.Children.Get(EMVTagsEnum.APPLICATION_DEDICATED_FILE_ADF_NAME_4F_KRN.Tag); TLV applicationPriorityIndicatorTag = tlv.Children.Get(EMVTagsEnum.APPLICATION_PRIORITY_INDICATOR_87_KRN.Tag); Optional <TLV> extendedSelectionTag = Optional <TLV> .Create(tlv.Children.Get(EMVTagsEnum.EXTENDED_SELECTION_9F29_KRN.Tag)); TLV preferedName = tlv.Children.Get(EMVTagsEnum.APPLICATION_PREFERRED_NAME_9F12_KRN.Tag); TLV appLabel = tlv.Children.Get(EMVTagsEnum.APPLICATION_LABEL_50_KRN.Tag); if (adfNameTag == null) { break; } if (adfNameTag.Value.Length < 5 || adfNameTag.Value.Length > 16) { break; } foreach (TerminalSupportedKernelAidTransactionTypeCombination kc in TerminalSupportedKernelAidTransactionTypeCombinations.SupportedContactCombinations) { string terminalAID = Enum.GetName(typeof(AIDEnum), ((TerminalSupportedContactKernelAidTransactionTypeCombination)kc).AIDEnum); string cardAid = Formatting.ByteArrayToHexString(adfNameTag.Value); if (terminalAID != cardAid && !cardAid.StartsWith(terminalAID)) { continue; } if (terminalAID == cardAid) { //full match } if (cardAid.StartsWith(terminalAID)) { //matching aid, partial match, check if partial match allowed if (!((TerminalSupportedContactKernelAidTransactionTypeCombination)kc).ApplicationSelectionIndicator) { continue; } } candidateList.Add(Tuple.Create(kc, new CardKernelAidCombination() { AdfNameTag = adfNameTag, ApplicationPriorityIndicatorTag = applicationPriorityIndicatorTag, ApplicationPreferredName = preferedName, ApplicationLabel = appLabel, ExtendedSelectionTag = extendedSelectionTag, })); } } return(candidateList); }
public virtual void Deserialize(byte[] input) { int pos = 0; DGI = new byte[2]; Array.Copy(input, pos, DGI, 0, 2); pos = pos + 2; DGILength = input[pos]; pos++; DataBytes = new byte[DGILength]; Array.Copy(input, pos, DataBytes, 0, DGILength); pos = pos + DGILength; DGIMeta = DGITagsList.GetMeta(Formatting.ByteArrayToHexString(DGI), DataBytes[0]); if (DGIMeta.IsTLVFormatted) { Data = new TLVList(); Data.Deserialize(DataBytes); } if (pos != input.Length) { MAC = new byte[8]; Array.Copy(input, pos, MAC, 0, 8); pos = pos + 8; } }
public string ConvertToString(byte[] data) { switch (Format) { //case DataFormats.UNKNOWN: //case DataFormats.VARIABLE_UNKNOWN: case DataFormats._BINARY: case DataFormats._BINARY_16: //case DataFormats._BINARY_MULTIPLE_OF_4: //case DataFormats.H: //case DataFormats.A: return(Formatting.ByteArrayToHexString(data)); case DataFormats._CN: case DataFormats._DATE_YYMMDD: case DataFormats._TIME_HHMMSS: case DataFormats._NUMERIC: return(Formatting.BcdToString(data)); case DataFormats._ALPHA: case DataFormats._ALPHA_NUMERIC: case DataFormats._ALPHA_NUMERIC_SPECIAL: case DataFormats._ALPHA_NUMERIC_SPACE: return(Formatting.ByteArrayToASCIIString(data)); default: throw new Exception("Unknown DataFormat:" + Format); } }
public byte[] WriteData(byte[] sessionKey, byte fileNo, byte dataIn) { //byte fileNo = 0x01; byte[] offset = new byte[] { 0x00, 0x00, 0x00 }; //offset of 0 byte[] length = new byte[] { 0x00, 0x00, 0x01 }; //length of 1 byte[] dataToWrite = new byte[] { dataIn }; byte[] dataForCRC32Header = new byte[] { (byte)DesfireCommand.CommandType.WriteData, fileNo, offset[2], offset[1], offset[0], length[2], length[1], length[0] }; byte[] dataForCRC32 = new byte[dataForCRC32Header.Length + dataToWrite.Length]; Array.Copy(dataForCRC32Header, dataForCRC32, dataForCRC32Header.Length); Array.Copy(dataToWrite, 0, dataForCRC32, dataForCRC32Header.Length, dataToWrite.Length); uint crc32 = Crc32.Compute(dataForCRC32); string dataPlusCRC = Formatting.ByteArrayToHexString(dataToWrite) + Formatting.ByteArrayToHexString(BitConverter.GetBytes(crc32)); byte[] dataPlusCRCPadded = Formatting.HexStringToByteArray(dataPlusCRC); Formatting.PadToMultipleOf(ref dataPlusCRCPadded, 16); string initialIV = "00000000000000000000000000000000"; byte[] dataPlusCRCResultPaddedEncrypted = AESCrypto.AESEncrypt( sessionKey, Formatting.HexStringToByteArray(initialIV), dataPlusCRCPadded); byte[] extractIV = new byte[16]; Array.Copy(dataPlusCRCResultPaddedEncrypted, dataPlusCRCResultPaddedEncrypted.Length - 16, extractIV, 0, 16); byte[] cmdToSendHeader = new byte[] { fileNo, offset[2], offset[1], offset[0], length[2], length[1], length[0] }; byte[] cmdToSend = new byte[cmdToSendHeader.Length + dataPlusCRCResultPaddedEncrypted.Length]; Array.Copy(cmdToSendHeader, cmdToSend, cmdToSendHeader.Length); Array.Copy(dataPlusCRCResultPaddedEncrypted, 0, cmdToSend, cmdToSendHeader.Length, dataPlusCRCResultPaddedEncrypted.Length); DesfireCommand desfireCommand = new DesfireCommand() { Command = (byte)DesfireCommand.CommandType.WriteData, Data = cmdToSend }; DesfireResponse desfireResFile = SendCommand(desfireCommand) as DesfireResponse; if (!desfireResFile.Succeeded) { throw new DesFireException("Error:" + desfireResFile.SW); } byte[] cmac = AESCMAC.CMAC( sessionKey, extractIV, new byte[] { desfireResFile.SW2 }); byte[] updatedIV = cmac; byte[] data = ReadData(sessionKey, updatedIV, fileNo); if (data[0] != dataToWrite[0]) { throw new DesFireException("Data read not the same as data written"); } return(data); }
public static byte[] VerifySSAD(ICCDynamicDataType iccDDType, KernelDatabaseBase database, CAPublicKeyCertificate caPublicKey, byte[] sdadRaw) { //section 5.4 of EMV book 2 - SDA //1.If the Signed Static Application Data has a length different from the //length of the ICC Public Key Modulus, SDA has failed IssuerPublicKeyCertificate ipk = IssuerPublicKeyCertificate.BuildAndValidatePublicKey(database, caPublicKey.Modulus, caPublicKey.Exponent); if (ipk == null) { return(null); } if (sdadRaw.Length != ipk.Modulus.Length) { return(null); } //2.In order to obtain the Recovered Data specified in Table 7, apply the //recovery function specified in Annex A2.1 on the Signed Static Application //Data using the Issuer Public Key in conjunction with the corresponding //algorithm.If the Recovered Data Trailer is not equal to 'BC', SDA has //failed. byte[] decrypted = PublicKeyCertificate.DecryptRSA(sdadRaw, ipk.Modulus, ipk.Exponent); SSAD ssad = new SSAD(decrypted); //3.Check the Recovered Data Header. If it is not '6A', SDA has failed. if (ssad.DataHeader != 0x6A) { return(null); } //4.Check the Signed Data Format. If it is not '03', SDA has failed. //For Visa specialpurpose readers it may return 0x93 if offline data authentication is supported for online transactions (in the TTQ) if (ssad.SignedDataFormat != 0x03 && ssad.SignedDataFormat != 0x05 && ssad.SignedDataFormat != 0x95) { return(null); } //5.Concatenate from left to right the second to the fifth data elements in //Table 7(that is, Signed Data Format through Pad Pattern), followed by //the static data to be authenticated as specified in section 10.3 of Book 3.If //the Static Data Authentication Tag List is present and contains tags other //than '82', then SDA has failed byte[] dataForHash = ssad.Concat(database.StaticDataToBeAuthenticated.BuildStaticDataToBeAuthenticated()); //6.Apply the indicated hash algorithm(derived from the Hash Algorithm //Indicator) to the result of the concatenation of the previous step to //produce the hash result. byte[] hash = SHA1.Create().ComputeHash(dataForHash); //7.Compare the calculated hash result from the previous step with the //recovered Hash Result.If they are not the same, SDA has failed. if (Formatting.ByteArrayToHexString(ssad.HashResult) != Formatting.ByteArrayToHexString(hash)) { return(null); } return(ssad.DataAuthenticationCode); }
public AID(byte[] bytes, int offset, int length) { if ((length < 5) || (length > 16)) { throw new Exception("AID's are between 5 and 16 bytes, not " + Formatting.ByteArrayToHexString(BitConverter.GetBytes(length))); } aidBytes = new byte[length]; Array.Copy(bytes, offset, aidBytes, 0, length); }
public override string ToPrintString() { string header = "Start ADPU Request: " + this.GetType().Name; string body = "P1: " + Formatting.ByteArrayToHexString(new byte[] { P1 }) + " P2: " + Formatting.ByteArrayToHexString(new byte[] { P2 }); string footer = "End ADPU Request: " + this.GetType().Name; StringBuilder sb = new StringBuilder(); sb.AppendLine(header).AppendLine(body).Append(footer); return(sb.ToString()); }
public override string ToPrintString() { string header = "Start ADPU Request: " + this.GetType().Name; string body = "Filename: " + fileName + "[" + Formatting.ByteArrayToHexString(CommandData) + "]"; string footer = "End ADPU Request: " + this.GetType().Name; StringBuilder sb = new StringBuilder(); sb.AppendLine(header).AppendLine(body).Append(footer); return(sb.ToString()); }
public virtual string ToPrintString() { string header = "Start ADPU Request: " + this.GetType().Name; string body = CommandData == null ? "No Data" : Formatting.ByteArrayToHexString(CommandData); string footer = "End ADPU Request: " + this.GetType().Name; StringBuilder sb = new StringBuilder(); sb.AppendLine(header).AppendLine(body).Append(footer); return(sb.ToString()); }
public override String ToString() { String s = "Card CPLC:"; foreach (KeyValuePair <Field, byte[]> f in values) { s += "\n" + f.Key + ": " + Formatting.ByteArrayToHexString(f.Value); } return(s); }
private static char[] FormatPINBlock(String pin, int checkDigit) { char[] block = Formatting.ByteArrayToHexString(fPaddingBlock).ToCharArray(); char[] pinLenHex = String.Format("{0:X2}", pin.Length).ToCharArray(); pinLenHex[0] = (char)('0' + checkDigit); // pin length then pad with 'F' Array.Copy(pinLenHex, 0, block, 0, pinLenHex.Length); Array.Copy(pin.ToCharArray(), 0, block, pinLenHex.Length, pin.Length); return(block); }
public virtual string ToPrintString() { string header = "+--- Start ADPU Request: " + this.GetType().Name; header = string.Format("{0} [Cla:{1:X2} Ins:{2:X2} P1:{3:X2} P2:{4:X2} Le:{5:X2}]", header, CLA, INS, P1, P2, Le); string body = "| Command Data: " + Formatting.ByteArrayToHexString(CommandData); string footer = "+--- End ADPU Request: " + this.GetType().Name; StringBuilder sb = new StringBuilder(); sb.AppendLine(header).AppendLine(body).AppendLine(footer); return(sb.ToString()); }
public virtual void Deserialize(byte[] input) { int pos = 0; LengthofExecutableLoadFileAID = input[pos]; pos++; byte[] loadFileAIDBytes = new byte[LengthofExecutableLoadFileAID]; Array.Copy(input, pos, loadFileAIDBytes, 0, LengthofExecutableLoadFileAID); ExecutableLoadFileAID = Formatting.ByteArrayToHexString(loadFileAIDBytes); pos = pos + LengthofExecutableLoadFileAID; LengthofExecutableModuleAID = input[pos]; pos++; byte[] securityDomainAIDBytes = new byte[LengthofExecutableModuleAID]; Array.Copy(input, pos, securityDomainAIDBytes, 0, LengthofExecutableModuleAID); ExecutableModuleAID = Formatting.ByteArrayToHexString(securityDomainAIDBytes); pos = pos + LengthofExecutableModuleAID; LengthofApplicationAID = input[pos]; pos++; byte[] applicationAIDBytes = new byte[LengthofApplicationAID]; Array.Copy(input, pos, applicationAIDBytes, 0, LengthofApplicationAID); ApplicationAID = Formatting.ByteArrayToHexString(applicationAIDBytes); pos = pos + LengthofApplicationAID; LengthofPrivileges = input[pos]; pos++; Privileges = new byte[LengthofPrivileges]; Array.Copy(input, pos, Privileges, 0, LengthofPrivileges); pos = pos + LengthofPrivileges; LengthofInstallParametersfield = (int)DeterminaLengthLength(input, ref pos); InstallParametersfield = new byte[LengthofInstallParametersfield]; Array.Copy(input, pos, InstallParametersfield, 0, LengthofInstallParametersfield); pos = pos + LengthofInstallParametersfield; if (LengthofInstallParametersfield > 2) { InstallParamC9 = new INSTALL_PARAM_C9_GP(); InstallParamC9.Deserialize(InstallParametersfield, 0); } LengthofInstallToken = (int)DeterminaLengthLength(input, ref pos); InstallToken = new byte[LengthofInstallToken]; Array.Copy(input, pos, InstallToken, 0, LengthofInstallToken); pos = pos + LengthofInstallToken; }
private async Task <ApduResponse> Transceive(ApduCommand apduCommand) { ApduResponse apduRes = Activator.CreateInstance(apduCommand.ApduResponseType) as ApduResponse; byte[] dataIn = apduCommand.Serialize(); bool debugOut = true; if (debugOut) { StringBuilder sb = new StringBuilder(); sb.AppendLine("********************************************************************************************************"); sb.AppendLine(apduCommand.ToString()); sb.Append("Raw Data Sent:" + Formatting.ByteArrayToHexString(dataIn)); Logger.Log(sb.ToString()); } byte[] dataOut = await CardInterfaceManger.TransmitAsync(dataIn); if (debugOut) { StringBuilder sb = new StringBuilder(); sb.AppendLine("Raw Data Received:" + Formatting.ByteArrayToHexString(dataOut)); sb.AppendLine("********************************************************************************************************"); Logger.Log(sb.ToString()); } apduRes.Deserialize(dataOut); if (apduRes.SW1 == 0x61) { GetResponseRequest getResponseRequest = new GetResponseRequest(apduRes.SW2); ApduResponse getResponseResponse = await Transceive(getResponseRequest); if (getResponseResponse.Succeeded || (getResponseResponse.SW1 == 0x62 && getResponseResponse.SW2 == 0x83)) { apduRes.ResponseData = Formatting.ConcatArrays(apduRes.ResponseData, getResponseResponse.ResponseData, new byte[] { 0x90, 0x00 }); apduRes.Deserialize(apduRes.ResponseData); } else { throw new Exception("GetResponse failed"); } } if (apduRes.SW1 == 0x6C) { //repeat command with correct Le apduCommand.Le = apduRes.SW2; apduRes = await Transceive(apduCommand); } return(apduRes); }
public SimpleMsg(String tagName, String msgName, Object msgContent) { this.tagName = tagName; this.msgName = msgName; if (msgContent is byte[]) { this.msgContent = Formatting.ByteArrayToHexString((byte[])msgContent); } else { this.msgContent = msgContent; } }
private static void Transmit(TCPClientStream stream, byte[] txBytes) { short length = (short)(txBytes.Length); byte[] lengthBytes = new byte[] { (byte)(length / 256), (byte)(length % 256) }; byte[] txBytesTCP = Formatting.ConcatArrays(lengthBytes, txBytes); Logger.Log("Sending: [" + Formatting.ConvertToInt16(lengthBytes) + "]" + "[" + Formatting.ByteArrayToHexString(txBytes) + "]"); stream.Write(txBytesTCP); }
private static byte[] Receive(TCPClientStream stream) { byte chrSTX = 0x02; // Start of Text byte chrETX = 0x03; // End of Text byte[] rxBuffer = new Byte[4096]; int countBytesRead = stream.Read(rxBuffer); byte[] lengthBytesReceived = new byte[2]; Array.Copy(rxBuffer, 0, lengthBytesReceived, 0, lengthBytesReceived.Length); int bytesInRxPacket = Formatting.ConvertToInt16(lengthBytesReceived); if (bytesInRxPacket + 2 != countBytesRead) { throw new TCPIPManagerException("Did not receive all expected bytes"); } byte[] result = new byte[bytesInRxPacket]; Array.Copy(rxBuffer, 2, result, 0, result.Length); bool hasSTX = false; bool hasETX = false; if (result.First() == chrSTX) { byte[] strippedSTX = new byte[result.Length - 1]; Array.Copy(result, 1, strippedSTX, 0, strippedSTX.Length); result = strippedSTX; hasSTX = true; } int lastPos = Array.FindIndex(result, 0, (x) => x == chrETX); if (lastPos != -1) { int lengthToCopy = result.Length - (result.Length - lastPos); byte[] strippedETX = new byte[lengthToCopy]; Array.Copy(result, 0, strippedETX, 0, strippedETX.Length); result = strippedETX; hasETX = true; } Logger.Log("Received:[" + countBytesRead + "]" + (hasSTX == true? "[" + Formatting.ByteArrayToHexString(new byte[] { chrSTX }) + "]": "[No STX]") + "[" + Formatting.ByteArrayToASCIIString(result) + "]" + (hasETX == true ? "[" + Formatting.ByteArrayToHexString(new byte[] { chrETX }) + "]": "[No ETX]")); return(result); }
public string GetDFName() { try { if (GetTLVResponse().Tag.TagLable != EMVTagsEnum.FILE_CONTROL_INFORMATION_FCI_TEMPLATE_6F_KRN.Tag) { throw new EMVProtocolException("No FILE_CONTROL_INFO_TEMPLATE_6F tag found"); } var y = GetTLVResponse().Children.Get(EMVTagsEnum.DEDICATED_FILE_DF_NAME_84_KRN.Tag); return(Formatting.ByteArrayToHexString(y.Value)); } catch (Exception ex) { throw new EMVProtocolException("DEDICATED_FILE_NAME_84 Tag not found:" + ex.Message); } }
private static Optional <Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> > AskCardHolderToSelect(List <Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> > candidateList, IUICallbackProvider uiProvider) { List <String> candidatesStrings = candidateList.Select(x => Formatting.ByteArrayToASCIIString(x.Item2.ApplicationLabel.Value) + ":" + Formatting.ByteArrayToHexString(x.Item2.AdfNameTag.Value)).ToList(); String selected = uiProvider.DisplayApplicationList(candidatesStrings); if (!string.IsNullOrEmpty(selected)) { Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> selectedTuple = candidateList.Where(x => Formatting.ByteArrayToHexString(x.Item2.AdfNameTag.Value) == selected).First(); return(Optional <Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> > .Create(selectedTuple)); } else { return(Optional <Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> > .CreateEmpty()); } }
public override int Deserialize(byte[] rawTlv, int pos) { pos = base.Deserialize(rawTlv, pos); string input = Formatting.ByteArrayToHexString(Value); //input = input.Replace("F", ""); string[] inputs = input.Split('D'); PAN = inputs[0]; ExpirationDate = inputs[1].Substring(0, 4); ServiceCode = inputs[1].Substring(4, 3); DiscretionaryData = Formatting.StringToBcd(inputs[1].Substring(7, inputs[1].Length - 7), false); return(pos); }
private static void Transmit(TCPClientStream stream, byte[] txBytes) { byte chrSTX = 0x02; // Start of Text byte chrETX = 0x03; // End of Text //byte[] LRC; short length = (short)(txBytes.Length + 2); byte[] lengthBytes = new byte[] { (byte)(length / 256), (byte)(length % 256) }; byte[] txBytesTCP = Formatting.ConcatArrays(lengthBytes, new byte[] { chrSTX }, txBytes, new byte[] { chrETX }); Logger.Log("Sending: [" + Formatting.ConvertToInt16(lengthBytes) + "]" + "[" + Formatting.ByteArrayToHexString(new byte[] { chrSTX }) + "]" + "[" + Formatting.ByteArrayToASCIIString(txBytes) + "]" + "[" + Formatting.ByteArrayToHexString(new byte[] { chrETX }) + "]"); stream.Write(txBytesTCP); }
public override string ToPrintString(ref int depth) { StringBuilder sb = new StringBuilder(); string tagName = TLVMetaDataSourceSingleton.Instance.DataSource.GetName(Tag.TagLable); string formatter = "{0,-75}"; sb.AppendLine(string.Format(formatter, Tag.ToString() + " " + tagName + " L:[" + Val.GetLength().ToString() + "]")); sb.AppendLine("V:["); sb.AppendLine("\tKernel1MessageidentifierEnum->" + Value.KernelMessageidentifierEnum); sb.AppendLine("\tKernel1StatusEnum->" + Value.KernelStatusEnum); sb.AppendLine("\tHoldTime->" + Formatting.ByteArrayToHexString(Value.HoldTime)); sb.AppendLine("\tValueQualifierEnum->" + Value.ValueQualifierEnum); sb.AppendLine("\tLanguagePreference->" + Formatting.ByteArrayToHexString(Value.LanguagePreference)); sb.AppendLine("\tValueQualifier->" + Formatting.ByteArrayToHexString(Value.ValueQualifier)); sb.AppendLine("\tCurrencyCode->" + Formatting.ByteArrayToHexString(Value.CurrencyCode)); sb.AppendLine("]"); return(sb.ToString()); }
public override string ToString() { StringBuilder sb = new StringBuilder(); sb.AppendLine(string.Format("{0,-30}:{1}", "ExecutableLoadFileAID", ExecutableLoadFileAID)); sb.AppendLine(string.Format("{0,-30}:{1}", "ExecutableModuleAID", ExecutableModuleAID)); sb.AppendLine(string.Format("{0,-30}:{1}", "ApplicationAID", ApplicationAID)); sb.AppendLine(string.Format("{0,-30}:{1}", "Privileges", Formatting.ByteArrayToHexString(Privileges))); if (InstallParamC9 != null) { sb.AppendLine(InstallParamC9.ToString()); } else { sb.AppendLine(string.Format("{0,-30}:{1}", "InstallParamC9", "Empty")); } sb.Append(string.Format("{0,-30}:{1}", "InstallToken", Formatting.ByteArrayToHexString(InstallToken))); return(sb.ToString()); }