Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
util_pkcs11.h
Go to the documentation of this file.
1/*
2 * Copyright 2015-2018 Yubico AB
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef UTIL_PKCS11_H
18#define UTIL_PKCS11_H
19
20#include <yubihsm.h>
21#include <pkcs11y.h>
22
23#include "yubihsm_pkcs11.h"
24
28
29bool get_mechanism_info(yubihsm_pkcs11_slot *slot, CK_MECHANISM_TYPE type,
31
32bool parse_hex(CK_UTF8CHAR_PTR hex, CK_ULONG hex_len, uint8_t *parsed);
33
34void destroy_session(yubihsm_pkcs11_context *ctx, CK_SESSION_HANDLE hSession);
35
36CK_RV get_attribute(CK_ATTRIBUTE_TYPE type, yh_object_descriptor *object,
39CK_RV get_attribute_ecsession_key(CK_ATTRIBUTE_TYPE type, ecdh_session_key *key,
41
44 CK_OBJECT_HANDLE objectHandle);
45
47 CK_OBJECT_HANDLE objHandle);
48
51
57 uint8_t *signature, uint16_t *signature_len);
59
67 uint8_t *signature, uint16_t signature_len);
69
77 uint8_t *plaintext, uint16_t *plaintext_len);
79
85 uint8_t *ciphertext, uint16_t *ciphertext_len);
86
92CK_RV perform_digest(yubihsm_pkcs11_op_info *op_info, uint8_t *digest,
95CK_ULONG get_digest_bytelength(CK_MECHANISM_TYPE m);
96
99
100bool is_RSA_sign_mechanism(CK_MECHANISM_TYPE m);
101bool is_RSA_decrypt_mechanism(CK_MECHANISM_TYPE m);
102bool is_hashed_mechanism(CK_MECHANISM_TYPE m);
103bool is_PKCS1v1_5_sign_mechanism(CK_MECHANISM_TYPE m);
104bool is_ECDSA_sign_mechanism(CK_MECHANISM_TYPE m);
105bool is_PSS_sign_mechanism(CK_MECHANISM_TYPE m);
106bool is_HMAC_sign_mechanism(CK_MECHANISM_TYPE m);
107
109bool add_connectors(yubihsm_pkcs11_context *ctx, int n_connectors,
110 char **connector_names, yh_connector **connectors);
113CK_RV get_session(yubihsm_pkcs11_context *ctx, CK_SESSION_HANDLE hSession,
114 yubihsm_pkcs11_session **session, int session_state);
121
129 bool generate);
132 bool generate);
133
139
145
146int parse_id_value(void *value, CK_ULONG len);
147
148CK_RV populate_template(int type, void *object, CK_ATTRIBUTE_PTR pTemplate,
150
151CK_RV validate_derive_key_attribute(CK_ATTRIBUTE_TYPE type, void *value);
152
153#endif
CK_SESSION_HANDLE session
int * count
ck_session_handle_t * CK_SESSION_HANDLE_PTR
Definition pkcs11.h:1227
ck_mechanism_type_t * CK_MECHANISM_TYPE_PTR
Definition pkcs11.h:1242
CK_ULONG * CK_ULONG_PTR
Definition pkcs11.h:1199
#define value
Definition pkcs11.h:157
unsigned long int CK_ULONG
Definition pkcs11.h:1194
CK_BYTE * CK_BYTE_PTR
Definition pkcs11.h:1196
void * CK_VOID_PTR
Definition pkcs11.h:1200
CK_UTF8CHAR * CK_UTF8CHAR_PTR
Definition pkcs11.h:1198
unsigned short uint16_t
Definition stdint.h:125
unsigned char uint8_t
Definition stdint.h:124
bool is_PKCS1v1_5_sign_mechanism(CK_MECHANISM_TYPE m)
bool is_ECDSA_sign_mechanism(CK_MECHANISM_TYPE m)
CK_RV set_template_attribute(yubihsm_pkcs11_attribute *attribute, void *value)
CK_RV get_mechanism_list(yubihsm_pkcs11_slot *slot, CK_MECHANISM_TYPE_PTR pMechanismList, CK_ULONG_PTR count)
Definition util_pkcs11.c:73
bool add_connectors(yubihsm_pkcs11_context *ctx, int n_connectors, char **connector_names, yh_connector **connectors)
bool decrypt_mechanism_cleanup(yubihsm_pkcs11_op_info *op_info)
bool verify_mechanism_cleanup(yubihsm_pkcs11_op_info *op_info)
CK_RV populate_template(int type, void *object, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount, yh_session *session)
bool check_encrypt_mechanism(yubihsm_pkcs11_slot *slot, CK_MECHANISM_PTR pMechanism)
CK_RV perform_encrypt(yh_session *session, yubihsm_pkcs11_op_info *op_info, uint8_t *plaintext, uint16_t *plaintext_len)
CK_RV parse_ec_generate_template(CK_ATTRIBUTE_PTR pPublicKeyTemplate, CK_ULONG ulPublicKeyAttributeCount, CK_ATTRIBUTE_PTR pPrivateKeyTemplate, CK_ULONG ulPrivateKeyAttributeCount, yubihsm_pkcs11_object_template *template)
CK_RV apply_verify_mechanism_init(yubihsm_pkcs11_op_info *op_info)
CK_RV perform_digest(yubihsm_pkcs11_op_info *op_info, uint8_t *digest, uint16_t *digest_len)
bool is_PSS_sign_mechanism(CK_MECHANISM_TYPE m)
void release_slot(yubihsm_pkcs11_context *ctx, yubihsm_pkcs11_slot *slot)
CK_RV parse_rsa_generate_template(CK_ATTRIBUTE_PTR pPublicKeyTemplate, CK_ULONG ulPublicKeyAttributeCount, CK_ATTRIBUTE_PTR pPrivateKeyTemplate, CK_ULONG ulPrivateKeyAttributeCount, yubihsm_pkcs11_object_template *template)
bool is_HMAC_sign_mechanism(CK_MECHANISM_TYPE m)
bool is_hashed_mechanism(CK_MECHANISM_TYPE m)
CK_RV get_session(yubihsm_pkcs11_context *ctx, CK_SESSION_HANDLE hSession, yubihsm_pkcs11_session **session, int session_state)
bool parse_hex(CK_UTF8CHAR_PTR hex, CK_ULONG hex_len, uint8_t *parsed)
CK_RV apply_digest_mechanism_init(yubihsm_pkcs11_op_info *op_info)
CK_RV perform_signature(yh_session *session, yubihsm_pkcs11_op_info *op_info, uint8_t *signature, uint16_t *signature_len)
CK_RV validate_derive_key_attribute(CK_ATTRIBUTE_TYPE type, void *value)
CK_RV apply_encrypt_mechanism_update(yubihsm_pkcs11_op_info *op_info, CK_BYTE_PTR in, CK_ULONG in_len)
CK_RV get_attribute_ecsession_key(CK_ATTRIBUTE_TYPE type, ecdh_session_key *key, CK_VOID_PTR value, CK_ULONG_PTR length)
bool check_decrypt_mechanism(yubihsm_pkcs11_slot *slot, CK_MECHANISM_PTR pMechanism)
bool check_digest_mechanism(CK_MECHANISM_PTR pMechanism)
CK_RV parse_wrap_template(CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount, yubihsm_pkcs11_object_template *template, bool generate)
int parse_id_value(void *value, CK_ULONG len)
CK_RV parse_ec_template(CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount, yubihsm_pkcs11_object_template *template)
bool sign_mechanism_cleanup(yubihsm_pkcs11_op_info *op_info)
bool create_session(yubihsm_pkcs11_slot *slot, CK_FLAGS flags, CK_SESSION_HANDLE_PTR phSession)
CK_RV apply_sign_mechanism_finalize(yubihsm_pkcs11_op_info *op_info)
yubihsm_pkcs11_slot * get_slot(yubihsm_pkcs11_context *ctx, CK_ULONG id)
CK_RV parse_hmac_template(CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount, yubihsm_pkcs11_object_template *template, bool generate)
bool is_RSA_sign_mechanism(CK_MECHANISM_TYPE m)
CK_RV apply_sign_mechanism_update(yubihsm_pkcs11_op_info *op_info, CK_BYTE_PTR in, CK_ULONG in_len)
void set_native_locking(yubihsm_pkcs11_context *ctx)
CK_RV apply_decrypt_mechanism_update(yubihsm_pkcs11_op_info *op_info, CK_BYTE_PTR in, CK_ULONG in_len)
bool check_wrap_mechanism(yubihsm_pkcs11_slot *slot, CK_MECHANISM_PTR pMechanism)
bool delete_session(yubihsm_pkcs11_context *ctx, CK_SESSION_HANDLE_PTR phSession)
CK_RV apply_digest_mechanism_update(yubihsm_pkcs11_op_info *op_info, CK_BYTE_PTR in, CK_ULONG in_len)
bool check_verify_mechanism(yubihsm_pkcs11_slot *slot, CK_MECHANISM_PTR pMechanism)
bool is_RSA_decrypt_mechanism(CK_MECHANISM_TYPE m)
CK_RV apply_verify_mechanism_finalize(yubihsm_pkcs11_op_info *op_info)
yubihsm_pkcs11_object_desc * get_object_desc(yh_session *session, yubihsm_pkcs11_object_desc *objects, CK_OBJECT_HANDLE objectHandle)
CK_RV apply_decrypt_mechanism_init(yubihsm_pkcs11_op_info *op_info)
CK_RV apply_digest_mechanism_finalize(yubihsm_pkcs11_op_info *op_info)
bool get_mechanism_info(yubihsm_pkcs11_slot *slot, CK_MECHANISM_TYPE type, CK_MECHANISM_INFO_PTR pInfo)
CK_RV perform_decrypt(yh_session *session, yubihsm_pkcs11_op_info *op_info, uint8_t *ciphertext, uint16_t *ciphertext_len)
CK_RV apply_decrypt_mechanism_finalize(yubihsm_pkcs11_op_info *op_info)
void release_session(yubihsm_pkcs11_context *ctx, yubihsm_pkcs11_session *session)
CK_RV perform_verify(yh_session *session, yubihsm_pkcs11_op_info *op_info, uint8_t *signature, uint16_t signature_len)
CK_RV parse_rsa_template(CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount, yubihsm_pkcs11_object_template *template)
void delete_object_from_cache(yubihsm_pkcs11_object_desc *objects, CK_OBJECT_HANDLE objHandle)
void destroy_session(yubihsm_pkcs11_context *ctx, CK_SESSION_HANDLE hSession)
CK_ULONG get_digest_bytelength(CK_MECHANISM_TYPE m)
CK_RV get_attribute(CK_ATTRIBUTE_TYPE type, yh_object_descriptor *object, CK_VOID_PTR value, CK_ULONG_PTR length, yh_session *session)
CK_RV apply_sign_mechanism_init(yubihsm_pkcs11_op_info *op_info)
bool digest_mechanism_cleanup(yubihsm_pkcs11_op_info *op_info)
CK_RV apply_verify_mechanism_update(yubihsm_pkcs11_op_info *op_info, CK_BYTE_PTR in, CK_ULONG in_len)
bool check_sign_mechanism(yubihsm_pkcs11_slot *slot, CK_MECHANISM_PTR pMechanism)
yubihsm_pkcs11_slot * slot
CK_SLOT_ID CK_SLOT_INFO_PTR pInfo
CK_SESSION_HANDLE CK_MECHANISM_PTR CK_ATTRIBUTE_PTR CK_ULONG CK_ATTRIBUTE_PTR CK_ULONG ulPrivateKeyAttributeCount
CK_SESSION_HANDLE hSession
CK_SESSION_HANDLE CK_ATTRIBUTE_PTR CK_ULONG ulCount
CK_SLOT_ID CK_FLAGS CK_VOID_PTR CK_NOTIFY CK_SESSION_HANDLE_PTR phSession
size_t len
CK_SLOT_ID CK_MECHANISM_TYPE_PTR pMechanismList
CK_SESSION_HANDLE CK_MECHANISM_PTR CK_ATTRIBUTE_PTR CK_ULONG CK_ATTRIBUTE_PTR pPrivateKeyTemplate
CK_SESSION_HANDLE CK_ATTRIBUTE_PTR pTemplate
CK_SESSION_HANDLE CK_MECHANISM_PTR CK_ATTRIBUTE_PTR CK_ULONG ulPublicKeyAttributeCount
session operation op digest digest_len
CK_SESSION_HANDLE CK_MECHANISM_PTR pMechanism
CK_SESSION_HANDLE CK_MECHANISM_PTR CK_ATTRIBUTE_PTR pPublicKeyTemplate
pInfo flags
size_t in_len
yubihsm_pkcs11_attribute