summaryrefslogtreecommitdiff
path: root/src/iso7816.h
blob: 426cd97207ad0726739819796674747b1b555632 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
 * Copyright (c) 2018 Yubico AB. All rights reserved.
 * Use of this source code is governed by a BSD-style
 * license that can be found in the LICENSE file.
 */

#ifndef _ISO7816_H
#define _ISO7816_H

#include "packed.h"

PACKED_TYPE(iso7816_header_t,
struct iso7816_header {
	uint8_t cla;
	uint8_t ins;
	uint8_t p1;
	uint8_t p2;
	uint8_t lc1;
	uint8_t lc2;
	uint8_t lc3;
})

PACKED_TYPE(iso7816_apdu_t,
struct iso7816_apdu {
	size_t            alloc_len;
	uint16_t          payload_len;
	uint8_t          *payload_ptr;
	iso7816_header_t  header;
	uint8_t           payload[];
})

const unsigned char *iso7816_ptr(const iso7816_apdu_t *);
int iso7816_add(iso7816_apdu_t *, const void *, size_t);
iso7816_apdu_t *iso7816_new(uint8_t, uint8_t, uint16_t);
size_t iso7816_len(const iso7816_apdu_t *);
void iso7816_free(iso7816_apdu_t **);

#endif /* !_ISO7816_H */