root/trunk/src/libopensc/p15card-helper.h

Revision 3126, 4.2 kB (checked in by aj, 21 months ago)

changes by Douglas E. Engert:
change the do_decompress* to sc_decompress* and the initialize_* to
sc_pkcs15emu_initialize_* in the new code.

Line 
1/*
2 * p15card-helper.h: Utility library to assist in PKCS#15 emulation on Non-filesystem cards
3 *
4 * Copyright (C) 2006, Identity Alliance, Thomas Harning <thomas.harning@identityalliance.com>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20
21#ifndef P15CARD_HELPER_H
22#define P15CARD_HELPER_H
23
24#include <opensc/pkcs15.h>
25
26
27#define USAGE_NONREP    SC_PKCS15_PRKEY_USAGE_NONREPUDIATION | \
28                        SC_PKCS15_PRKEY_USAGE_SIGN
29#define USAGE_DS        SC_PKCS15_PRKEY_USAGE_SIGN
30#define USAGE_CRYPTO    SC_PKCS15_PRKEY_USAGE_ENCRYPT | \
31                        SC_PKCS15_PRKEY_USAGE_DECRYPT | \
32                        SC_PKCS15_PRKEY_USAGE_WRAP    | \
33                        SC_PKCS15_PRKEY_USAGE_UNWRAP
34#define USAGE_KE        SC_PKCS15_PRKEY_USAGE_ENCRYPT | \
35                        SC_PKCS15_PRKEY_USAGE_DECRYPT | \
36                        SC_PKCS15_PRKEY_USAGE_WRAP    | \
37                        SC_PKCS15_PRKEY_USAGE_UNWRAP
38#define USAGE_AUT       SC_PKCS15_PRKEY_USAGE_ENCRYPT | \
39                        SC_PKCS15_PRKEY_USAGE_DECRYPT | \
40                        SC_PKCS15_PRKEY_USAGE_WRAP    | \
41                        SC_PKCS15_PRKEY_USAGE_UNWRAP  | \
42                        SC_PKCS15_PRKEY_USAGE_SIGN
43
44
45typedef struct objdata_st {
46        const char *id;
47        const char *label;
48        const char *aoid;
49        int     authority;
50        const char *path;
51        int         obj_flags;
52} objdata;
53
54typedef struct cdata_st {
55        const char *id;
56        const char *label;
57        int         authority;
58        const char *path;
59        int         obj_flags;
60} cdata;
61
62typedef struct pdata_st {
63        const char *id;
64        const char *label;
65        const char *path;
66        int         ref;
67        int         type;
68        unsigned int maxlen;
69        unsigned int minlen;
70        unsigned int storedlen;
71        int         flags;     
72        int         tries_left;
73        const char  pad_char;
74        int         obj_flags;
75} pindata;
76
77typedef struct pubdata_st {
78        const char *id;
79        const char *label;
80        unsigned int modulus_len;
81        int         usage;
82        const char *path;
83        int         ref;
84        const char *auth_id;
85        int         obj_flags;
86} pubdata;
87
88typedef struct prdata_st {
89        const char *id;
90        const char *label;
91        unsigned int modulus_len;
92        int         usage;
93        const char *path;
94        int         ref;
95        const char *auth_id;
96        int         obj_flags;
97} prdata;
98
99typedef struct keyinfo_st {
100        int fileid;
101        sc_pkcs15_id_t id;
102        unsigned int modulus_len;
103        u8 modulus[1024/8];
104} keyinfo;
105
106typedef struct p15data_items p15data_items;
107
108typedef int (*cert_load_function)(sc_card_t *card, u8** data, size_t* length, int* shouldFree);
109#define CERT_LOAD_FUNCTION(x) int x(sc_card_t *card, u8** data, size_t*length, int *shouldFree)
110typedef int (*cert_handle_function)(sc_pkcs15_card_t *p15card, p15data_items* items, const cdata* cert, u8* data, size_t length);
111#define CERT_HANDLE_FUNCTION(x) int x(sc_pkcs15_card_t *p15card, p15data_items* items, const cdata* cert, u8* data, size_t length)
112
113struct p15data_items {
114        const objdata* objects;
115        const cdata* certs;
116        const pindata* pins;
117        const pubdata* public_keys;
118        const prdata* private_keys;
119       
120        cert_load_function cert_load;
121        cert_handle_function cert_handle;
122        int cert_continue; /* Continue after cert failure */
123        int forced_private; /* Should add all private keys w/o cert-management */
124        int forced_public; /* Should add public keys (generally not needed..) */
125};
126
127CERT_HANDLE_FUNCTION(default_cert_handle);
128
129int sc_pkcs15emu_initialize_objects(sc_pkcs15_card_t *p15card, p15data_items* items);
130int sc_pkcs15emu_initialize_certificates(sc_pkcs15_card_t *p15card, p15data_items* items);
131int sc_pkcs15emu_initialize_pins(sc_pkcs15_card_t *p15card, p15data_items *items);
132int sc_pkcs15emu_initialize_private_keys(sc_pkcs15_card_t *p15card, p15data_items *items);
133int sc_pkcs15emu_initialize_public_keys(sc_pkcs15_card_t *p15card, p15data_items *items);
134int sc_pkcs15emu_initialize_all(sc_pkcs15_card_t *p15card, p15data_items *items);
135
136#endif
Note: See TracBrowser for help on using the browser.