]> cvs.zerfleddert.de Git - proxmark3-svn/blob - client/emv/emvcore.h
fixing the fix: older shells don't know about &>
[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 enum TransactionType {
33 TT_MSD,
34 TT_VSDC, // not standart for contactless!!!!
35 TT_QVSDCMCHIP,
36 TT_CDA,
37 };
38
39 typedef struct {
40 uint8_t CLA;
41 uint8_t INS;
42 uint8_t P1;
43 uint8_t P2;
44 uint8_t Lc;
45 uint8_t *data;
46 } sAPDU;
47
48 enum CardPSVendor {
49 CV_NA,
50 CV_VISA,
51 CV_MASTERCARD,
52 CV_AMERICANEXPRESS,
53 CV_JCB,
54 CV_CB,
55 CV_OTHER,
56 };
57 extern enum CardPSVendor GetCardPSVendor(uint8_t * AID, size_t AIDlen);
58
59 extern void TLVPrintFromBuffer(uint8_t *data, int datalen);
60 extern void TLVPrintFromTLV(struct tlvdb *tlv);
61 extern void TLVPrintFromTLVLev(struct tlvdb *tlv, int level);
62 extern void TLVPrintAIDlistFromSelectTLV(struct tlvdb *tlv);
63
64 extern struct tlvdb *GetPANFromTrack2(const struct tlv *track2);
65 extern struct tlvdb *GetdCVVRawFromTrack2(const struct tlv *track2);
66
67 extern void SetAPDULogging(bool logging);
68
69 // search application
70 extern int EMVSearchPSE(bool ActivateField, bool LeaveFieldON, bool decodeTLV, struct tlvdb *tlv);
71 extern int EMVSearch(bool ActivateField, bool LeaveFieldON, bool decodeTLV, struct tlvdb *tlv);
72 extern int EMVSelectPSE(bool ActivateField, bool LeaveFieldON, uint8_t PSENum, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw);
73 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);
74 // select application
75 extern int EMVSelectApplication(struct tlvdb *tlv, uint8_t *AID, size_t *AIDlen);
76 // Get Processing Options
77 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);
78 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);
79 // AC
80 extern int EMVGenerateChallenge(bool LeaveFieldON, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv);
81 extern int EMVAC(bool LeaveFieldON, uint8_t RefControl, uint8_t *CDOL, size_t CDOLLen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv);
82 // Mastercard
83 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);
84 // Auth
85 extern int trSDA(uint8_t *AID, size_t AIDlen, struct tlvdb *tlv);
86
87 #endif
88
89
90
91
Impressum, Datenschutz