pk11.h revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
/*
* Copyright (C) 2014, 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef PK11_PK11_H
#define PK11_PK11_H 1
#include <pkcs11/cryptoki.h>
typedef struct pk11_context pk11_context_t;
struct pk11_object {
};
struct pk11_context {
void *handle;
#ifndef PKCS11CRYPTOWITHHMAC
unsigned char *key;
#endif
};
typedef struct pk11_object pk11_object_t;
typedef enum {
OP_ANY = 0,
OP_RAND = 1,
OP_RSA = 2,
OP_DSA = 3,
OP_DH = 4,
OP_DIGEST = 5,
OP_EC = 6,
OP_GOST = 7,
OP_AES = 8,
OP_MAX = 9
/*%
* Function prototypes
*/
void pk11_set_lib_name(const char *lib_name);
/*%<
*/
/*%<
* Initialize PKCS#11 device
*
* mctx: memory context to attach to pk11_mctx.
*
* returns:
* ISC_R_SUCCESS
* PK11_R_NOPROVIDER: can't load the provider
* PK11_R_INITFAILED: C_Initialize() failed
* PK11_R_NORANDOMSERVICE: can't find required random service
* PK11_R_NODIGESTSERVICE: can't find required digest service
* PK11_R_NOAESSERVICE: can't find required AES service
*/
const char *pin,
/*%<
* Initialize PKCS#11 device and acquire a session.
*
* need_services:
* if ISC_TRUE, this session requires full PKCS#11 API
* support including random and digest services, and
* the lack of these services will cause the session not
* to be initialized. If ISC_FALSE, the function will return
* an error code indicating the missing service, but the
* session will be usable for other purposes.
* generating or destroying keys); otherwise read-only.
* login: indicates whether to log in to the device
* pin: optional PIN, overriding any PIN currently associated
* with the
* slot: device slot ID
*/
/*%<
* Release an active PKCS#11 session for reuse.
*/
isc_result_t pk11_finalize(void);
/*%<
* Shut down PKCS#11 device and free all sessions.
*/
void pk11_rand_seed_fromfile(const char *randomfile);
void pk11_dump_tokens(void);
#endif /* PK11_PK11_H */