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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
|
/**
* XML Security Library (http://www.aleksey.com/xmlsec).
*
* Keys.
*
* This is free software; see Copyright file in the source
* distribution for preciese wording.
*
* Copyright (C) 2002-2016 Aleksey Sanin <aleksey@aleksey.com>. All Rights Reserved.
*/
#ifndef __XMLSEC_KEYS_H__
#define __XMLSEC_KEYS_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <time.h>
#include <xmlsec/xmlsec.h>
#include <xmlsec/list.h>
#include <xmlsec/keysdata.h>
/**
* xmlSecKeyUsage:
*
* The key usage.
*/
typedef unsigned int xmlSecKeyUsage;
/**
* xmlSecKeyUsageSign:
*
* Key can be used in any way.
*/
#define xmlSecKeyUsageSign 0x00000001
/**
* xmlSecKeyUsageVerify:
*
* Key for signing.
*/
#define xmlSecKeyUsageVerify 0x00000002
/**
* xmlSecKeyUsageEncrypt:
*
* Key for signature verification.
*/
#define xmlSecKeyUsageEncrypt 0x00000004
/**
* xmlSecKeyUsageDecrypt:
*
* An encryption key.
*/
#define xmlSecKeyUsageDecrypt 0x00000008
/**
* xmlSecKeyUsageKeyExchange:
*
* The key is used for key exchange.
*/
#define xmlSecKeyUsageKeyExchange 0x00000010
/**
* xmlSecKeyUsageAny:
*
* A decryption key.
*/
#define xmlSecKeyUsageAny 0xFFFFFFFF
/**************************************************************************
*
* xmlSecKeyUseWith
*
*************************************************************************/
typedef struct _xmlSecKeyUseWith xmlSecKeyUseWith, *xmlSecKeyUseWithPtr;
XMLSEC_EXPORT int xmlSecKeyUseWithInitialize (xmlSecKeyUseWithPtr keyUseWith);
XMLSEC_EXPORT void xmlSecKeyUseWithFinalize (xmlSecKeyUseWithPtr keyUseWith);
XMLSEC_EXPORT void xmlSecKeyUseWithReset (xmlSecKeyUseWithPtr keyUseWith);
XMLSEC_EXPORT int xmlSecKeyUseWithCopy (xmlSecKeyUseWithPtr dst,
xmlSecKeyUseWithPtr src);
XMLSEC_EXPORT xmlSecKeyUseWithPtr xmlSecKeyUseWithCreate (const xmlChar* application,
const xmlChar* identifier);
XMLSEC_EXPORT xmlSecKeyUseWithPtr xmlSecKeyUseWithDuplicate (xmlSecKeyUseWithPtr keyUseWith);
XMLSEC_EXPORT void xmlSecKeyUseWithDestroy (xmlSecKeyUseWithPtr keyUseWith);
XMLSEC_EXPORT int xmlSecKeyUseWithSet (xmlSecKeyUseWithPtr keyUseWith,
const xmlChar* application,
const xmlChar* identifier);
XMLSEC_EXPORT void xmlSecKeyUseWithDebugDump (xmlSecKeyUseWithPtr keyUseWith,
FILE* output);
XMLSEC_EXPORT void xmlSecKeyUseWithDebugXmlDump (xmlSecKeyUseWithPtr keyUseWith,
FILE* output);
/**
* xmlSecKeyUseWith:
* @application: the application.
* @identifier: the identifier.
* @reserved1: reserved for future use.
* @reserved2: reserved for future use.
*
* Information about application and user of the key.
*/
struct _xmlSecKeyUseWith {
xmlChar* application;
xmlChar* identifier;
void* reserved1;
void* reserved2;
};
/**
* xmlSecKeyUseWithPtrListId:
*
* The keys list klass.
*/
#define xmlSecKeyUseWithPtrListId xmlSecKeyUseWithPtrListGetKlass()
XMLSEC_EXPORT xmlSecPtrListId xmlSecKeyUseWithPtrListGetKlass (void);
/**************************************************************************
*
* xmlSecKeyReq - what key are we looking for?
*
*************************************************************************/
typedef struct _xmlSecKeyReq xmlSecKeyReq, *xmlSecKeyReqPtr;
/**
* xmlSecKeyReq:
* @keyId: the desired key value klass.
* @keyType: the desired key type.
* @keyUsage: the desired key usage.
* @keyBitsSize: the desired key size (in bits!).
* @keyUseWithList: the desired key use with application/identifier information.
* @reserved1: reserved for future use.
* @reserved2: reserved for future use.
*
* The key requirements information.
*/
struct _xmlSecKeyReq {
xmlSecKeyDataId keyId;
xmlSecKeyDataType keyType;
xmlSecKeyUsage keyUsage;
xmlSecSize keyBitsSize;
xmlSecPtrList keyUseWithList;
void* reserved1;
void* reserved2;
};
XMLSEC_EXPORT int xmlSecKeyReqInitialize (xmlSecKeyReqPtr keyReq);
XMLSEC_EXPORT void xmlSecKeyReqFinalize (xmlSecKeyReqPtr keyReq);
XMLSEC_EXPORT void xmlSecKeyReqReset (xmlSecKeyReqPtr keyReq);
XMLSEC_EXPORT int xmlSecKeyReqCopy (xmlSecKeyReqPtr dst,
xmlSecKeyReqPtr src);
XMLSEC_EXPORT int xmlSecKeyReqMatchKey (xmlSecKeyReqPtr keyReq,
xmlSecKeyPtr key);
XMLSEC_EXPORT int xmlSecKeyReqMatchKeyValue (xmlSecKeyReqPtr keyReq,
xmlSecKeyDataPtr value);
XMLSEC_EXPORT void xmlSecKeyReqDebugDump (xmlSecKeyReqPtr keyReq,
FILE* output);
XMLSEC_EXPORT void xmlSecKeyReqDebugXmlDump (xmlSecKeyReqPtr keyReq,
FILE* output);
/**
* xmlSecKey:
* @name: the key name.
* @value: the key value.
* @dataList: the key data list.
* @usage: the key usage.
* @notValidBefore: the start key validity interval.
* @notValidAfter: the end key validity interval.
*
* The key.
*/
struct _xmlSecKey {
xmlChar* name;
xmlSecKeyDataPtr value;
xmlSecPtrListPtr dataList;
xmlSecKeyUsage usage;
time_t notValidBefore;
time_t notValidAfter;
};
XMLSEC_EXPORT xmlSecKeyPtr xmlSecKeyCreate (void);
XMLSEC_EXPORT void xmlSecKeyDestroy (xmlSecKeyPtr key);
XMLSEC_EXPORT void xmlSecKeyEmpty (xmlSecKeyPtr key);
XMLSEC_EXPORT xmlSecKeyPtr xmlSecKeyDuplicate (xmlSecKeyPtr key);
XMLSEC_EXPORT int xmlSecKeyCopy (xmlSecKeyPtr keyDst,
xmlSecKeyPtr keySrc);
XMLSEC_EXPORT const xmlChar* xmlSecKeyGetName (xmlSecKeyPtr key);
XMLSEC_EXPORT int xmlSecKeySetName (xmlSecKeyPtr key,
const xmlChar* name);
XMLSEC_EXPORT xmlSecKeyDataType xmlSecKeyGetType (xmlSecKeyPtr key);
XMLSEC_EXPORT xmlSecKeyDataPtr xmlSecKeyGetValue (xmlSecKeyPtr key);
XMLSEC_EXPORT int xmlSecKeySetValue (xmlSecKeyPtr key,
xmlSecKeyDataPtr value);
XMLSEC_EXPORT xmlSecKeyDataPtr xmlSecKeyGetData (xmlSecKeyPtr key,
xmlSecKeyDataId dataId);
XMLSEC_EXPORT xmlSecKeyDataPtr xmlSecKeyEnsureData (xmlSecKeyPtr key,
xmlSecKeyDataId dataId);
XMLSEC_EXPORT int xmlSecKeyAdoptData (xmlSecKeyPtr key,
xmlSecKeyDataPtr data);
XMLSEC_EXPORT void xmlSecKeyDebugDump (xmlSecKeyPtr key,
FILE *output);
XMLSEC_EXPORT void xmlSecKeyDebugXmlDump (xmlSecKeyPtr key,
FILE *output);
XMLSEC_EXPORT xmlSecKeyPtr xmlSecKeyGenerate (xmlSecKeyDataId dataId,
xmlSecSize sizeBits,
xmlSecKeyDataType type);
XMLSEC_EXPORT xmlSecKeyPtr xmlSecKeyGenerateByName (const xmlChar* name,
xmlSecSize sizeBits,
xmlSecKeyDataType type);
XMLSEC_EXPORT int xmlSecKeyMatch (xmlSecKeyPtr key,
const xmlChar *name,
xmlSecKeyReqPtr keyReq);
XMLSEC_EXPORT xmlSecKeyPtr xmlSecKeyReadBuffer (xmlSecKeyDataId dataId,
xmlSecBuffer* buffer);
XMLSEC_EXPORT xmlSecKeyPtr xmlSecKeyReadBinaryFile (xmlSecKeyDataId dataId,
const char* filename);
XMLSEC_EXPORT xmlSecKeyPtr xmlSecKeyReadMemory (xmlSecKeyDataId dataId,
const xmlSecByte* data,
xmlSecSize dataSize);
/**
* xmlSecKeyIsValid:
* @key: the pointer to key.
*
* Macro. Returns 1 if @key is not NULL and @key->id is not NULL
* or 0 otherwise.
*/
#define xmlSecKeyIsValid(key) \
((( key ) != NULL) && \
(( key )->value != NULL) && \
((( key )->value->id) != NULL))
/**
* xmlSecKeyCheckId:
* @key: the pointer to key.
* @keyId: the key Id.
*
* Macro. Returns 1 if @key is valid and @key's id is equal to @keyId.
*/
#define xmlSecKeyCheckId(key, keyId) \
(xmlSecKeyIsValid(( key )) && \
((( key )->value->id) == ( keyId )))
/***********************************************************************
*
* Keys list
*
**********************************************************************/
/**
* xmlSecKeyPtrListId:
*
* The keys list klass.
*/
#define xmlSecKeyPtrListId xmlSecKeyPtrListGetKlass()
XMLSEC_EXPORT xmlSecPtrListId xmlSecKeyPtrListGetKlass (void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __XMLSEC_KEYS_H__ */
|