proxmark3/client/emv/apduinfo.h

61 lines
1.6 KiB
C
Raw Normal View History

2017-11-11 03:08:28 +08:00
//-----------------------------------------------------------------------------
// Copyright (C) 2017 Merlok
//
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
// at your option, any later version. See the LICENSE.txt file for the text of
// the license.
//-----------------------------------------------------------------------------
// APDU status bytes information
//-----------------------------------------------------------------------------
#ifndef APDUINFO_H__
#define APDUINFO_H__
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
2019-07-11 00:11:56 +08:00
#include <stdbool.h>
2017-11-11 03:08:28 +08:00
#include <inttypes.h>
2019-03-10 06:35:06 +08:00
#define APDUCODE_TYPE_NONE 0
#define APDUCODE_TYPE_INFO 1
#define APDUCODE_TYPE_WARNING 2
#define APDUCODE_TYPE_ERROR 3
#define APDUCODE_TYPE_SECURITY 4
2017-11-11 03:08:28 +08:00
typedef struct {
2019-03-10 06:35:06 +08:00
const char *ID;
const uint8_t Type;
const char *Description;
2017-11-11 03:08:28 +08:00
} APDUCode;
const APDUCode *GetAPDUCode(uint8_t sw1, uint8_t sw2);
2019-04-06 06:52:55 +08:00
const char *GetAPDUCodeDescription(uint8_t sw1, uint8_t sw2);
2017-11-11 03:08:28 +08:00
2019-07-12 18:58:38 +08:00
typedef struct {
2019-07-11 00:11:56 +08:00
uint8_t cla;
uint8_t ins;
uint8_t p1;
uint8_t p2;
uint8_t lc[3];
2019-07-11 00:21:54 +08:00
} __attribute__((packed)) ExtAPDUHeader;
2019-07-11 00:11:56 +08:00
2019-07-12 18:58:38 +08:00
typedef struct {
2019-07-11 00:11:56 +08:00
uint8_t cla;
uint8_t ins;
uint8_t p1;
uint8_t p2;
uint16_t lc;
uint8_t *data;
uint32_t le;
bool extended_apdu;
uint8_t case_type;
2019-07-11 00:21:54 +08:00
} __attribute__((packed)) APDUStruct;
2019-07-11 00:11:56 +08:00
2019-07-15 22:26:42 +08:00
extern int APDUDecode(uint8_t *data, int len, APDUStruct *apdu);
extern int APDUEncode(APDUStruct *apdu, uint8_t *data, int *len);
2019-07-11 00:21:54 +08:00
extern void APDUPrint(APDUStruct apdu);
2019-07-16 00:12:01 +08:00
extern void APDUPrintEx(APDUStruct apdu, size_t maxdatalen);
2019-07-11 00:11:56 +08:00
2017-11-11 03:08:28 +08:00
#endif