1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2017, Linaro Limited
4  */
5 
6 #ifndef LIBCKTEEC_PKCS11_TOKEN_H
7 #define LIBCKTEEC_PKCS11_TOKEN_H
8 
9 #include <pkcs11.h>
10 
11 #include "invoke_ta.h"
12 
13 CK_RV ck_get_info(CK_INFO_PTR info);
14 
15 CK_RV ck_slot_get_list(CK_BBOOL present,
16 		       CK_SLOT_ID_PTR slots, CK_ULONG_PTR count);
17 
18 CK_RV ck_slot_get_info(CK_SLOT_ID slot, CK_SLOT_INFO_PTR info);
19 
20 CK_RV ck_token_get_info(CK_SLOT_ID slot, CK_TOKEN_INFO_PTR info);
21 
22 CK_RV ck_token_mechanism_ids(CK_SLOT_ID slot,
23 			     CK_MECHANISM_TYPE_PTR mechanisms,
24 			     CK_ULONG_PTR count);
25 
26 CK_RV ck_token_mechanism_info(CK_SLOT_ID slot, CK_MECHANISM_TYPE type,
27 			      CK_MECHANISM_INFO_PTR info);
28 
29 CK_RV ck_open_session(CK_SLOT_ID slot, CK_FLAGS flags, CK_VOID_PTR cookie,
30 		      CK_NOTIFY callback, CK_SESSION_HANDLE_PTR session);
31 
32 CK_RV ck_close_session(CK_SESSION_HANDLE session);
33 
34 CK_RV ck_close_all_sessions(CK_SLOT_ID slot);
35 
36 CK_RV ck_get_session_info(CK_SESSION_HANDLE session, CK_SESSION_INFO_PTR info);
37 
38 CK_RV ck_init_token(CK_SLOT_ID slot, CK_UTF8CHAR_PTR pin,
39 		    CK_ULONG pin_len, CK_UTF8CHAR_PTR label);
40 
41 CK_RV ck_init_pin(CK_SESSION_HANDLE session,
42 		  CK_UTF8CHAR_PTR pin, CK_ULONG pin_len);
43 
44 CK_RV ck_set_pin(CK_SESSION_HANDLE session,
45 		 CK_UTF8CHAR_PTR old, CK_ULONG old_len,
46 		 CK_UTF8CHAR_PTR new, CK_ULONG new_len);
47 
48 CK_RV ck_login(CK_SESSION_HANDLE session, CK_USER_TYPE user_type,
49 	       CK_UTF8CHAR_PTR pin, CK_ULONG pin_len);
50 
51 CK_RV ck_logout(CK_SESSION_HANDLE session);
52 
53 CK_RV ck_seed_random(CK_SESSION_HANDLE session, CK_BYTE_PTR seed,
54 		     CK_ULONG length);
55 
56 CK_RV ck_generate_random(CK_SESSION_HANDLE session, CK_BYTE_PTR data,
57 			 CK_ULONG length);
58 
59 #endif /*LIBCKTEEC_PKCS11_TOKEN_H*/
60