pkcs11-helper
pkcs11h-certificate.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
72#ifndef __PKCS11H_CERTIFICATE_H
73#define __PKCS11H_CERTIFICATE_H
74
76
77#if defined(__cplusplus)
78extern "C" {
79#endif
80
82struct pkcs11h_certificate_s;
83
88
92typedef struct pkcs11h_certificate_s *pkcs11h_certificate_t;
93
95
100
107
109 char displayName[1024];
111 CK_BYTE_PTR attrCKA_ID;
114
116 unsigned char *certificate_blob;
119};
120
129};
130
136CK_RV
138 IN pkcs11h_certificate_id_t certificate_id
139);
140
149CK_RV
151 OUT pkcs11h_certificate_id_t * const to,
152 IN const pkcs11h_certificate_id_t from
153);
154
164CK_RV
166 IN const pkcs11h_certificate_id_t certificate_id,
167 IN const unsigned char * const blob,
168 IN const size_t blob_size
169);
170
176CK_RV
178 IN pkcs11h_certificate_t certificate
179);
180
193CK_RV
195 IN const pkcs11h_certificate_id_t certificate_id,
196 IN void * const user_data,
197 IN const unsigned mask_prompt,
198 IN const int pin_cache_period,
199 OUT pkcs11h_certificate_t * const p_certificate
200);
201
207unsigned
209 IN const pkcs11h_certificate_t certificate
210);
211
217void
219 IN const pkcs11h_certificate_t certificate,
220 IN const unsigned mask_prompt
221);
222
228void *
230 IN const pkcs11h_certificate_t certificate
231);
232
238void
240 IN const pkcs11h_certificate_t certificate,
241 IN void * const user_data
242);
243
252CK_RV
254 IN const pkcs11h_certificate_t certificate,
255 OUT pkcs11h_certificate_id_t * const p_certificate_id
256);
257
266CK_RV
268 IN const pkcs11h_certificate_t certificate,
269 OUT unsigned char * const certificate_blob,
270 IN OUT size_t * const p_certificate_blob_size
271);
272
281CK_RV
283 OUT char * const sz,
284 IN OUT size_t *max,
285 IN const pkcs11h_certificate_id_t certificate_id
286);
287
296CK_RV
298 OUT pkcs11h_certificate_id_t * const p_certificate_id,
299 IN const char * const sz
300);
301
307CK_RV
309 IN const pkcs11h_certificate_t certificate
310);
311
317CK_RV
319 IN const pkcs11h_certificate_t certificate
320);
321
336CK_RV
338 IN const pkcs11h_certificate_t certificate
339);
340
347CK_RV
349 IN const pkcs11h_certificate_t certificate
350);
351
366CK_RV
368 IN const pkcs11h_certificate_t certificate,
369 IN const CK_MECHANISM_TYPE mech_type,
370 IN const unsigned char * const source,
371 IN const size_t source_size,
372 OUT unsigned char * const target,
373 IN OUT size_t * const p_target_size
374);
375
390CK_RV
392 IN const pkcs11h_certificate_t certificate,
393 IN const CK_MECHANISM_TYPE mech_type,
394 IN const unsigned char * const source,
395 IN const size_t source_size,
396 OUT unsigned char * const target,
397 IN OUT size_t * const p_target_size
398);
399
413CK_RV
415 IN const pkcs11h_certificate_t certificate,
416 IN const CK_MECHANISM_TYPE mech_type,
417 IN const unsigned char * const source,
418 IN const size_t source_size,
419 OUT unsigned char * const target,
420 IN OUT size_t * const p_target_size
421);
422
436CK_RV
438 IN const pkcs11h_certificate_t certificate,
439 IN const CK_MECHANISM_TYPE mech_type,
440 IN const unsigned char * const source,
441 IN const size_t source_size,
442 OUT unsigned char * const target,
443 IN OUT size_t * const p_target_size
444);
445
459CK_RV
461 IN const pkcs11h_certificate_t certificate,
462 IN const CK_MECHANISM_TYPE mech_type,
463 IN const unsigned char * const source,
464 IN const size_t source_size,
465 OUT unsigned char * const target,
466 IN OUT size_t * const p_target_size
467);
468
482CK_RV
484 IN const pkcs11h_certificate_t certificate,
485 IN const CK_MECHANISM_TYPE mech_type,
486 IN const unsigned char * const source,
487 IN const size_t source_size,
488 OUT unsigned char * const target,
489 IN OUT size_t * const p_target_size
490);
491
497CK_RV
499 IN const pkcs11h_certificate_id_list_t cert_id_list
500);
501
516CK_RV
518 IN const pkcs11h_token_id_t token_id,
519 IN const unsigned method,
520 IN void * const user_data,
521 IN const unsigned mask_prompt,
522 OUT pkcs11h_certificate_id_list_t * const p_cert_id_issuers_list,
523 OUT pkcs11h_certificate_id_list_t * const p_cert_id_end_list
524);
525
538CK_RV
540 IN const unsigned method,
541 IN void * const user_data,
542 IN const unsigned mask_prompt,
543 OUT pkcs11h_certificate_id_list_t * const p_cert_id_issuers_list,
544 OUT pkcs11h_certificate_id_list_t * const p_cert_id_end_list
545);
546
547#ifdef __cplusplus
548}
549#endif
550
553#endif /* __PKCS11H_CERTIFICATE_H */
unsigned pkcs11h_certificate_getPromptMask(IN const pkcs11h_certificate_t certificate)
Extract user data out of certificate.
struct pkcs11h_certificate_id_s * pkcs11h_certificate_id_t
Certificate id reference.
Definition: pkcs11h-certificate.h:87
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_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_deserializeCertificateId(OUT pkcs11h_certificate_id_t *const p_certificate_id, IN const char *const sz)
Deserialize certificate_id out of string.
CK_RV pkcs11h_certificate_releaseSession(IN const pkcs11h_certificate_t certificate)
Releases session lock.
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.
void * pkcs11h_certificate_getUserData(IN const pkcs11h_certificate_t certificate)
Extract user data out of certificate.
CK_RV pkcs11h_certificate_freeCertificateIdList(IN const pkcs11h_certificate_id_list_t cert_id_list)
Free certificate_id list.
struct pkcs11h_certificate_s * pkcs11h_certificate_t
Certificate object.
Definition: pkcs11h-certificate.h:92
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_freeCertificateId(IN pkcs11h_certificate_id_t certificate_id)
Free certificate_id object.
void pkcs11h_certificate_setUserData(IN const pkcs11h_certificate_t certificate, IN void *const user_data)
Extract user data out of certificate.
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_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_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_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.
CK_RV pkcs11h_certificate_ensureCertificateAccess(IN const pkcs11h_certificate_t certificate)
Ensure certificate is accessible.
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.
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.
CK_RV pkcs11h_certificate_ensureKeyAccess(IN const pkcs11h_certificate_t certificate)
Ensure key is accessible.
CK_RV pkcs11h_certificate_duplicateCertificateId(OUT pkcs11h_certificate_id_t *const to, IN const pkcs11h_certificate_id_t from)
Duplicate certificate_id object.
struct pkcs11h_certificate_id_list_s * pkcs11h_certificate_id_list_t
Certificate id list.
Definition: pkcs11h-certificate.h:99
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.
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_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_freeCertificate(IN pkcs11h_certificate_t certificate)
Free certificate object.
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.
CK_RV pkcs11h_certificate_lockSession(IN const pkcs11h_certificate_t certificate)
Lock session for threded environment.
pkcs11-helper core.
Certificate id list.
Definition: pkcs11h-certificate.h:124
pkcs11h_certificate_id_list_t next
Definition: pkcs11h-certificate.h:126
pkcs11h_certificate_id_t certificate_id
Definition: pkcs11h-certificate.h:128
Certificate id reference.
Definition: pkcs11h-certificate.h:104
pkcs11h_token_id_t token_id
Definition: pkcs11h-certificate.h:106
char displayName[1024]
Definition: pkcs11h-certificate.h:109
unsigned char * certificate_blob
Definition: pkcs11h-certificate.h:116
size_t attrCKA_ID_size
Definition: pkcs11h-certificate.h:113
CK_BYTE_PTR attrCKA_ID
Definition: pkcs11h-certificate.h:111
size_t certificate_blob_size
Definition: pkcs11h-certificate.h:118
Token identifier.
Definition: pkcs11h-core.h:268

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