| 1 |
#ifndef AWS_IO_PKCS11_PRIVATE_H |
| 2 |
#define AWS_IO_PKCS11_PRIVATE_H |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
#include <aws/io/tls_channel_handler.h> |
| 9 |
|
| 10 |
#include "pkcs11/v2.40/pkcs11.h" |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
struct aws_pkcs11_lib; |
| 24 |
struct aws_pkcs11_tls_key_handler; |
| 25 |
struct aws_string; |
| 26 |
|
| 27 |
AWS_EXTERN_C_BEGIN |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
AWS_IO_API |
| 34 |
const char *aws_pkcs11_ckr_str(CK_RV rv); |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
AWS_IO_API |
| 41 |
CK_FUNCTION_LIST *aws_pkcs11_lib_get_function_list(struct aws_pkcs11_lib *pkcs11_lib); |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
AWS_IO_API |
| 51 |
int aws_pkcs11_lib_find_slot_with_token( |
| 52 |
struct aws_pkcs11_lib *pkcs11_lib, |
| 53 |
const uint64_t *match_slot_id, |
| 54 |
const struct aws_string *match_token_label, |
| 55 |
CK_SLOT_ID *out_slot_id); |
| 56 |
|
| 57 |
AWS_IO_API |
| 58 |
int aws_pkcs11_lib_open_session( |
| 59 |
struct aws_pkcs11_lib *pkcs11_lib, |
| 60 |
CK_SLOT_ID slot_id, |
| 61 |
CK_SESSION_HANDLE *out_session_handle); |
| 62 |
|
| 63 |
AWS_IO_API |
| 64 |
void aws_pkcs11_lib_close_session(struct aws_pkcs11_lib *pkcs11_lib, CK_SESSION_HANDLE session_handle); |
| 65 |
|
| 66 |
AWS_IO_API |
| 67 |
int aws_pkcs11_lib_login_user( |
| 68 |
struct aws_pkcs11_lib *pkcs11_lib, |
| 69 |
CK_SESSION_HANDLE session_handle, |
| 70 |
const struct aws_string *optional_user_pin); |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
AWS_IO_API |
| 79 |
int aws_pkcs11_lib_find_private_key( |
| 80 |
struct aws_pkcs11_lib *pkcs11_lib, |
| 81 |
CK_SESSION_HANDLE session_handle, |
| 82 |
const struct aws_string *match_label, |
| 83 |
CK_OBJECT_HANDLE *out_key_handle, |
| 84 |
CK_KEY_TYPE *out_key_type); |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
AWS_IO_API |
| 92 |
int aws_pkcs11_lib_decrypt( |
| 93 |
struct aws_pkcs11_lib *pkcs11_lib, |
| 94 |
CK_SESSION_HANDLE session_handle, |
| 95 |
CK_OBJECT_HANDLE key_handle, |
| 96 |
CK_KEY_TYPE key_type, |
| 97 |
struct aws_byte_cursor encrypted_data, |
| 98 |
struct aws_allocator *allocator, |
| 99 |
struct aws_byte_buf *out_data); |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
AWS_IO_API |
| 107 |
int aws_pkcs11_lib_sign( |
| 108 |
struct aws_pkcs11_lib *pkcs11_lib, |
| 109 |
CK_SESSION_HANDLE session_handle, |
| 110 |
CK_OBJECT_HANDLE key_handle, |
| 111 |
CK_KEY_TYPE key_type, |
| 112 |
struct aws_byte_cursor digest_data, |
| 113 |
struct aws_allocator *allocator, |
| 114 |
enum aws_tls_hash_algorithm digest_alg, |
| 115 |
enum aws_tls_signature_algorithm signature_alg, |
| 116 |
struct aws_byte_buf *out_signature); |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
AWS_IO_API |
| 123 |
int aws_get_prefix_to_rsa_sig(enum aws_tls_hash_algorithm digest_alg, struct aws_byte_cursor *out_prefix); |
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
AWS_IO_API |
| 131 |
int aws_pkcs11_asn1_enc_ubigint(struct aws_byte_buf *const buffer, struct aws_byte_cursor bigint); |
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
AWS_IO_API |
| 141 |
struct aws_custom_key_op_handler *aws_pkcs11_tls_op_handler_new( |
| 142 |
struct aws_allocator *allocator, |
| 143 |
struct aws_pkcs11_lib *pkcs11_lib, |
| 144 |
const struct aws_byte_cursor *user_pin, |
| 145 |
const struct aws_byte_cursor *match_token_label, |
| 146 |
const struct aws_byte_cursor *match_private_key_label, |
| 147 |
const uint64_t *match_slot_id); |
| 148 |
|
| 149 |
AWS_EXTERN_C_END |
| 150 |
#endif |