pkcs11-helper
pkcs11h-certificate.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 
73 #ifndef __PKCS11H_CERTIFICATE_H
74 #define __PKCS11H_CERTIFICATE_H
75 
77 
78 #if defined(__cplusplus)
79 extern "C" {
80 #endif
81 
83 struct pkcs11h_certificate_s;
84 
89 
93 typedef struct pkcs11h_certificate_s *pkcs11h_certificate_t;
94 
96 
101 
108 
110  char displayName[1024];
112  CK_BYTE_PTR attrCKA_ID;
115 
117  unsigned char *certificate_blob;
120 };
121 
130 };
131 
137 CK_RV
139  IN pkcs11h_certificate_id_t certificate_id
140 );
141 
150 CK_RV
152  OUT pkcs11h_certificate_id_t * const to,
153  IN const pkcs11h_certificate_id_t from
154 );
155 
165 CK_RV
167  IN const pkcs11h_certificate_id_t certificate_id,
168  IN const unsigned char * const blob,
169  IN const size_t blob_size
170 );
171 
177 CK_RV
179  IN pkcs11h_certificate_t certificate
180 );
181 
194 CK_RV
196  IN const pkcs11h_certificate_id_t certificate_id,
197  IN void * const user_data,
198  IN const unsigned mask_prompt,
199  IN const int pin_cache_period,
200  OUT pkcs11h_certificate_t * const p_certificate
201 );
202 
208 unsigned
210  IN const pkcs11h_certificate_t certificate
211 );
212 
218 void
220  IN const pkcs11h_certificate_t certificate,
221  IN const unsigned mask_prompt
222 );
223 
229 void *
231  IN const pkcs11h_certificate_t certificate
232 );
233 
239 void
241  IN const pkcs11h_certificate_t certificate,
242  IN void * const user_data
243 );
244 
253 CK_RV
255  IN const pkcs11h_certificate_t certificate,
256  OUT pkcs11h_certificate_id_t * const p_certificate_id
257 );
258 
267 CK_RV
269  IN const pkcs11h_certificate_t certificate,
270  OUT unsigned char * const certificate_blob,
271  IN OUT size_t * const p_certificate_blob_size
272 );
273 
282 CK_RV
284  OUT char * const sz,
285  IN OUT size_t *max,
286  IN const pkcs11h_certificate_id_t certificate_id
287 );
288 
297 CK_RV
299  OUT pkcs11h_certificate_id_t * const p_certificate_id,
300  IN const char * const sz
301 );
302 
308 CK_RV
310  IN const pkcs11h_certificate_t certificate
311 );
312 
318 CK_RV
320  IN const pkcs11h_certificate_t certificate
321 );
322 
337 CK_RV
339  IN const pkcs11h_certificate_t certificate
340 );
341 
348 CK_RV
350  IN const pkcs11h_certificate_t certificate
351 );
352 
367 CK_RV
369  IN const pkcs11h_certificate_t certificate,
370  IN const CK_MECHANISM_TYPE mech_type,
371  IN const unsigned char * const source,
372  IN const size_t source_size,
373  OUT unsigned char * const target,
374  IN OUT size_t * const p_target_size
375 );
376 
391 CK_RV
393  IN const pkcs11h_certificate_t certificate,
394  IN const CK_MECHANISM_TYPE mech_type,
395  IN const unsigned char * const source,
396  IN const size_t source_size,
397  OUT unsigned char * const target,
398  IN OUT size_t * const p_target_size
399 );
400 
414 CK_RV
416  IN const pkcs11h_certificate_t certificate,
417  IN const CK_MECHANISM_TYPE mech_type,
418  IN const unsigned char * const source,
419  IN const size_t source_size,
420  OUT unsigned char * const target,
421  IN OUT size_t * const p_target_size
422 );
423 
437 CK_RV
439  IN const pkcs11h_certificate_t certificate,
440  IN const CK_MECHANISM_TYPE mech_type,
441  IN const unsigned char * const source,
442  IN const size_t source_size,
443  OUT unsigned char * const target,
444  IN OUT size_t * const p_target_size
445 );
446 
460 CK_RV
462  IN const pkcs11h_certificate_t certificate,
463  IN const CK_MECHANISM_TYPE mech_type,
464  IN const unsigned char * const source,
465  IN const size_t source_size,
466  OUT unsigned char * const target,
467  IN OUT size_t * const p_target_size
468 );
469 
483 CK_RV
485  IN const pkcs11h_certificate_t certificate,
486  IN const CK_MECHANISM_TYPE mech_type,
487  IN const unsigned char * const source,
488  IN const size_t source_size,
489  OUT unsigned char * const target,
490  IN OUT size_t * const p_target_size
491 );
492 
498 CK_RV
500  IN const pkcs11h_certificate_id_list_t cert_id_list
501 );
502 
517 CK_RV
519  IN const pkcs11h_token_id_t token_id,
520  IN const unsigned method,
521  IN void * const user_data,
522  IN const unsigned mask_prompt,
523  OUT pkcs11h_certificate_id_list_t * const p_cert_id_issuers_list,
524  OUT pkcs11h_certificate_id_list_t * const p_cert_id_end_list
525 );
526 
539 CK_RV
541  IN const unsigned method,
542  IN void * const user_data,
543  IN const unsigned mask_prompt,
544  OUT pkcs11h_certificate_id_list_t * const p_cert_id_issuers_list,
545  OUT pkcs11h_certificate_id_list_t * const p_cert_id_end_list
546 );
547 
548 #ifdef __cplusplus
549 }
550 #endif
551 
554 #endif /* __PKCS11H_CERTIFICATE_H */
CK_BYTE_PTR attrCKA_ID
Definition: pkcs11h-certificate.h:112
CK_RV pkcs11h_certificate_duplicateCertificateId(OUT pkcs11h_certificate_id_t *const to, IN const pkcs11h_certificate_id_t from)
Duplicate certificate_id object.
CK_RV pkcs11h_certificate_serializeCertificateId(OUT char *const sz, IN OUT size_t *max, IN const pkcs11h_certificate_id_t certificate_id)
Serialize certificate_id into a string.
CK_RV pkcs11h_certificate_deserializeCertificateId(OUT pkcs11h_certificate_id_t *const p_certificate_id, IN const char *const sz)
Deserialize certificate_id out of string.
struct pkcs11h_certificate_id_list_s * pkcs11h_certificate_id_list_t
Certificate id list.
Definition: pkcs11h-certificate.h:100
struct pkcs11h_certificate_s * pkcs11h_certificate_t
Certificate object.
Definition: pkcs11h-certificate.h:93
unsigned char * certificate_blob
Definition: pkcs11h-certificate.h:117
CK_RV pkcs11h_certificate_decrypt(IN const pkcs11h_certificate_t certificate, IN const CK_MECHANISM_TYPE mech_type, IN const unsigned char *const source, IN const size_t source_size, OUT unsigned char *const target, IN OUT size_t *const p_target_size)
Decrypt data.
pkcs11h_certificate_id_list_t next
Definition: pkcs11h-certificate.h:127
pkcs11h_certificate_id_t certificate_id
Definition: pkcs11h-certificate.h:129
void * pkcs11h_certificate_getUserData(IN const pkcs11h_certificate_t certificate)
Extract user data out of certificate.
char displayName[1024]
Definition: pkcs11h-certificate.h:110
CK_RV pkcs11h_certificate_sign(IN const pkcs11h_certificate_t certificate, IN const CK_MECHANISM_TYPE mech_type, IN const unsigned char *const source, IN const size_t source_size, OUT unsigned char *const target, IN OUT size_t *const p_target_size)
Sign data.
struct pkcs11h_certificate_id_s * pkcs11h_certificate_id_t
Certificate id reference.
Definition: pkcs11h-certificate.h:88
void pkcs11h_certificate_setUserData(IN const pkcs11h_certificate_t certificate, IN void *const user_data)
Extract user data out of certificate.
CK_RV pkcs11h_certificate_signAny(IN const pkcs11h_certificate_t certificate, IN const CK_MECHANISM_TYPE mech_type, IN const unsigned char *const source, IN const size_t source_size, OUT unsigned char *const target, IN OUT size_t *const p_target_size)
Sign data mechanism determined by key attributes.
CK_RV pkcs11h_certificate_freeCertificate(IN pkcs11h_certificate_t certificate)
Free certificate object.
Certificate id reference.
Definition: pkcs11h-certificate.h:105
CK_RV pkcs11h_certificate_getCertificateBlob(IN const pkcs11h_certificate_t certificate, OUT unsigned char *const certificate_blob, IN OUT size_t *const p_certificate_blob_size)
Get the certificate blob out of the certificate object.
CK_RV pkcs11h_certificate_setCertificateIdCertificateBlob(IN const pkcs11h_certificate_id_t certificate_id, IN const unsigned char *const blob, IN const size_t blob_size)
Sets internal certificate_id blob.
CK_RV pkcs11h_certificate_lockSession(IN const pkcs11h_certificate_t certificate)
Lock session for threded environment.
CK_RV pkcs11h_certificate_getCertificateId(IN const pkcs11h_certificate_t certificate, OUT pkcs11h_certificate_id_t *const p_certificate_id)
Get certifiate id object out of a certifiate.
Token identifier.
Definition: pkcs11h-core.h:269
CK_RV pkcs11h_certificate_enumTokenCertificateIds(IN const pkcs11h_token_id_t token_id, IN const unsigned method, IN void *const user_data, IN const unsigned mask_prompt, OUT pkcs11h_certificate_id_list_t *const p_cert_id_issuers_list, OUT pkcs11h_certificate_id_list_t *const p_cert_id_end_list)
Enumerate available certificates on specific token.
CK_RV pkcs11h_certificate_decryptAny(IN const pkcs11h_certificate_t certificate, IN const CK_MECHANISM_TYPE mech_type, IN const unsigned char *const source, IN const size_t source_size, OUT unsigned char *const target, IN OUT size_t *const p_target_size)
Decrypt data mechanism determined by key attributes.
pkcs11-helper core.
CK_RV pkcs11h_certificate_create(IN const pkcs11h_certificate_id_t certificate_id, IN void *const user_data, IN const unsigned mask_prompt, IN const int pin_cache_period, OUT pkcs11h_certificate_t *const p_certificate)
Create a certificate object out of certificate_id.
CK_RV pkcs11h_certificate_unwrap(IN const pkcs11h_certificate_t certificate, IN const CK_MECHANISM_TYPE mech_type, IN const unsigned char *const source, IN const size_t source_size, OUT unsigned char *const target, IN OUT size_t *const p_target_size)
Decrypt data.
CK_RV pkcs11h_certificate_ensureCertificateAccess(IN const pkcs11h_certificate_t certificate)
Ensure certificate is accessible.
CK_RV pkcs11h_certificate_releaseSession(IN const pkcs11h_certificate_t certificate)
Releases session lock.
CK_RV pkcs11h_certificate_freeCertificateId(IN pkcs11h_certificate_id_t certificate_id)
Free certificate_id object.
unsigned pkcs11h_certificate_getPromptMask(IN const pkcs11h_certificate_t certificate)
Extract user data out of certificate.
CK_RV pkcs11h_certificate_enumCertificateIds(IN const unsigned method, IN void *const user_data, IN const unsigned mask_prompt, OUT pkcs11h_certificate_id_list_t *const p_cert_id_issuers_list, OUT pkcs11h_certificate_id_list_t *const p_cert_id_end_list)
Enumerate available certificates.
CK_RV pkcs11h_certificate_freeCertificateIdList(IN const pkcs11h_certificate_id_list_t cert_id_list)
Free certificate_id list.
pkcs11h_token_id_t token_id
Definition: pkcs11h-certificate.h:107
size_t attrCKA_ID_size
Definition: pkcs11h-certificate.h:114
CK_RV pkcs11h_certificate_ensureKeyAccess(IN const pkcs11h_certificate_t certificate)
Ensure key is accessible.
void pkcs11h_certificate_setPromptMask(IN const pkcs11h_certificate_t certificate, IN const unsigned mask_prompt)
Extract user data out of certificate.
CK_RV pkcs11h_certificate_signRecover(IN const pkcs11h_certificate_t certificate, IN const CK_MECHANISM_TYPE mech_type, IN const unsigned char *const source, IN const size_t source_size, OUT unsigned char *const target, IN OUT size_t *const p_target_size)
Sign data.
size_t certificate_blob_size
Definition: pkcs11h-certificate.h:119
Certificate id list.
Definition: pkcs11h-certificate.h:125

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