pkcs11-helper-1.0/pkcs11h-certificate.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 
00073 #ifndef __PKCS11H_CERTIFICATE_H
00074 #define __PKCS11H_CERTIFICATE_H
00075 
00076 #include <pkcs11-helper-1.0/pkcs11h-core.h>
00077 
00078 #if defined(__cplusplus)
00079 extern "C" {
00080 #endif
00081 
00082 struct pkcs11h_certificate_id_s;
00083 struct pkcs11h_certificate_s;
00084 
00088 typedef struct pkcs11h_certificate_id_s *pkcs11h_certificate_id_t;
00089 
00093 typedef struct pkcs11h_certificate_s *pkcs11h_certificate_t;
00094 
00095 struct pkcs11h_certificate_id_list_s;
00096 
00100 typedef struct pkcs11h_certificate_id_list_s *pkcs11h_certificate_id_list_t;
00101 
00105 struct pkcs11h_certificate_id_s {
00107         pkcs11h_token_id_t token_id;
00108 
00110         char displayName[1024];
00112         CK_BYTE_PTR attrCKA_ID;
00114         size_t attrCKA_ID_size;
00115 
00117         unsigned char *certificate_blob;
00119         size_t certificate_blob_size;
00120 };
00121 
00125 struct pkcs11h_certificate_id_list_s {
00127         pkcs11h_certificate_id_list_t next;
00129         pkcs11h_certificate_id_t certificate_id;
00130 };
00131 
00137 CK_RV
00138 pkcs11h_certificate_freeCertificateId (
00139         IN pkcs11h_certificate_id_t certificate_id
00140 );
00141 
00150 CK_RV
00151 pkcs11h_certificate_duplicateCertificateId (
00152         OUT pkcs11h_certificate_id_t * const to,
00153         IN const pkcs11h_certificate_id_t from
00154 );
00155 
00165 CK_RV
00166 pkcs11h_certificate_setCertificateIdCertificateBlob (
00167         IN const pkcs11h_certificate_id_t certificate_id,
00168         IN const unsigned char * const blob,
00169         IN const size_t blob_size
00170 );
00171 
00177 CK_RV
00178 pkcs11h_certificate_freeCertificate (
00179         IN pkcs11h_certificate_t certificate
00180 );
00181 
00194 CK_RV
00195 pkcs11h_certificate_create (
00196         IN const pkcs11h_certificate_id_t certificate_id,
00197         IN void * const user_data,
00198         IN const unsigned mask_prompt,
00199         IN const int pin_cache_period,
00200         OUT pkcs11h_certificate_t * const p_certificate
00201 );
00202 
00208 unsigned
00209 pkcs11h_certificate_getPromptMask (
00210         IN const pkcs11h_certificate_t certificate
00211 );
00212 
00218 void
00219 pkcs11h_certificate_setPromptMask (
00220         IN const pkcs11h_certificate_t certificate,
00221         IN const unsigned mask_prompt
00222 );
00223 
00229 void *
00230 pkcs11h_certificate_getUserData (
00231         IN const pkcs11h_certificate_t certificate
00232 );
00233 
00239 void
00240 pkcs11h_certificate_setUserData (
00241         IN const pkcs11h_certificate_t certificate,
00242         IN void * const user_data
00243 );
00244 
00253 CK_RV
00254 pkcs11h_certificate_getCertificateId (
00255         IN const pkcs11h_certificate_t certificate,
00256         OUT pkcs11h_certificate_id_t * const p_certificate_id
00257 );
00258 
00267 CK_RV
00268 pkcs11h_certificate_getCertificateBlob (
00269         IN const pkcs11h_certificate_t certificate,
00270         OUT unsigned char * const certificate_blob,
00271         IN OUT size_t * const p_certificate_blob_size
00272 );
00273 
00282 CK_RV
00283 pkcs11h_certificate_serializeCertificateId (
00284         OUT char * const sz,
00285         IN OUT size_t *max,
00286         IN const pkcs11h_certificate_id_t certificate_id
00287 );
00288 
00297 CK_RV
00298 pkcs11h_certificate_deserializeCertificateId (
00299         OUT pkcs11h_certificate_id_t * const p_certificate_id,
00300         IN const char * const sz
00301 );
00302 
00308 CK_RV
00309 pkcs11h_certificate_ensureCertificateAccess (
00310         IN const pkcs11h_certificate_t certificate
00311 );
00312 
00318 CK_RV
00319 pkcs11h_certificate_ensureKeyAccess (
00320         IN const pkcs11h_certificate_t certificate
00321 );
00322 
00337 CK_RV
00338 pkcs11h_certificate_lockSession (
00339         IN const pkcs11h_certificate_t certificate
00340 );
00341 
00348 CK_RV
00349 pkcs11h_certificate_releaseSession (
00350         IN const pkcs11h_certificate_t certificate
00351 );
00352 
00367 CK_RV
00368 pkcs11h_certificate_sign (
00369         IN const pkcs11h_certificate_t certificate,
00370         IN const CK_MECHANISM_TYPE mech_type,
00371         IN const unsigned char * const source,
00372         IN const size_t source_size,
00373         OUT unsigned char * const target,
00374         IN OUT size_t * const p_target_size
00375 );
00376 
00391 CK_RV
00392 pkcs11h_certificate_signRecover (
00393         IN const pkcs11h_certificate_t certificate,
00394         IN const CK_MECHANISM_TYPE mech_type,
00395         IN const unsigned char * const source,
00396         IN const size_t source_size,
00397         OUT unsigned char * const target,
00398         IN OUT size_t * const p_target_size
00399 );
00400 
00414 CK_RV
00415 pkcs11h_certificate_decrypt (
00416         IN const pkcs11h_certificate_t certificate,
00417         IN const CK_MECHANISM_TYPE mech_type,
00418         IN const unsigned char * const source,
00419         IN const size_t source_size,
00420         OUT unsigned char * const target,
00421         IN OUT size_t * const p_target_size
00422 );
00423 
00437 CK_RV
00438 pkcs11h_certificate_unwrap (
00439         IN const pkcs11h_certificate_t certificate,
00440         IN const CK_MECHANISM_TYPE mech_type,
00441         IN const unsigned char * const source,
00442         IN const size_t source_size,
00443         OUT unsigned char * const target,
00444         IN OUT size_t * const p_target_size
00445 );
00446 
00460 CK_RV
00461 pkcs11h_certificate_signAny (
00462         IN const pkcs11h_certificate_t certificate,
00463         IN const CK_MECHANISM_TYPE mech_type,
00464         IN const unsigned char * const source,
00465         IN const size_t source_size,
00466         OUT unsigned char * const target,
00467         IN OUT size_t * const p_target_size
00468 );
00469 
00483 CK_RV
00484 pkcs11h_certificate_decryptAny (
00485         IN const pkcs11h_certificate_t certificate,
00486         IN const CK_MECHANISM_TYPE mech_type,
00487         IN const unsigned char * const source,
00488         IN const size_t source_size,
00489         OUT unsigned char * const target,
00490         IN OUT size_t * const p_target_size
00491 );
00492 
00498 CK_RV
00499 pkcs11h_certificate_freeCertificateIdList (
00500         IN const pkcs11h_certificate_id_list_t cert_id_list
00501 );
00502 
00517 CK_RV
00518 pkcs11h_certificate_enumTokenCertificateIds (
00519         IN const pkcs11h_token_id_t token_id,
00520         IN const unsigned method,
00521         IN void * const user_data,
00522         IN const unsigned mask_prompt,
00523         OUT pkcs11h_certificate_id_list_t * const p_cert_id_issuers_list,
00524         OUT pkcs11h_certificate_id_list_t * const p_cert_id_end_list
00525 );
00526 
00539 CK_RV
00540 pkcs11h_certificate_enumCertificateIds (
00541         IN const unsigned method,
00542         IN void * const user_data,
00543         IN const unsigned mask_prompt,
00544         OUT pkcs11h_certificate_id_list_t * const p_cert_id_issuers_list,
00545         OUT pkcs11h_certificate_id_list_t * const p_cert_id_end_list
00546 );
00547 
00548 #ifdef __cplusplus
00549 }
00550 #endif
00551 
00554 #endif                          /* __PKCS11H_CERTIFICATE_H */

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