summaryrefslogtreecommitdiff
path: root/src/p11-tests.h
blob: 89b856cfdf25ceb244c887799d299b3f4ebbdb7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef P11TESTST_H_
#define P11TESTST_H_

#include "pkcs11/pkcs11.h"

#include <assert.h>
#include <stdarg.h>

/* -------------------------------------------------------------------
 * 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_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);

/* -------------------------------------------------------------------
 * info.c
 */

extern CK_INFO p11t_info_global;

extern CK_ULONG p11t_info_slot_count;
extern CK_SLOT_ID_PTR p11t_info_slot_ids;
extern CK_SLOT_INFO_PTR p11t_info_slot_info;
extern CK_TOKEN_INFO_PTR p11t_info_token_info;

extern CK_ULONG p11t_info_mech_count;
extern CK_MECHANISM_TYPE_PTR p11t_info_mech_types;
extern CK_MECHANISM_INFO_PTR p11t_info_mech_info;

void p11t_info_tests(void);

/* -------------------------------------------------------------------
 * module.c
 */

extern CK_FUNCTION_LIST_PTR p11t_module_funcs;

void p11t_module_load(const char *filename);
void p11t_module_unload(void);

void p11t_module_initialize(const char *initstr);
void p11t_module_finalize(void);

#endif /* P11TESTST_H_ */