1 /* 2 * Copyright (c) 2018 Yubico AB. All rights reserved. 3 * Use of this source code is governed by a BSD-style 4 * license that can be found in the LICENSE file. 5 */ 6 7 #ifndef _ISO7816_H 8 #define _ISO7816_H 9 10 #include <stdint.h> 11 #include <stdlib.h> 12 13 #include "packed.h" 14 15 PACKED_TYPE(iso7816_header_t, 16 struct iso7816_header { 17 uint8_t cla; 18 uint8_t ins; 19 uint8_t p1; 20 uint8_t p2; 21 uint8_t lc1; 22 uint8_t lc2; 23 uint8_t lc3; 24 }) 25 26 PACKED_TYPE(iso7816_apdu_t, 27 struct iso7816_apdu { 28 size_t alloc_len; 29 uint16_t payload_len; 30 uint8_t *payload_ptr; 31 iso7816_header_t header; 32 uint8_t payload[]; 33 }) 34 35 const unsigned char *iso7816_ptr(const iso7816_apdu_t *); 36 int iso7816_add(iso7816_apdu_t *, const void *, size_t); 37 iso7816_apdu_t *iso7816_new(uint8_t, uint8_t, uint16_t); 38 size_t iso7816_len(const iso7816_apdu_t *); 39 void iso7816_free(iso7816_apdu_t **); 40 41 #endif /* !_ISO7816_H */ 42