Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
yubihsm_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 YUBIHSM_PKCS11_H
18#define YUBIHSM_PKCS11_H
19
20#include "pkcs11y.h"
21#include "list.h"
22#include <openssl/evp.h>
23#include <sys/time.h>
24
25#define YUBIHSM_PKCS11_OP_BUFSIZE 4096
26#define MAX_ECDH_SESSION_KEYS 255
27#define ECDH_KEY_BUF_SIZE 128
28#define ECDH_KEY_TYPE 0x00FF
29
36
37#define SESSION_AUTHENTICATED \
38 (SESSION_AUTHENTICATED_RO | SESSION_AUTHENTICATED_RW)
39#define SESSION_NOT_AUTHENTICATED (SESSION_RESERVED_RO | SESSION_RESERVED_RW)
40
41typedef struct {
42 struct timeval tv;
43 bool filled;
46
57
64
65typedef struct {
66 EVP_MD_CTX *md_ctx; // Digest context
67 uint16_t key_id; // Key id
68 CK_ULONG key_len; // Length in bits
69 uint16_t sig_len; // Length in bytes
70} sign_info;
71
72typedef struct {
73 EVP_MD_CTX *md_ctx; // Digest context
74 CK_ULONG digest_len; // Length in bits
77
78typedef struct {
79 uint16_t key_id; // Key id
80 CK_ULONG key_len; // Length in bits
83
84typedef struct {
87
88typedef struct {
89 EVP_MD_CTX *md_ctx; // running hash
90 const EVP_MD *md; // digest used
91 int padding; // padding in the rsa case
92 unsigned long saltLen; // saltlen for rsa-pss
93 const EVP_MD *mgf1md; // mgf1 md used for rsa-pss
94 uint16_t key_id; // Key id
95 CK_ULONG key_len; // Length in bits
97
106
107typedef struct {
108 CK_MECHANISM_TYPE mechanism;
109 union {
110 struct {
111 uint8_t label[64]; // hash of OAEP label
112 unsigned int label_len; // length of the hashed label
114 } oaep;
115 struct {
117 yh_algorithm mgf1Algo;
118 } pss;
119 };
120} mechanism;
121
122typedef struct {
123 // The session key ID 0x00 ff 0001, 0x00 ff 0002, 0x00 ff 0003...etc
124 CK_OBJECT_HANDLE id;
128 size_t len;
132
140
141typedef struct {
143 CK_CREATEMUTEX create_mutex;
144 CK_DESTROYMUTEX destroy_mutex;
145 CK_LOCKMUTEX lock_mutex;
146 CK_UNLOCKMUTEX unlock_mutex;
147 void *mutex;
149
162
170
176
198
199#endif
unsigned long int CK_ULONG
Definition pkcs11.h:1194
unsigned short uint16_t
Definition stdint.h:125
unsigned char uint8_t
Definition stdint.h:124
Definition list.h:35
CK_ULONG key_len
uint16_t key_id
EVP_MD_CTX * md_ctx
CK_ULONG digest_len
size_t len
The length of the key.
CK_OBJECT_HANDLE id
uint16_t key_id
uint16_t current_object
bool only_private
size_t n_objects
uint16_t salt_len
yh_algorithm mgf1Algo
unsigned int label_len
CK_MECHANISM_TYPE mechanism
EVP_MD_CTX * md_ctx
uint16_t key_id
uint16_t sig_len
CK_ULONG key_len
uint16_t key_id
unsigned long saltLen
EVP_MD_CTX * md_ctx
const EVP_MD * md
CK_ULONG key_len
const EVP_MD * mgf1md
CK_UNLOCKMUTEX unlock_mutex
CK_DESTROYMUTEX destroy_mutex
CK_CREATEMUTEX create_mutex
yh_object_descriptor object
yubihsm_pkcs11_attribute sign
yubihsm_pkcs11_attribute decrypt
yubihsm_pkcs11_attribute wrap
yubihsm_pkcs11_attribute exportable
yubihsm_pkcs11_attribute derive
yubihsm_pkcs11_attribute verify
yubihsm_pkcs11_attribute encrypt
yubihsm_pkcs11_attribute unwrap
yubihsm_pkcs11_op_type type
yubihsm_pkcs11_op_info operation
yubihsm_pkcs11_slot * slot
yubihsm_pkcs11_session_state session_state
yh_connector * connector
yh_session * device_session
digest_info digest
find_info find
decrypt_info decrypt
verify_info verify
encrypt_info encrypt
sign_info sign
#define YH_MAX_ITEMS_COUNT
Max items the device may hold.
Definition yubihsm.h:103
#define YH_OBJ_LABEL_LEN
Max length of object labels.
Definition yubihsm.h:123
yh_algorithm
Definition yubihsm.h:390
#define YH_MAX_ALGORITHM_COUNT
Max number of algorithms defined here.
Definition yubihsm.h:383
char * label
ecdh_session_key ecdh_key
session operation mechanism mechanism
yubihsm_pkcs11_session_state
@ SESSION_AUTHENTICATED_RW
@ SESSION_AUTHENTICATED_RO
@ SESSION_RESERVED_RO
@ SESSION_RESERVED_RW
#define YUBIHSM_PKCS11_OP_BUFSIZE
#define ECDH_KEY_BUF_SIZE
yubihsm_pkcs11_attribute
@ ATTRIBUTE_NOT_SET
@ ATTRIBUTE_TRUE
@ ATTRIBUTE_FALSE
yubihsm_pkcs11_op_type
@ OPERATION_FIND
@ OPERATION_DIGEST
@ OPERATION_GEN
@ OPERATION_ENCRYPT
@ OPERATION_SIGN
@ OPERATION_NOOP
@ OPERATION_VERIFY
@ OPERATION_DECRYPT