]> git.zerfleddert.de Git - proxmark3-svn/blame - client/emv/emvcore.h
Update lfops.c
[proxmark3-svn] / client / emv / emvcore.h
CommitLineData
a2bb2735 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//-----------------------------------------------------------------------------
3c5fce2b 8// EMV core functionality
a2bb2735 9//-----------------------------------------------------------------------------
10
11#ifndef EMVCORE_H__
12#define EMVCORE_H__
13
a2bb2735 14#include <stdint.h>
41bdfce3 15#include <stdbool.h>
d03fb293 16#include "tlv.h"
41bdfce3 17#include "jansson.h"
a2bb2735 18
6b5105be 19// maximum APDU lengths. Long APDUs not yet supported/needed
20#define APDU_DATA_LEN 255
21#define APDU_COMMAND_LEN (4 + 1 + APDU_DATA_LEN + 1)
22#define APDU_RESPONSE_LEN (256 + 2)
3c5fce2b 23
8d7d7b61 24typedef enum {
25 ECC_CONTACTLESS,
26 ECC_CONTACT
27} EMVCommandChannel;
28
10d4f823 29enum TransactionType {
30 TT_MSD,
31 TT_VSDC, // not standart for contactless!!!!
32 TT_QVSDCMCHIP,
33 TT_CDA,
34};
95b697f0 35extern char *TransactionTypeStr[];
10d4f823 36
66efdc1f 37enum CardPSVendor {
38 CV_NA,
39 CV_VISA,
40 CV_MASTERCARD,
41 CV_AMERICANEXPRESS,
42 CV_JCB,
43 CV_CB,
97096af6 44 CV_SWITCH,
45 CV_DINERS,
66efdc1f 46 CV_OTHER,
47};
48extern enum CardPSVendor GetCardPSVendor(uint8_t * AID, size_t AIDlen);
49
41bdfce3 50extern void DropFieldEx(EMVCommandChannel channel);
51
1511ea28 52extern bool TLVPrintFromBuffer(uint8_t *data, int datalen);
3c5fce2b 53extern void TLVPrintFromTLV(struct tlvdb *tlv);
66efdc1f 54extern void TLVPrintFromTLVLev(struct tlvdb *tlv, int level);
3c5fce2b
OM
55extern void TLVPrintAIDlistFromSelectTLV(struct tlvdb *tlv);
56
66efdc1f 57extern struct tlvdb *GetPANFromTrack2(const struct tlv *track2);
58extern struct tlvdb *GetdCVVRawFromTrack2(const struct tlv *track2);
59
3c5fce2b
OM
60extern void SetAPDULogging(bool logging);
61
39cc1c87 62// exchange
41bdfce3 63extern int EMVExchangeEx(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldON, uint8_t *apdu, int apdu_len, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv);
39cc1c87 64
3c5fce2b 65// search application
1511ea28 66extern int EMVSearchPSE(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldON, uint8_t PSENum, bool decodeTLV, struct tlvdb *tlv);
8d7d7b61 67extern int EMVSearch(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldON, bool decodeTLV, struct tlvdb *tlv);
68extern int EMVSelectPSE(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldON, uint8_t PSENum, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw);
69extern int EMVSelect(EMVCommandChannel channel, 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);
3c5fce2b
OM
70// select application
71extern int EMVSelectApplication(struct tlvdb *tlv, uint8_t *AID, size_t *AIDlen);
72// Get Processing Options
8d7d7b61 73extern int EMVGPO(EMVCommandChannel channel, bool LeaveFieldON, uint8_t *PDOL, size_t PDOLLen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv);
74extern int EMVReadRecord(EMVCommandChannel channel, bool LeaveFieldON, uint8_t SFI, uint8_t SFIrec, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv);
10d4f823 75// AC
8d7d7b61 76extern int EMVGenerateChallenge(EMVCommandChannel channel, bool LeaveFieldON, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv);
77extern int EMVAC(EMVCommandChannel channel, 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);
d03fb293 78// DDA
8d7d7b61 79extern int EMVInternalAuthenticate(EMVCommandChannel channel, bool LeaveFieldON, uint8_t *DDOL, size_t DDOLLen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv);
66efdc1f 80// Mastercard
8d7d7b61 81int MSCComputeCryptoChecksum(EMVCommandChannel channel, bool LeaveFieldON, uint8_t *UDOL, uint8_t UDOLlen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv);
10d4f823 82// Auth
d03fb293 83extern int trSDA(struct tlvdb *tlv);
8d7d7b61 84extern int trDDA(EMVCommandChannel channel, bool decodeTLV, struct tlvdb *tlv);
d03fb293 85extern int trCDA(struct tlvdb *tlv, struct tlvdb *ac_tlv, struct tlv *pdol_data_tlv, struct tlv *ac_data_tlv);
a2bb2735 86
95b697f0
OM
87extern int RecoveryCertificates(struct tlvdb *tlvRoot, json_t *root);
88
1511ea28 89extern struct emv_pk *get_ca_pk(struct tlvdb *db);
a2bb2735 90#endif
91
92
93
94
Impressum, Datenschutz