|
libp11 0.4.21
|
libp11 header file More...
#include "p11_ver.h"#include "p11_err.h"#include <openssl/bio.h>#include <openssl/err.h>#include <openssl/bn.h>#include <openssl/rsa.h>#include <openssl/x509.h>#include <openssl/evp.h>Go to the source code of this file.
Data Structures | |
| struct | PKCS11_key_st |
| PKCS11 key object (public or private). More... | |
| struct | PKCS11_cert_st |
| PKCS11 certificate object. More... | |
| struct | PKCS11_token_st |
| PKCS11 token: smart card or USB key. More... | |
| struct | PKCS11_slot_st |
| PKCS11 slot: card reader. More... | |
| struct | PKCS11_ctx_st |
| PKCS11 context. More... | |
| struct | PKCS11_ec_kgen_st |
| struct | PKCS11_nid_kgen_st |
| struct | PKCS11_rsa_kgen_st |
| struct | PKCS11_params |
| struct | PKCS11_kgen_attrs_st |
Typedefs | |
| typedef struct pkcs11_object_private | PKCS11_OBJECT_private |
| typedef struct pkcs11_slot_private | PKCS11_SLOT_private |
| typedef struct pkcs11_ctx_private | PKCS11_CTX_private |
| typedef struct PKCS11_key_st | PKCS11_KEY |
| typedef struct PKCS11_cert_st | PKCS11_CERT |
| typedef struct PKCS11_token_st | PKCS11_TOKEN |
| typedef struct PKCS11_slot_st | PKCS11_SLOT |
| typedef struct PKCS11_ctx_st | PKCS11_CTX |
| typedef struct PKCS11_ec_kgen_st | PKCS11_EC_KGEN |
| typedef struct PKCS11_nid_kgen_st | PKCS11_NID_KGEN |
| typedef struct PKCS11_rsa_kgen_st | PKCS11_RSA_KGEN |
| typedef struct PKCS11_params | PKCS11_params |
| typedef struct PKCS11_kgen_attrs_st | PKCS11_KGEN_ATTRS |
| typedef void(*) | PKCS11_VLOG_A_CB(int, const char *, va_list) |
| PKCS11 ASCII logging callback. | |
| typedef int(*) | PKCS11_PKEY_CALLBACK(PKCS11_KEY *, EVP_PKEY *, void *) |
| Callback invoked for an EVP_PKEY returned by libp11. | |
Functions | |
| int | ERR_load_CKR_strings (void) |
| void | ERR_unload_CKR_strings (void) |
| void | ERR_CKR_error (int function, int reason, char *file, int line) |
| int | ERR_get_CKR_code (void) |
| PKCS11_CTX * | PKCS11_CTX_new_ex (int flags) |
| Create a new libp11 context with specified flags. | |
| PKCS11_CTX * | PKCS11_CTX_new (void) |
| Create a new libp11 context. | |
| int | PKCS11_CTX_set_pkey_callback (PKCS11_CTX *ctx, int callback_type, PKCS11_PKEY_CALLBACK callback, void *user_data) |
| Set a callback for EVP_PKEY objects returned by this context. | |
| void | PKCS11_CTX_init_args (PKCS11_CTX *ctx, const char *init_args) |
| Specify any private PKCS#11 module initialization args, if necessary. | |
| int | PKCS11_CTX_load (PKCS11_CTX *ctx, const char *ident) |
| Load a PKCS#11 module. | |
| void | PKCS11_CTX_unload (PKCS11_CTX *ctx) |
| Unload a PKCS#11 module. | |
| void | PKCS11_CTX_free (PKCS11_CTX *ctx) |
| Free a libp11 context. | |
| int | PKCS11_open_session (PKCS11_SLOT *slot, int rw) |
| Open a session in RO or RW mode. | |
| int | PKCS11_enumerate_slots (PKCS11_CTX *ctx, PKCS11_SLOT **slotsp, unsigned int *nslotsp) |
| Get a list of all slots. | |
| int | PKCS11_update_slots (PKCS11_CTX *ctx, PKCS11_SLOT **slotsp, unsigned int *nslotsp) |
| Get or update a list of all slots. | |
| unsigned long | PKCS11_get_slotid_from_slot (PKCS11_SLOT *slotp) |
| Get the slot_id from a slot as it is stored in private. | |
| void | PKCS11_release_all_slots (PKCS11_CTX *ctx, PKCS11_SLOT *slots, unsigned int nslots) |
| Free the list of slots allocated by PKCS11_enumerate_slots(). | |
| PKCS11_SLOT * | PKCS11_find_token (PKCS11_CTX *ctx, PKCS11_SLOT *slots, unsigned int nslots) |
| Find the first slot with a token. | |
| PKCS11_SLOT * | PKCS11_find_next_token (PKCS11_CTX *ctx, PKCS11_SLOT *slots, unsigned int nslots, PKCS11_SLOT *slot) |
| Find the next slot with a token. | |
| int | PKCS11_is_logged_in (PKCS11_SLOT *slot, int so, int *res) |
| Check if user is already authenticated to a card. | |
| int | PKCS11_login (PKCS11_SLOT *slot, int so, const char *pin) |
| Authenticate to the card. | |
| int | PKCS11_logout (PKCS11_SLOT *slot) |
| De-authenticate from the card. | |
| int | PKCS11_enumerate_keys (PKCS11_TOKEN *, PKCS11_KEY **, unsigned int *) |
| int | PKCS11_enumerate_keys_ext (PKCS11_TOKEN *, const PKCS11_KEY *, PKCS11_KEY **, unsigned int *) |
| int | PKCS11_remove_key (PKCS11_KEY *) |
| int | PKCS11_enumerate_public_keys (PKCS11_TOKEN *, PKCS11_KEY **, unsigned int *) |
| int | PKCS11_enumerate_public_keys_ext (PKCS11_TOKEN *, const PKCS11_KEY *, PKCS11_KEY **, unsigned int *) |
| int | PKCS11_get_key_type (PKCS11_KEY *) |
| EVP_PKEY * | PKCS11_get_private_key (PKCS11_KEY *key) |
| Returns a EVP_PKEY object for the private key. | |
| EVP_PKEY * | PKCS11_get_public_key (PKCS11_KEY *key) |
| Returns a EVP_PKEY object with the public key. | |
| PKCS11_CERT * | PKCS11_find_certificate (PKCS11_KEY *) |
| PKCS11_KEY * | PKCS11_find_key (PKCS11_CERT *) |
| int | PKCS11_enumerate_certs (PKCS11_TOKEN *, PKCS11_CERT **, unsigned int *) |
| int | PKCS11_enumerate_certs_ext (PKCS11_TOKEN *, const PKCS11_CERT *, PKCS11_CERT **, unsigned int *) |
| int | PKCS11_remove_certificate (PKCS11_CERT *) |
| int | PKCS11_set_ui_method (PKCS11_CTX *ctx, UI_METHOD *ui_method, void *ui_user_data) |
| int | PKCS11_init_token (PKCS11_TOKEN *token, const char *pin, const char *label) |
| Initialize a token. | |
| int | PKCS11_init_pin (PKCS11_TOKEN *token, const char *pin) |
| Initialize the user PIN on a token. | |
| int | PKCS11_change_pin (PKCS11_SLOT *slot, const char *old_pin, const char *new_pin) |
| Change the currently used (either USER or SO) PIN on a token. | |
| int | PKCS11_store_private_key (PKCS11_TOKEN *token, EVP_PKEY *pk, char *label, unsigned char *id, size_t id_len) |
| Store private key on a token. | |
| int | PKCS11_store_public_key (PKCS11_TOKEN *token, EVP_PKEY *pk, char *label, unsigned char *id, size_t id_len) |
| Store public key on a token. | |
| int | PKCS11_store_certificate (PKCS11_TOKEN *token, X509 *x509, char *label, unsigned char *id, size_t id_len, PKCS11_CERT **ret_cert) |
| Store certificate on a token. | |
| int | PKCS11_seed_random (PKCS11_SLOT *slot, const unsigned char *s, unsigned int s_len) |
| int | PKCS11_generate_random (PKCS11_SLOT *slot, unsigned char *r, unsigned int r_len) |
| RSA_METHOD * | PKCS11_get_rsa_method (void) |
| void * | PKCS11_get_ec_key_method (void) |
| ECDSA_METHOD * | PKCS11_get_ecdsa_method (void) |
| ECDH_METHOD * | PKCS11_get_ecdh_method (void) |
| int | PKCS11_pkey_meths (ENGINE *e, EVP_PKEY_METHOD **pmeth, const int **nids, int nid) |
| Return supported key types or create a legacy OpenSSL pkey method. | |
| void | ERR_load_PKCS11_strings (void) |
| Load PKCS11 error strings. | |
| int | PKCS11_keygen (PKCS11_TOKEN *token, PKCS11_KGEN_ATTRS *kgen_attrs) |
| Generate key pair on the token. | |
| int | PKCS11_generate_key (PKCS11_TOKEN *token, int algorithm, unsigned int bits_or_nid, char *label, unsigned char *id, size_t id_len) |
| Generate a private key on the token. | |
| int | PKCS11_generate_key_ext (PKCS11_TOKEN *token, int algorithm, unsigned int bits_or_nid, char *label, unsigned char *id, size_t id_len, PKCS11_KEY **ret_key) |
| int | PKCS11_get_key_size (PKCS11_KEY *) |
| int | PKCS11_get_key_modulus (PKCS11_KEY *, BIGNUM **) |
| int | PKCS11_get_key_exponent (PKCS11_KEY *, BIGNUM **) |
| int | PKCS11_ecdsa_sign (const unsigned char *m, unsigned int m_len, unsigned char *sigret, unsigned int *siglen, PKCS11_KEY *key) |
| int | PKCS11_sign (int type, const unsigned char *m, unsigned int m_len, unsigned char *sigret, unsigned int *siglen, PKCS11_KEY *key) |
| int | PKCS11_verify (int type, const unsigned char *m, unsigned int m_len, unsigned char *signature, unsigned int siglen, PKCS11_KEY *key) |
| int | PKCS11_private_encrypt (int flen, const unsigned char *from, unsigned char *to, PKCS11_KEY *rsa, int padding) |
| int | PKCS11_private_decrypt (int flen, const unsigned char *from, unsigned char *to, PKCS11_KEY *key, int padding) |
| Decrypts data using the private key. | |
| void | PKCS11_set_vlog_a_method (PKCS11_CTX *pctx, PKCS11_VLOG_A_CB cb) |
libp11 header file
Definition in file libp11.h.
| #define CKRerr | ( | f, | |
| r ) |
| #define PKCS11_F_PKCS11_CHECK_TOKEN CKR_F_PKCS11_CHECK_TOKEN |
| #define PKCS11_F_PKCS11_ECDH_DERIVE CKR_F_PKCS11_ECDH_DERIVE |
| #define PKCS11_F_PKCS11_ENUMERATE_SLOTS CKR_F_PKCS11_ENUMERATE_SLOTS |
| #define PKCS11_F_PKCS11_GENERATE_KEY CKR_F_PKCS11_GENERATE_KEY |
| #define PKCS11_F_PKCS11_GENERATE_RANDOM CKR_F_PKCS11_GENERATE_RANDOM |
| #define PKCS11_F_PKCS11_GETATTR_ALLOC CKR_F_PKCS11_GETATTR_ALLOC |
| #define PKCS11_F_PKCS11_GETATTR_INT CKR_F_PKCS11_GETATTR_INT |
| #define PKCS11_F_PKCS11_IS_LOGGED_IN CKR_F_PKCS11_IS_LOGGED_IN |
| #define PKCS11_F_PKCS11_OPEN_SESSION CKR_F_PKCS11_OPEN_SESSION |
| #define PKCS11_F_PKCS11_PRIVATE_DECRYPT CKR_F_PKCS11_PRIVATE_DECRYPT |
| #define PKCS11_F_PKCS11_PRIVATE_ENCRYPT CKR_F_PKCS11_PRIVATE_ENCRYPT |
| #define PKCS11_F_PKCS11_REMOVE_CERTIFICATE CKR_F_PKCS11_REMOVE_CERTIFICATE |
| #define PKCS11_F_PKCS11_SEED_RANDOM CKR_F_PKCS11_SEED_RANDOM |
| #define PKCS11_F_PKCS11_STORE_CERTIFICATE CKR_F_PKCS11_STORE_CERTIFICATE |
| #define PKCS11_PKEY_CALLBACK_GET_PRIVATE_KEY 1 |
Callback type for PKCS11_get_private_key().
| typedef struct PKCS11_cert_st PKCS11_CERT |
| typedef struct PKCS11_ctx_st PKCS11_CTX |
| typedef struct PKCS11_ec_kgen_st PKCS11_EC_KGEN |
| typedef struct PKCS11_key_st PKCS11_KEY |
| typedef struct PKCS11_kgen_attrs_st PKCS11_KGEN_ATTRS |
| typedef struct PKCS11_nid_kgen_st PKCS11_NID_KGEN |
| typedef int(*) PKCS11_PKEY_CALLBACK(PKCS11_KEY *, EVP_PKEY *, void *) |
| typedef struct PKCS11_rsa_kgen_st PKCS11_RSA_KGEN |
| typedef struct PKCS11_slot_st PKCS11_SLOT |
| typedef struct PKCS11_token_st PKCS11_TOKEN |
| typedef void(*) PKCS11_VLOG_A_CB(int, const char *, va_list) |
|
extern |
Load PKCS11 error strings.
Call this function to be able to use ERR_reason_error_string(ERR_get_error()) to get an textual version of the latest error code
References ERR_load_PKCS11_strings().
Referenced by ERR_load_PKCS11_strings().
|
extern |
Change the currently used (either USER or SO) PIN on a token.
| slot | slot returned by PKCS11_find_token() |
| old_pin | old PIN value |
| new_pin | new PIN value |
| 0 | success |
| -1 | error |
References PKCS11_change_pin().
Referenced by PKCS11_change_pin().
|
extern |
Free a libp11 context.
| ctx | context allocated by PKCS11_CTX_new() |
References PKCS11_CTX_free().
Referenced by PKCS11_CTX_free().
|
extern |
Specify any private PKCS#11 module initialization args, if necessary.
References PKCS11_CTX_init_args().
Referenced by PKCS11_CTX_init_args().
|
extern |
Load a PKCS#11 module.
| ctx | context allocated by PKCS11_CTX_new() |
| ident | PKCS#11 library filename |
| 0 | success |
| -1 | error |
References PKCS11_CTX_load().
Referenced by PKCS11_CTX_load().
|
extern |
Create a new libp11 context.
This should be the first function called in the use of libp11
References PKCS11_CTX_new().
Referenced by PKCS11_CTX_new().
|
extern |
Create a new libp11 context with specified flags.
This should be the first function called in the use of libp11
References PKCS11_CTX_new_ex().
Referenced by PKCS11_CTX_new_ex().
|
extern |
Set a callback for EVP_PKEY objects returned by this context.
The callback and its user data must remain valid until they are replaced, unset, or the context is freed. Callback registration must not be changed concurrently with key retrieval.
| ctx | context allocated by PKCS11_CTX_new() |
| callback_type | one of PKCS11_PKEY_CALLBACK_* types |
| callback | callback function, or NULL to unset it |
| user_data | opaque callback data |
| 0 | success |
| -1 | unsupported callback type or invalid context |
References PKCS11_CTX_set_pkey_callback().
Referenced by PKCS11_CTX_set_pkey_callback().
|
extern |
Unload a PKCS#11 module.
| ctx | context allocated by PKCS11_CTX_new() |
References PKCS11_CTX_unload().
Referenced by PKCS11_CTX_unload().
|
extern |
Get a list of all slots.
| ctx | context allocated by PKCS11_CTX_new() |
| slotsp | pointer on a list of slots |
| nslotsp | size of the allocated list |
| 0 | success |
| -1 | error |
References PKCS11_enumerate_slots().
Referenced by PKCS11_enumerate_slots().
| PKCS11_SLOT * PKCS11_find_next_token | ( | PKCS11_CTX * | ctx, |
| PKCS11_SLOT * | slots, | ||
| unsigned int | nslots, | ||
| PKCS11_SLOT * | slot ) |
Find the next slot with a token.
| ctx | context allocated by PKCS11_CTX_new() |
| slots | list of slots allocated by PKCS11_enumerate_slots() |
| nslots | size of the list |
| slot | current slot |
| !=NULL | pointer on a slot structure |
| NULL | error |
References PKCS11_find_next_token().
Referenced by PKCS11_find_next_token().
| PKCS11_SLOT * PKCS11_find_token | ( | PKCS11_CTX * | ctx, |
| PKCS11_SLOT * | slots, | ||
| unsigned int | nslots ) |
Find the first slot with a token.
| ctx | context allocated by PKCS11_CTX_new() |
| slots | list of slots allocated by PKCS11_enumerate_slots() |
| nslots | size of the list |
| !=NULL | pointer on a slot structure |
| NULL | error |
References PKCS11_find_token().
Referenced by PKCS11_find_token().
|
extern |
Generate a private key on the token.
| token | token returned by PKCS11_find_token() |
| algorithm | EVP_PKEY_EC any other value select EVP_PKEY_RSA |
| bits_or_nid | size of the modulus in bits or the nid of the curve |
| label | label for this key |
| id | bytes to use as the id value |
| id_len | length of the id value |
| 0 | success |
| -1 | error |
References PKCS11_generate_key().
Referenced by PKCS11_generate_key().
|
extern |
Returns a EVP_PKEY object for the private key.
| key | PKCS11_KEY object |
| !=NULL | reference to the EVP_PKEY object |
| NULL | error |
References PKCS11_get_private_key().
Referenced by PKCS11_get_private_key().
|
extern |
Returns a EVP_PKEY object with the public key.
| key | PKCS11_KEY object |
| !=NULL | reference to the EVP_PKEY object |
| NULL | error |
References PKCS11_get_public_key().
Referenced by PKCS11_get_public_key().
|
extern |
Get the slot_id from a slot as it is stored in private.
| slotp | pointer on a slot |
| the | slotid |
References PKCS11_get_slotid_from_slot().
Referenced by PKCS11_get_slotid_from_slot().
|
extern |
Initialize the user PIN on a token.
| token | token descriptor (in general slot->token) |
| pin | new user PIN value |
| 0 | success |
| -1 | error |
References PKCS11_init_pin().
Referenced by PKCS11_init_pin().
|
extern |
Initialize a token.
| token | token descriptor (in general slot->token) |
| pin | Security Officer PIN value |
| label | new name of the token |
| 0 | success |
| -1 | error |
References PKCS11_init_token().
Referenced by PKCS11_init_token().
|
extern |
Check if user is already authenticated to a card.
| slot | slot returned by PKCS11_find_token() |
| so | kind of login to check: CKU_SO if != 0, otherwise CKU_USER |
| res | pointer to return value: 1 if logged in, 0 if not logged in |
| 0 | success |
| -1 | error |
References PKCS11_is_logged_in().
Referenced by PKCS11_is_logged_in().
|
extern |
Generate key pair on the token.
| token | on which the key should be generated |
| kgen_attrs | struct describing key generation (selection of algorithm, algorithm parameters...) |
| 0 | on success |
| -1 | error |
References PKCS11_keygen().
Referenced by PKCS11_keygen().
|
extern |
Authenticate to the card.
| slot | slot returned by PKCS11_find_token() |
| so | login as CKU_SO if != 0, otherwise login as CKU_USER |
| pin | PIN value |
| 0 | success |
| -1 | error |
References PKCS11_login().
Referenced by PKCS11_login().
|
extern |
De-authenticate from the card.
| slot | slot returned by PKCS11_find_token() |
| 0 | success |
| -1 | error |
References PKCS11_logout().
Referenced by PKCS11_logout().
|
extern |
Open a session in RO or RW mode.
| slot | slot descriptor returned by PKCS11_find_token() or PKCS11_enumerate_slots() |
| rw | open in read/write mode is mode != 0, otherwise in read only mode |
| 0 | success |
| -1 | error |
References PKCS11_open_session().
Referenced by PKCS11_open_session().
| int PKCS11_pkey_meths | ( | ENGINE * | e, |
| EVP_PKEY_METHOD ** | pmeth, | ||
| const int ** | nids, | ||
| int | nid ) |
Return supported key types or create a legacy OpenSSL pkey method.
A method returned through pmeth is newly allocated and owned by the caller. Do not install this function directly with ENGINE_set_pkey_meths(): OpenSSL expects repeated callback calls to return the same method, while this function returns a fresh method to avoid sharing methods between ENGINE instances. Direct callback use therefore leaks methods. Use the bundled pkcs11 engine, which caches methods per ENGINE.
References PKCS11_pkey_meths().
Referenced by PKCS11_pkey_meths().
|
extern |
Decrypts data using the private key.
| flen | length of the encrypted data |
| from | encrypted data |
| to | output buffer (MUST be a least flen bytes long) |
| key | private key object |
| padding | padding algorithm to be used |
References PKCS11_private_decrypt().
Referenced by PKCS11_private_decrypt().
|
extern |
Free the list of slots allocated by PKCS11_enumerate_slots().
| ctx | context allocated by PKCS11_CTX_new() |
| slots | list of slots allocated by PKCS11_enumerate_slots() |
| nslots | size of the list |
References PKCS11_release_all_slots().
Referenced by PKCS11_release_all_slots().
|
extern |
Store certificate on a token.
| token | token returned by PKCS11_find_token() |
| x509 | x509 certificate object |
| label | label for this certificate |
| id | bytes to use as the id value |
| id_len | length of the id value |
| ret_cert | put new PKCS11_CERT object here |
| 0 | success |
| -1 | error |
References PKCS11_store_certificate().
Referenced by PKCS11_store_certificate().
|
extern |
Store private key on a token.
| token | token returned by PKCS11_find_token() |
| pk | private key |
| label | label for this key |
| id | bytes to use as the id value |
| id_len | length of the id value |
| 0 | success |
| -1 | error |
References PKCS11_store_private_key().
Referenced by PKCS11_store_private_key().
|
extern |
Store public key on a token.
| token | token returned by PKCS11_find_token() |
| pk | private key |
| label | label for this key |
| id | bytes to use as the id value |
| id_len | length of the id value |
| 0 | success |
| -1 | error |
References PKCS11_store_public_key().
Referenced by PKCS11_store_public_key().
|
extern |
Get or update a list of all slots.
The difference to PKCS11_enumerate_slots() is that this will expect as input previous slot list (or zero initialized count and null pointer) for the list. This function always reuses the slots found from the previous list to avoid unexpected slot and key object destructon.
| ctx | context allocated by PKCS11_CTX_new() |
| slotsp | pointer on a list of slots |
| nslotsp | pointer to size of the allocated list |
| 0 | success |
| -1 | error |
References PKCS11_update_slots().
Referenced by PKCS11_update_slots().
| libp11, Copyright (C) 2005 Olaf Kirch <okir@lst.de> | ![]() |