pkcs11-helper-1.0/pkcs11h-engines.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2005-2007 Alon Bar-Lev <alon.barlev@gmail.com>
00003  * All rights reserved.
00004  *
00005  * This software is available to you under a choice of one of two
00006  * licenses.  You may choose to be licensed under the terms of the GNU
00007  * General Public License (GPL) Version 2, or the BSD license.
00008  *
00009  * GNU General Public License (GPL) Version 2
00010  * ===========================================
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License version 2
00013  * as published by the Free Software Foundation.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program (see the file COPYING.GPL included with this
00022  * distribution); if not, write to the Free Software Foundation, Inc.,
00023  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00024  *
00025  * BSD License
00026  * ============
00027  * Redistribution and use in source and binary forms, with or without
00028  * modification, are permitted provided that the following conditions are met:
00029  *
00030  *     o Redistributions of source code must retain the above copyright notice,
00031  *       this list of conditions and the following disclaimer.
00032  *     o Redistributions in binary form must reproduce the above copyright
00033  *       notice, this list of conditions and the following disclaimer in the
00034  *       documentation and/or other materials provided with the distribution.
00035  *     o Neither the name of the <ORGANIZATION> nor the names of its
00036  *       contributors may be used to endorse or promote products derived from
00037  *       this software without specific prior written permission.
00038  *
00039  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00040  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00041  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00042  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00043  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00044  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00045  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00046  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00047  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00048  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00049  * POSSIBILITY OF SUCH DAMAGE.
00050  */
00051 
00067 #ifndef __PKCS11H_ENGINES_H
00068 #define __PKCS11H_ENGINES_H
00069 
00070 #include <time.h>
00071 #if !defined(_WIN32)
00072 #include <sys/time.h>
00073 #endif
00074 #include <pkcs11-helper-1.0/pkcs11h-def.h>
00075 
00076 #if defined(__cplusplus)
00077 extern "C" {
00078 #endif
00079 
00083 typedef struct pkcs11h_sys_engine_s {
00084 
00090         void *(*malloc) (size_t size);
00091 
00096         void (*free) (void *ptr);
00097 
00102         time_t (*time) (void);
00103 
00108         void (*usleep) (unsigned long usec);
00109 
00114 #if defined(_WIN32)
00115         void *gettimeofday;
00116 #else
00117         int (*gettimeofday) (struct timeval *tv);
00118 #endif
00119 } pkcs11h_engine_system_t;
00120 
00124 typedef struct pkcs11h_crypto_engine_s {
00125         void *global_data;
00126 
00132         int (*initialize) (
00133                 IN void * const global_data
00134         );
00135 
00141         int (*uninitialize) (
00142                 IN void * const global_data
00143         );
00144 
00153         int (*certificate_get_expiration) (
00154                 IN void * const global_data,
00155                 IN const unsigned char * const blob,
00156                 IN const size_t blob_size,
00157                 OUT time_t * const expiration
00158         );
00159 
00169         int (*certificate_get_dn) (
00170                 IN void * const global_data,
00171                 IN const unsigned char * const blob,
00172                 IN const size_t blob_size,
00173                 OUT char * const dn,
00174                 IN const size_t dn_max
00175         );
00176 
00186         int (*certificate_is_issuer) (
00187                 IN void * const global_data,
00188                 IN const unsigned char * const issuer_blob,
00189                 IN const size_t issuer_blob_size,
00190                 IN const unsigned char * const cert_blob,
00191                 IN const size_t cert_blob_size
00192         );
00193 } pkcs11h_engine_crypto_t;
00194 
00202 #define PKCS11H_ENGINE_CRYPTO_AUTO      ((pkcs11h_engine_crypto_t *)0)
00203 
00204 #define PKCS11H_ENGINE_CRYPTO_OPENSSL   ((pkcs11h_engine_crypto_t *)1)
00205 
00206 #define PKCS11H_ENGINE_CRYPTO_GNUTLS    ((pkcs11h_engine_crypto_t *)2)
00207 
00208 #define PKCS11H_ENGINE_CRYPTO_WIN32     ((pkcs11h_engine_crypto_t *)3)
00209 
00210 #define PKCS11H_ENGINE_CRYPTO_NSS       ((pkcs11h_engine_crypto_t *)4)
00211 
00212 #define PKCS11H_ENGINE_CRYPTO_GPL       ((pkcs11h_engine_crypto_t *)10)
00213 
00222 CK_RV
00223 pkcs11h_engine_setSystem (
00224         IN const pkcs11h_engine_system_t * const engine
00225 );
00226 
00235 CK_RV
00236 pkcs11h_engine_setCrypto (
00237         IN const pkcs11h_engine_crypto_t * const engine
00238 );
00239 
00240 #ifdef __cplusplus
00241 }
00242 #endif
00243 
00246 #endif                          /* __PKCS11H_ENGINES_H */

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