1 /*
2  * aux-data.h: Non PKCS#15, non ISO7816 data
3  *             Used to pass auxiliary data from non PKCS#15, non ISO7816 applications (like minidriver)
4  *             to card specific part through the standard PKCS#15 and ISO7816 frameworks
5  *
6  * Copyright (C) 2016  Viktor Tarasov <viktor.tarasov@gmail.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22 
23 #ifndef _AUX_DATA_H
24 #define _AUX_DATA_H
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #include "cardctl.h"
31 #include "errors.h"
32 #include "asn1.h"
33 #include "types.h"
34 
35 #define SC_AUX_DATA_TYPE_NO_DATA	0x00
36 #define SC_AUX_DATA_TYPE_MD_CMAP_RECORD	0x01
37 
38 /* From Windows Smart Card Minidriver Specification
39  * Version 7.06
40  *
41  * #define MAX_CONTAINER_NAME_LEN       39
42  * #define CONTAINER_MAP_VALID_CONTAINER        1
43  * #define CONTAINER_MAP_DEFAULT_CONTAINER      2
44  * typedef struct _CONTAINER_MAP_RECORD
45  * {
46  *      WCHAR wszGuid [MAX_CONTAINER_NAME_LEN + 1];
47  *      BYTE bFlags;
48  *      BYTE bReserved;
49  *      WORD wSigKeySizeBits;
50  *      WORD wKeyExchangeKeySizeBits;
51  * } CONTAINER_MAP_RECORD, *PCONTAINER_MAP_RECORD;
52  */
53 #define SC_MD_MAX_CONTAINER_NAME_LEN	39
54 #define SC_MD_CONTAINER_MAP_VALID_CONTAINER	0x01
55 #define SC_MD_CONTAINER_MAP_DEFAULT_CONTAINER	0x02
56 
57 struct sc_md_cmap_record {
58 	unsigned char guid[SC_MD_MAX_CONTAINER_NAME_LEN + 1];
59 	size_t guid_len;
60 	unsigned flags;
61 	unsigned keysize_sign;
62 	unsigned keysize_keyexchange;
63 };
64 
65 struct sc_auxiliary_data {
66 	unsigned type;
67 	union {
68 		struct sc_md_cmap_record cmap_record;
69 	} data;
70 };
71 
72 int sc_aux_data_set_md_flags(struct sc_context *, struct sc_auxiliary_data *, unsigned char);
73 int sc_aux_data_allocate(struct sc_context *, struct sc_auxiliary_data **, struct sc_auxiliary_data *);
74 int sc_aux_data_set_md_guid(struct sc_context *, struct sc_auxiliary_data *, char *);
75 void sc_aux_data_free(struct sc_auxiliary_data **);
76 int sc_aux_data_get_md_guid(struct sc_context *, struct sc_auxiliary_data *, unsigned,
77 		unsigned char *, size_t *);
78 int sc_aux_data_get_md_flags(struct sc_context *, struct sc_auxiliary_data *, unsigned char *);
79 
80 #ifdef __cplusplus
81 }
82 #endif
83 
84 #endif /* ifndef _AUX_DATA_H */
85