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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
/*
* gnome-keyring
*
* Copyright (C) 2008 Stefan Walter
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef GKM_CRYPTO_H_
#define GKM_CRYPTO_H_
#include "gkm-types.h"
#include "pkcs11/pkcs11.h"
#include "egg/egg-padding.h"
#include <glib.h>
#include <gcrypt.h>
void gkm_crypto_initialize (void);
CK_RV gkm_crypto_prepare (GkmSession *session,
CK_MECHANISM_TYPE mech,
GkmObject *key);
CK_RV gkm_crypto_prepare_xsa (GkmSession *session,
CK_MECHANISM_TYPE mech,
GkmObject *key);
CK_RV gkm_crypto_perform (GkmSession *session,
CK_MECHANISM_TYPE mech,
CK_ATTRIBUTE_TYPE method,
CK_BYTE_PTR bufone,
CK_ULONG n_bufone,
CK_BYTE_PTR buftwo,
CK_ULONG_PTR n_buftwo);
CK_RV gkm_crypto_encrypt (GkmSession *session,
CK_MECHANISM_TYPE mech,
CK_BYTE_PTR data,
CK_ULONG n_data,
CK_BYTE_PTR encrypted,
CK_ULONG_PTR n_encrypted);
CK_RV gkm_crypto_encrypt_xsa (gcry_sexp_t sexp,
CK_MECHANISM_TYPE mech,
CK_BYTE_PTR data,
CK_ULONG n_data,
CK_BYTE_PTR encrypted,
CK_ULONG_PTR n_encrypted);
CK_RV gkm_crypto_decrypt (GkmSession *session,
CK_MECHANISM_TYPE mech,
CK_BYTE_PTR encrypted,
CK_ULONG n_encrypted,
CK_BYTE_PTR data,
CK_ULONG_PTR n_data);
CK_RV gkm_crypto_decrypt_xsa (gcry_sexp_t sexp,
CK_MECHANISM_TYPE mech,
CK_BYTE_PTR encrypted,
CK_ULONG n_encrypted,
CK_BYTE_PTR data,
CK_ULONG_PTR n_data);
CK_RV gkm_crypto_sign (GkmSession *session,
CK_MECHANISM_TYPE mech,
CK_BYTE_PTR data,
CK_ULONG n_data,
CK_BYTE_PTR signature,
CK_ULONG_PTR n_signature);
CK_RV gkm_crypto_sign_xsa (gcry_sexp_t sexp,
CK_MECHANISM_TYPE mech,
CK_BYTE_PTR data,
CK_ULONG n_data,
CK_BYTE_PTR signature,
CK_ULONG_PTR n_signature);
CK_RV gkm_crypto_verify (GkmSession *session,
CK_MECHANISM_TYPE mech,
CK_BYTE_PTR data,
CK_ULONG n_data,
CK_BYTE_PTR signature,
CK_ULONG n_signature);
CK_RV gkm_crypto_verify_xsa (gcry_sexp_t sexp,
CK_MECHANISM_TYPE mech,
CK_BYTE_PTR data,
CK_ULONG n_data,
CK_BYTE_PTR signature,
CK_ULONG n_signature);
CK_RV gkm_crypto_sexp_to_data (gcry_sexp_t sexp,
guint bits,
CK_BYTE_PTR data,
CK_ULONG *n_data,
EggPadding padding,
...) G_GNUC_NULL_TERMINATED;
CK_RV gkm_crypto_data_to_sexp (const gchar *format,
guint nbits,
EggPadding padding,
CK_BYTE_PTR data,
CK_ULONG n_data,
gcry_sexp_t *sexp);
CK_RV gkm_crypto_generate_key_pair (GkmSession *session,
CK_MECHANISM_TYPE mech,
CK_ATTRIBUTE_PTR pub_atts,
CK_ULONG n_pub_atts,
CK_ATTRIBUTE_PTR priv_atts,
CK_ULONG n_priv_atts,
GkmObject **pub_key,
GkmObject **priv_key);
CK_RV gkm_crypto_derive_key (GkmSession *session,
CK_MECHANISM_PTR mech,
GkmObject *base,
CK_ATTRIBUTE_PTR attrs,
CK_ULONG n_attrs,
GkmObject **derived);
CK_RV gkm_crypto_wrap_key (GkmSession *session,
CK_MECHANISM_PTR mech,
GkmObject *wrapper,
GkmObject *wrapped,
CK_BYTE_PTR output,
CK_ULONG_PTR n_output);
CK_RV gkm_crypto_unwrap_key (GkmSession *session,
CK_MECHANISM_PTR mech,
GkmObject *wrapper,
CK_VOID_PTR input,
CK_ULONG n_input,
CK_ATTRIBUTE_PTR attrs,
CK_ULONG n_attrs,
GkmObject **unwrapped);
gulong gkm_crypto_secret_key_length (CK_KEY_TYPE type);
#endif /* GKM_CRYPTO_H_ */
|