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

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