]> git.zerfleddert.de Git - proxmark3-svn/blame_incremental - client/emv/emvcore.h
Revert "dbg: Watchdog resets while 'hw tune lf'"
[proxmark3-svn] / client / emv / emvcore.h
... / ...
CommitLineData
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 "apduinfo.h"
24#include "tlv.h"
25#include "dol.h"
26#include "dump.h"
27#include "emv_tags.h"
28#include "emv_pk.h"
29#include "emv_pki.h"
30
31#define APDU_RES_LEN 260
32#define APDU_AID_LEN 50
33
34enum TransactionType {
35 TT_MSD,
36 TT_VSDC, // not standart for contactless!!!!
37 TT_QVSDCMCHIP,
38 TT_CDA,
39};
40
41typedef struct {
42 uint8_t CLA;
43 uint8_t INS;
44 uint8_t P1;
45 uint8_t P2;
46 uint8_t Lc;
47 uint8_t *data;
48} sAPDU;
49
50enum CardPSVendor {
51 CV_NA,
52 CV_VISA,
53 CV_MASTERCARD,
54 CV_AMERICANEXPRESS,
55 CV_JCB,
56 CV_CB,
57 CV_OTHER,
58};
59extern enum CardPSVendor GetCardPSVendor(uint8_t * AID, size_t AIDlen);
60
61extern void TLVPrintFromBuffer(uint8_t *data, int datalen);
62extern void TLVPrintFromTLV(struct tlvdb *tlv);
63extern void TLVPrintFromTLVLev(struct tlvdb *tlv, int level);
64extern void TLVPrintAIDlistFromSelectTLV(struct tlvdb *tlv);
65
66extern struct tlvdb *GetPANFromTrack2(const struct tlv *track2);
67extern struct tlvdb *GetdCVVRawFromTrack2(const struct tlv *track2);
68
69extern void SetAPDULogging(bool logging);
70
71// search application
72extern int EMVSearchPSE(bool ActivateField, bool LeaveFieldON, bool decodeTLV, struct tlvdb *tlv);
73extern int EMVSearch(bool ActivateField, bool LeaveFieldON, bool decodeTLV, struct tlvdb *tlv);
74extern int EMVSelectPSE(bool ActivateField, bool LeaveFieldON, uint8_t PSENum, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw);
75extern 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);
76// select application
77extern int EMVSelectApplication(struct tlvdb *tlv, uint8_t *AID, size_t *AIDlen);
78// Get Processing Options
79extern 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);
80extern 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);
81// AC
82extern int EMVGenerateChallenge(bool LeaveFieldON, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv);
83extern 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);
84// DDA
85extern int EMVInternalAuthenticate(bool LeaveFieldON, uint8_t *DDOL, size_t DDOLLen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv);
86// Mastercard
87int MSCComputeCryptoChecksum(bool LeaveFieldON, uint8_t *UDOL, uint8_t UDOLlen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv);
88// Auth
89extern int trSDA(struct tlvdb *tlv);
90extern int trDDA(bool decodeTLV, struct tlvdb *tlv);
91extern int trCDA(struct tlvdb *tlv, struct tlvdb *ac_tlv, struct tlv *pdol_data_tlv, struct tlv *ac_data_tlv);
92
93#endif
94
95
96
97
Impressum, Datenschutz