summaryrefslogtreecommitdiff
path: root/src/p11-tests.h
blob: 4792e568f7ec54c0c3b75807875b7de5a526071e (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#ifndef P11TESTST_H_
#define P11TESTST_H_

#include "pkcs11/pkcs11.h"

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

#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);

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

/* -------------------------------------------------------------------
 * session.c
 */

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);


#endif /* P11TESTST_H_ */