]> git.zerfleddert.de Git - proxmark3-svn/blob - client/emv/emvcore.h
03d5c956c232fbaae1ff54e7861320e4c0c643f9
[proxmark3-svn] / client / emv / emvcore.h
1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2017 Merlok
3 //
4 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
5 // at your option, any later version. See the LICENSE.txt file for the text of
6 // the license.
7 //-----------------------------------------------------------------------------
8 // EMV core functionality
9 //-----------------------------------------------------------------------------
10
11 #ifndef EMVCORE_H__
12 #define EMVCORE_H__
13
14 #include <stdio.h>
15 #include <stdint.h>
16 #include <stdlib.h>
17 #include <inttypes.h>
18 #include <string.h>
19 #include "util.h"
20 #include "common.h"
21 #include "ui.h"
22 #include "cmdhf14a.h"
23 #include "emv/apduinfo.h"
24 #include "emv/tlv.h"
25 #include "emv/dol.h"
26 #include "emv/dump.h"
27 #include "emv/emv_tags.h"
28
29 #define APDU_RES_LEN 260
30 #define APDU_AID_LEN 50
31
32 typedef struct {
33 uint8_t CLA;
34 uint8_t INS;
35 uint8_t P1;
36 uint8_t P2;
37 uint8_t Lc;
38 uint8_t *data;
39 } sAPDU;
40
41 enum CardPSVendor {
42 CV_NA,
43 CV_VISA,
44 CV_MASTERCARD,
45 CV_AMERICANEXPRESS,
46 CV_JCB,
47 CV_CB,
48 CV_OTHER,
49 };
50 extern enum CardPSVendor GetCardPSVendor(uint8_t * AID, size_t AIDlen);
51
52 extern void TLVPrintFromBuffer(uint8_t *data, int datalen);
53 extern void TLVPrintFromTLV(struct tlvdb *tlv);
54 extern void TLVPrintFromTLVLev(struct tlvdb *tlv, int level);
55 extern void TLVPrintAIDlistFromSelectTLV(struct tlvdb *tlv);
56
57 extern struct tlvdb *GetPANFromTrack2(const struct tlv *track2);
58 extern struct tlvdb *GetdCVVRawFromTrack2(const struct tlv *track2);
59
60 extern void SetAPDULogging(bool logging);
61
62 // search application
63 extern int EMVSearchPSE(bool ActivateField, bool LeaveFieldON, bool decodeTLV, struct tlvdb *tlv);
64 extern int EMVSearch(bool ActivateField, bool LeaveFieldON, bool decodeTLV, struct tlvdb *tlv);
65 extern int EMVSelectPSE(bool ActivateField, bool LeaveFieldON, uint8_t PSENum, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw);
66 extern int EMVSelect(bool ActivateField, bool LeaveFieldON, uint8_t *AID, size_t AIDLen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv);
67 // select application
68 extern int EMVSelectApplication(struct tlvdb *tlv, uint8_t *AID, size_t *AIDlen);
69 // Get Processing Options
70 extern int EMVGPO(bool LeaveFieldON, uint8_t *PDOL, size_t PDOLLen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv);
71 extern int EMVReadRecord(bool LeaveFieldON, uint8_t SFI, uint8_t SFIrec, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv);
72 // Mastercard
73 int MSCComputeCryptoChecksum(bool LeaveFieldON, uint8_t *UDOL, uint8_t UDOLlen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv);
74
75 #endif
76
77
78
79
Impressum, Datenschutz