00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __PKCS11_LIB_H__
00018 #define __PKCS11_LIB_H__
00019
00020 #include "cert_st.h"
00021
00022 typedef struct cert_object_str cert_object_t;
00023 typedef struct pkcs11_handle_str pkcs11_handle_t;
00024
00025 #ifndef __PKCS11_LIB_C__
00026 #define PKCS11_EXTERN extern
00027 #else
00028 #define PKCS11_EXTERN
00029 #endif
00030
00031 PKCS11_EXTERN int crypto_init(cert_policy *policy);
00032 PKCS11_EXTERN int load_pkcs11_module(char *module, pkcs11_handle_t **h);
00033 PKCS11_EXTERN int init_pkcs11_module(pkcs11_handle_t *h,int flag);
00034 PKCS11_EXTERN int find_slot_by_number(pkcs11_handle_t *h,int slot_num,
00035 unsigned int *slot);
00036 PKCS11_EXTERN int find_slot_by_number_and_label(pkcs11_handle_t *h,
00037 int slot_num, const char *slot_label,
00038 unsigned int *slot);
00039 PKCS11_EXTERN const char *get_slot_label(pkcs11_handle_t *h);
00040 PKCS11_EXTERN int wait_for_token(pkcs11_handle_t *h,
00041 int wanted_slot_num,
00042 const char *wanted_slot_label,
00043 unsigned int *slot);
00044 PKCS11_EXTERN const X509 *get_X509_certificate(cert_object_t *cert);
00045 PKCS11_EXTERN void release_pkcs11_module(pkcs11_handle_t *h);
00046 PKCS11_EXTERN int open_pkcs11_session(pkcs11_handle_t *h, unsigned int slot);
00047 PKCS11_EXTERN int close_pkcs11_session(pkcs11_handle_t *h);
00048 PKCS11_EXTERN int pkcs11_login(pkcs11_handle_t *h, char *password);
00049 PKCS11_EXTERN int pkcs11_pass_login(pkcs11_handle_t *h, int nullok);
00050 PKCS11_EXTERN cert_object_t **get_certificate_list(pkcs11_handle_t *h,
00051 int *ncert);
00052 PKCS11_EXTERN int get_private_key(pkcs11_handle_t *h, cert_object_t *);
00053 PKCS11_EXTERN int sign_value(pkcs11_handle_t *h, cert_object_t *,
00054 unsigned char *data, unsigned long length,
00055 unsigned char **signature, unsigned long *signature_length);
00056 PKCS11_EXTERN int get_random_value(unsigned char *data, int length);
00057
00058 #undef PKCS11_EXTERN
00059
00060
00061 #endif