pkcs11-helper
pkcs11h-engines.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2005-2018 Alon Bar-Lev <alon.barlev@gmail.com>
3  *
4  * This software is available to you under a choice of one of two
5  * licenses. You may choose to be licensed under the terms of the GNU
6  * General Public License (GPL) Version 2, or the BSD license.
7  *
8  * GNU General Public License (GPL) Version 2
9  * ===========================================
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2
12  * as published by the Free Software Foundation.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program (see the file COPYING.GPL included with this
21  * distribution); if not, write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  *
24  * BSD License
25  * ============
26  * Redistribution and use in source and binary forms, with or without
27  * modification, are permitted provided that the following conditions are met:
28  *
29  * o Redistributions of source code must retain the above copyright notice,
30  * this list of conditions and the following disclaimer.
31  * o Redistributions in binary form must reproduce the above copyright
32  * notice, this list of conditions and the following disclaimer in the
33  * documentation and/or other materials provided with the distribution.
34  * o Neither the name of the Alon Bar-Lev nor the names of its
35  * contributors may be used to endorse or promote products derived from
36  * this software without specific prior written permission.
37  *
38  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
39  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
41  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
42  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
43  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
44  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
45  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
46  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
47  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
48  * POSSIBILITY OF SUCH DAMAGE.
49  */
50 
66 #ifndef __PKCS11H_ENGINES_H
67 #define __PKCS11H_ENGINES_H
68 
69 #include <time.h>
70 #if !defined(_WIN32)
71 #include <sys/time.h>
72 #endif
74 
75 #if defined(__cplusplus)
76 extern "C" {
77 #endif
78 
82 typedef struct pkcs11h_sys_engine_s {
83 
89  void *(*malloc) (size_t size);
90 
95  void (*free) (void *ptr);
96 
101  time_t (*time) (void);
102 
107  void (*usleep) (unsigned long usec);
108 
113 #if defined(_WIN32)
114  void *gettimeofday;
115 #else
116  int (*gettimeofday) (struct timeval *tv);
117 #endif
119 
123 typedef struct pkcs11h_crypto_engine_s {
124  void *global_data;
125 
131  int (*initialize) (
132  IN void * const global_data
133  );
134 
140  int (*uninitialize) (
141  IN void * const global_data
142  );
143 
153  IN void * const global_data,
154  IN const unsigned char * const blob,
155  IN const size_t blob_size,
156  OUT time_t * const expiration
157  );
158 
169  IN void * const global_data,
170  IN const unsigned char * const blob,
171  IN const size_t blob_size,
172  OUT char * const dn,
173  IN const size_t dn_max
174  );
175 
186  IN void * const global_data,
187  IN const unsigned char * const issuer_blob,
188  IN const size_t issuer_blob_size,
189  IN const unsigned char * const cert_blob,
190  IN const size_t cert_blob_size
191  );
193 
201 #define PKCS11H_ENGINE_CRYPTO_AUTO ((pkcs11h_engine_crypto_t *)0)
202 
203 #define PKCS11H_ENGINE_CRYPTO_OPENSSL ((pkcs11h_engine_crypto_t *)1)
204 
205 #define PKCS11H_ENGINE_CRYPTO_GNUTLS ((pkcs11h_engine_crypto_t *)2)
206 
207 #define PKCS11H_ENGINE_CRYPTO_CRYPTOAPI ((pkcs11h_engine_crypto_t *)3)
208 
212 #define PKCS11H_ENGINE_CRYPTO_WIN32 ((pkcs11h_engine_crypto_t *)3)
213 
214 #define PKCS11H_ENGINE_CRYPTO_NSS ((pkcs11h_engine_crypto_t *)4)
215 
216 #define PKCS11H_ENGINE_CRYPTO_POLARSSL ((pkcs11h_engine_crypto_t *)5)
217 
218 #define PKCS11H_ENGINE_CRYPTO_MBEDTLS ((pkcs11h_engine_crypto_t *)5)
219 
220 #define PKCS11H_ENGINE_CRYPTO_GPL ((pkcs11h_engine_crypto_t *)10)
221 
230 CK_RV
232  IN const pkcs11h_engine_system_t * const engine
233 );
234 
243 CK_RV
245  IN const pkcs11h_engine_crypto_t * const engine
246 );
247 
248 #ifdef __cplusplus
249 }
250 #endif
251 
254 #endif /* __PKCS11H_ENGINES_H */

pkcs11-helper, Copyright (C) Alon Bar-Lev <alon.barlev@gmail.com>OpenSC-Project.org Logo