#ifndef P11TESTST_H_ #define P11TESTST_H_ #include "pkcs11/pkcs11.h" #include #include #define CK_INVALID ((CK_ULONG)-1) extern int p11t_test_unexpected; /* ------------------------------------------------------------------- * msg.c */ const char* p11t_msg_rv(CK_RV rv); void p11t_msg_va(const char *message, va_list va); void p11t_msg_print(const char *message, ...); void p11t_msg_fatal(const char *message, ...); void p11t_msg_exit(int code, const char *message, ...); void p11t_msg_prefix(const char *prefix); #define p11t_msg_here() \ (__func__ "() at " __FILE__ ":" __LINE__) /* ------------------------------------------------------------------- * check.c */ int p11t_check_returns(const char *message, CK_RV have, CK_RV want); #define p11t_check_padded(msg, padded) \ (p11t_check_padded_len((msg), (padded), sizeof(padded))) int p11t_check_padded_len(const char *message, const CK_UTF8CHAR_PTR padded, CK_ULONG length); int p11t_check_ulong(const char *message, CK_ULONG have, CK_ULONG want); int p11t_check_mask(const char *message, CK_ULONG flags, CK_ULONG mask); int p11t_check_flag(const char *message, CK_ULONG flags, CK_ULONG flag); int p11t_check_nflag(const char *message, CK_ULONG flags, CK_ULONG nflag); int p11t_check_bool(const char *message, CK_BBOOL value); int p11t_check_string(const char *message, CK_UTF8CHAR_PTR value, CK_ULONG length); /* ------------------------------------------------------------------- * config.c */ void p11t_config_parse(const char* filename); void p11t_config_cleanup(void); /* ------------------------------------------------------------------- * module.c */ extern CK_FUNCTION_LIST_PTR p11t_module_funcs; void p11t_module_config(const char *name, const char *value); void p11t_module_load(const char *filename); void p11t_module_unload(void); void p11t_module_initialize(void); void p11t_module_finalize(void); /* ------------------------------------------------------------------- * object.c */ CK_OBJECT_HANDLE_PTR p11t_object_find(CK_SESSION_HANDLE session, CK_ATTRIBUTE_PTR attrs, CK_ULONG n_attrs, CK_ULONG_PTR n_objects); void p11t_object_tests(void); /* ------------------------------------------------------------------- * session.c */ CK_SESSION_HANDLE p11t_session_open(CK_SLOT_ID slot, int readwrite); int p11t_session_login(CK_SESSION_HANDLE handle); int p11t_session_logout(CK_SESSION_HANDLE handle); int p11t_session_close(CK_SESSION_HANDLE handle); int p11t_session_close_all(CK_SLOT_ID slot); void p11t_session_config(const char *name, const char *value); void p11t_session_tests(void); /* ------------------------------------------------------------------- * slot.c */ extern CK_INFO p11t_slot_global; extern CK_ULONG p11t_slot_count; extern CK_SLOT_ID_PTR p11t_slot_ids; extern CK_SLOT_INFO_PTR p11t_slot_info; extern CK_TOKEN_INFO_PTR p11t_slot_token_info; extern CK_ULONG* p11t_slot_mech_count; extern CK_MECHANISM_INFO_PTR* p11t_slot_mech_info; void p11t_slot_tests(void); CK_TOKEN_INFO_PTR p11t_slot_get_token_info(CK_SLOT_ID slot); #endif /* P11TESTST_H_ */