pkcs11h-certificate.h
Go to the documentation of this file.
/*
* Copyright (c) 2005-2018 Alon Bar-Lev <alon.barlev@gmail.com>
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, or the BSD license.
*
* GNU General Public License (GPL) Version 2
* ===========================================
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program (see the file COPYING.GPL included with this
* distribution); if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* BSD License
* ============
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* o Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* o Neither the name of the Alon Bar-Lev nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __PKCS11H_CERTIFICATE_H
#define __PKCS11H_CERTIFICATE_H
#include <pkcs11-helper-1.0/pkcs11h-core.h>
#if defined(__cplusplus)
extern "C" {
#endif
struct pkcs11h_certificate_id_s;
struct pkcs11h_certificate_s;
typedef struct pkcs11h_certificate_id_s *pkcs11h_certificate_id_t;
typedef struct pkcs11h_certificate_s *pkcs11h_certificate_t;
struct pkcs11h_certificate_id_list_s;
typedef struct pkcs11h_certificate_id_list_s *pkcs11h_certificate_id_list_t;
struct pkcs11h_certificate_id_s {
pkcs11h_token_id_t token_id;
char displayName[1024];
CK_BYTE_PTR attrCKA_ID;
size_t attrCKA_ID_size;
unsigned char *certificate_blob;
size_t certificate_blob_size;
};
struct pkcs11h_certificate_id_list_s {
pkcs11h_certificate_id_list_t next;
pkcs11h_certificate_id_t certificate_id;
};
CK_RV
pkcs11h_certificate_freeCertificateId (
IN pkcs11h_certificate_id_t certificate_id
);
CK_RV
pkcs11h_certificate_duplicateCertificateId (
OUT pkcs11h_certificate_id_t * const to,
IN const pkcs11h_certificate_id_t from
);
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
);
CK_RV
pkcs11h_certificate_freeCertificate (
IN pkcs11h_certificate_t certificate
);
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
);
unsigned
pkcs11h_certificate_getPromptMask (
IN const pkcs11h_certificate_t certificate
);
void
pkcs11h_certificate_setPromptMask (
IN const pkcs11h_certificate_t certificate,
IN const unsigned mask_prompt
);
void *
pkcs11h_certificate_getUserData (
IN const pkcs11h_certificate_t certificate
);
void
pkcs11h_certificate_setUserData (
IN const pkcs11h_certificate_t certificate,
IN void * const user_data
);
CK_RV
pkcs11h_certificate_getCertificateId (
IN const pkcs11h_certificate_t certificate,
OUT pkcs11h_certificate_id_t * const p_certificate_id
);
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
);
CK_RV
pkcs11h_certificate_serializeCertificateId (
OUT char * const sz,
IN OUT size_t *max,
IN const pkcs11h_certificate_id_t certificate_id
);
CK_RV
pkcs11h_certificate_deserializeCertificateId (
OUT pkcs11h_certificate_id_t * const p_certificate_id,
IN const char * const sz
);
CK_RV
pkcs11h_certificate_ensureCertificateAccess (
IN const pkcs11h_certificate_t certificate
);
CK_RV
pkcs11h_certificate_ensureKeyAccess (
IN const pkcs11h_certificate_t certificate
);
CK_RV
pkcs11h_certificate_lockSession (
IN const pkcs11h_certificate_t certificate
);
CK_RV
pkcs11h_certificate_releaseSession (
IN const pkcs11h_certificate_t certificate
);
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
);
CK_RV
pkcs11h_certificate_sign_ex (
IN const pkcs11h_certificate_t certificate,
IN const CK_MECHANISM * const mech,
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
);
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
);
CK_RV
pkcs11h_certificate_signRecover_ex (
IN const pkcs11h_certificate_t certificate,
IN const CK_MECHANISM * const mech,
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
);
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
);
CK_RV
pkcs11h_certificate_decrypt_ex (
IN const pkcs11h_certificate_t certificate,
IN const CK_MECHANISM * const mech,
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
);
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
);
CK_RV
pkcs11h_certificate_unwrap_ex (
IN const pkcs11h_certificate_t certificate,
IN const CK_MECHANISM * const mech,
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
);
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
);
CK_RV
pkcs11h_certificate_signAny_ex (
IN const pkcs11h_certificate_t certificate,
IN const CK_MECHANISM * const mech,
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
);
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
);
CK_RV
pkcs11h_certificate_decryptAny_ex (
IN const pkcs11h_certificate_t certificate,
IN const CK_MECHANISM * const mech,
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
);
CK_RV
pkcs11h_certificate_freeCertificateIdList (
IN const pkcs11h_certificate_id_list_t cert_id_list
);
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
);
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
);
#ifdef __cplusplus
}
#endif
#endif /* __PKCS11H_CERTIFICATE_H */
pkcs11h_certificate_getPromptMask
unsigned pkcs11h_certificate_getPromptMask(IN const pkcs11h_certificate_t certificate)
Extract user data out of certificate.
pkcs11h_certificate_id_t
struct pkcs11h_certificate_id_s * pkcs11h_certificate_id_t
Certificate id reference.
Definition pkcs11h-certificate.h:87
pkcs11h_certificate_enumCertificateIds
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.
pkcs11h_certificate_signRecover_ex
CK_RV pkcs11h_certificate_signRecover_ex(IN const pkcs11h_certificate_t certificate, IN const CK_MECHANISM *const mech, 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 with mechanism parameters.
pkcs11h_certificate_unwrap_ex
CK_RV pkcs11h_certificate_unwrap_ex(IN const pkcs11h_certificate_t certificate, IN const CK_MECHANISM *const mech, 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 with mechanism parameters.
pkcs11h_certificate_signAny
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 with method determined by key attributes.
pkcs11h_certificate_decryptAny_ex
CK_RV pkcs11h_certificate_decryptAny_ex(IN const pkcs11h_certificate_t certificate, IN const CK_MECHANISM *const mech, 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 with method determined by key attributes.
pkcs11h_certificate_deserializeCertificateId
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.
pkcs11h_certificate_releaseSession
CK_RV pkcs11h_certificate_releaseSession(IN const pkcs11h_certificate_t certificate)
Releases session lock.
pkcs11h_certificate_unwrap
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.
pkcs11h_certificate_getUserData
void * pkcs11h_certificate_getUserData(IN const pkcs11h_certificate_t certificate)
Extract user data out of certificate.
pkcs11h_certificate_freeCertificateIdList
CK_RV pkcs11h_certificate_freeCertificateIdList(IN const pkcs11h_certificate_id_list_t cert_id_list)
Free certificate_id list.
pkcs11h_certificate_t
struct pkcs11h_certificate_s * pkcs11h_certificate_t
Certificate object.
Definition pkcs11h-certificate.h:92
pkcs11h_certificate_create
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.
pkcs11h_certificate_freeCertificateId
CK_RV pkcs11h_certificate_freeCertificateId(IN pkcs11h_certificate_id_t certificate_id)
Free certificate_id object.
pkcs11h_certificate_setUserData
void pkcs11h_certificate_setUserData(IN const pkcs11h_certificate_t certificate, IN void *const user_data)
Extract user data out of certificate.
pkcs11h_certificate_setPromptMask
void pkcs11h_certificate_setPromptMask(IN const pkcs11h_certificate_t certificate, IN const unsigned mask_prompt)
Extract user data out of certificate.
pkcs11h_certificate_serializeCertificateId
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.
pkcs11h_certificate_getCertificateBlob
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.
pkcs11h_certificate_signRecover
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.
pkcs11h_certificate_ensureCertificateAccess
CK_RV pkcs11h_certificate_ensureCertificateAccess(IN const pkcs11h_certificate_t certificate)
Ensure certificate is accessible.
pkcs11h_certificate_getCertificateId
CK_RV pkcs11h_certificate_getCertificateId(IN const pkcs11h_certificate_t certificate, OUT pkcs11h_certificate_id_t *const p_certificate_id)
Get certificate id object out of a certificate.
pkcs11h_certificate_decryptAny
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 with method determined by key attributes.
pkcs11h_certificate_ensureKeyAccess
CK_RV pkcs11h_certificate_ensureKeyAccess(IN const pkcs11h_certificate_t certificate)
Ensure key is accessible.
pkcs11h_certificate_duplicateCertificateId
CK_RV pkcs11h_certificate_duplicateCertificateId(OUT pkcs11h_certificate_id_t *const to, IN const pkcs11h_certificate_id_t from)
Duplicate certificate_id object.
pkcs11h_certificate_signAny_ex
CK_RV pkcs11h_certificate_signAny_ex(IN const pkcs11h_certificate_t certificate, IN const CK_MECHANISM *const mech, 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 with method determined by key attributes.
pkcs11h_certificate_id_list_t
struct pkcs11h_certificate_id_list_s * pkcs11h_certificate_id_list_t
Certificate id list.
Definition pkcs11h-certificate.h:99
pkcs11h_certificate_sign
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.
pkcs11h_certificate_setCertificateIdCertificateBlob
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.
pkcs11h_certificate_enumTokenCertificateIds
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.
pkcs11h_certificate_freeCertificate
CK_RV pkcs11h_certificate_freeCertificate(IN pkcs11h_certificate_t certificate)
Free certificate object.
pkcs11h_certificate_decrypt_ex
CK_RV pkcs11h_certificate_decrypt_ex(IN const pkcs11h_certificate_t certificate, IN const CK_MECHANISM *const mech, 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 with mechanism parameters.
pkcs11h_certificate_sign_ex
CK_RV pkcs11h_certificate_sign_ex(IN const pkcs11h_certificate_t certificate, IN const CK_MECHANISM *const mech, 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 with mechanism parameters.
pkcs11h_certificate_decrypt
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_lockSession
CK_RV pkcs11h_certificate_lockSession(IN const pkcs11h_certificate_t certificate)
Lock session for threaded environment.
pkcs11h_token_id_t
struct pkcs11h_token_id_s * pkcs11h_token_id_t
Token identifier.
Definition pkcs11h-core.h:406
pkcs11h-core.h
pkcs11-helper core.
pkcs11h_certificate_id_list_s
Certificate id list.
Definition pkcs11h-certificate.h:124
pkcs11h_certificate_id_list_s::next
pkcs11h_certificate_id_list_t next
Definition pkcs11h-certificate.h:126
pkcs11h_certificate_id_list_s::certificate_id
pkcs11h_certificate_id_t certificate_id
Definition pkcs11h-certificate.h:128
pkcs11h_certificate_id_s
Certificate id reference.
Definition pkcs11h-certificate.h:104
pkcs11h_certificate_id_s::token_id
pkcs11h_token_id_t token_id
Definition pkcs11h-certificate.h:106
pkcs11h_certificate_id_s::displayName
char displayName[1024]
Definition pkcs11h-certificate.h:109
pkcs11h_certificate_id_s::certificate_blob
unsigned char * certificate_blob
Definition pkcs11h-certificate.h:116
pkcs11h_certificate_id_s::attrCKA_ID_size
size_t attrCKA_ID_size
Definition pkcs11h-certificate.h:113
pkcs11h_certificate_id_s::attrCKA_ID
CK_BYTE_PTR attrCKA_ID
Definition pkcs11h-certificate.h:111
pkcs11h_certificate_id_s::certificate_blob_size
size_t certificate_blob_size
Definition pkcs11h-certificate.h:118

pkcs11-helper, Copyright (C) Alon Bar-Lev <alon.barlev@gmail.com> |