naoki 1.0.1-x86-linux

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/ext/icapi.h ADDED
@@ -0,0 +1,1187 @@
1
+ /*
2
+ * @(#)icapi.h 1.79 10/03/10 05:58:06 SafeNet, Inc.
3
+ *
4
+ * Copyright (c) 2003-2009 SafeNet, Inc.
5
+ *
6
+ * Ingrian/SafeNet Crypto API (ICAPI)
7
+ *
8
+ */
9
+
10
+ #ifndef IngrianICAPI
11
+ #define IngrianICAPI
12
+
13
+ #define ARCH 32
14
+ /* Identifier naming:
15
+ *
16
+ * I_C_ denotes function
17
+ * I_O_ denotes opaque object
18
+ * I_T_ denotes type or enum value
19
+ * I_E_ denotes enum value for error code
20
+ */
21
+
22
+
23
+ #define ICAPI_VERSION 1.0.0
24
+
25
+
26
+ #include "icapierr.h"
27
+
28
+ #include <sys/types.h>
29
+
30
+
31
+ typedef unsigned char I_T_BYTE;
32
+ typedef char I_T_CHAR;
33
+ typedef const char * I_T_PCCHAR;
34
+
35
+ /* I_T_INT is supposed to be a 32-bit int */
36
+ #if ARCH == 32
37
+ typedef long int I_T_INT;
38
+ typedef unsigned long int I_T_UINT;
39
+ #elif ARCH == 64
40
+ typedef int I_T_INT;
41
+ typedef unsigned int I_T_UINT;
42
+ #else
43
+ #error "ARCH neither 32 nor 64!"
44
+ #endif
45
+
46
+ /* The function return type */
47
+ typedef I_T_INT I_T_RETURN;
48
+
49
+ /* The boolean type and values */
50
+ typedef I_T_UINT I_T_BOOL;
51
+ #define I_T_TRUE 1
52
+ #define I_T_FALSE 0
53
+ const I_T_UINT I_T_MAX_BULK_DATA_SIZE = 100;
54
+
55
+ #ifdef WIN32
56
+ #define FUNCEXP __declspec(dllexport)
57
+ #else
58
+ #define FUNCEXP
59
+ #endif
60
+
61
+
62
+
63
+ /* Permission masks may be OR'd together to define the complete permissions
64
+ * to be granted to groups for using keys.
65
+ */
66
+ enum I_T_PermissionMaskEnum
67
+ {
68
+ I_T_Permission_Encrypt = 0x1,
69
+ I_T_Permission_Decrypt = 0x2,
70
+ I_T_Permission_Sign = 0x4,
71
+ I_T_Permission_SignV = 0x8,
72
+ I_T_Permission_MAC = 0x10,
73
+ I_T_Permission_MACV = 0x20,
74
+ I_T_Permission_UsePrivate = 0x40,
75
+ I_T_Permission_UsePublic = 0x80,
76
+ I_T_Permission_Export = 0x100
77
+ };
78
+
79
+
80
+ /* Opaque objects are typedef'd to pointers to structs in order to provide
81
+ * type safety.
82
+ */
83
+
84
+ /* An opaque object representing a list of group permissions for a key */
85
+ typedef struct _O_GroupList * I_O_GroupList;
86
+
87
+ /* An opaque object representing a reusable algorithm specification */
88
+ typedef struct _O_CipherSpec * I_O_CipherSpec;
89
+
90
+ /* An opaque object representing a given encryption operation */
91
+ typedef struct _O_CipherState * I_O_CipherState;
92
+
93
+ /* An opaque object representing a session belonging to a single user */
94
+ typedef struct _O_Session * I_O_Session;
95
+
96
+ /* An opaque object representing key information */
97
+ typedef struct _O_KeyInfo * I_O_KeyInfo;
98
+
99
+ /* An opaque object representing an attribute list */
100
+ typedef struct _O_AttributeList * I_O_AttributeList;
101
+
102
+ /* Cryptographic operation types */
103
+ typedef enum I_T_OperationEnum
104
+ {
105
+ I_T_Operation_Encrypt = 0,
106
+ I_T_Operation_Decrypt = 1,
107
+ I_T_Operation_PublicEncrypt = 2,
108
+ I_T_Operation_PrivateDecrypt = 5,
109
+ I_T_Operation_MAC = 7,
110
+ I_T_Operation_MACV = 8,
111
+ I_T_Operation_Sign = 9,
112
+ I_T_Operation_SignV = 10
113
+ } I_T_Operation;
114
+
115
+ #define I_T_LNG_ALG_DES_ECB_PKCS5PADDING "DES/ECB/PKCS5Padding"
116
+ #define I_T_LNG_ALG_DES_ECB_NOPADDING "DES/ECB/NoPadding"
117
+ #define I_T_LNG_ALG_DES_CBC_PKCS5PADDING "DES/CBC/PKCS5Padding"
118
+ #define I_T_LNG_ALG_DES_CBC_NOPADDING "DES/CBC/NoPadding"
119
+ #define I_T_LNG_ALG_DES_EDE_ECB_PKCS5PADDING "DESede/ECB/PKCS5Padding"
120
+ #define I_T_LNG_ALG_DES_EDE_ECB_NOPADDING "DESede/ECB/NoPadding"
121
+ #define I_T_LNG_ALG_DES_EDE_CBC_PKCS5PADDING "DESede/CBC/PKCS5Padding"
122
+ #define I_T_LNG_ALG_DES_EDE_CBC_NOPADDING "DESede/CBC/NoPadding"
123
+ #define I_T_LNG_ALG_AES_ECB_PKCS5PADDING "AES/ECB/PKCS5Padding"
124
+ #define I_T_LNG_ALG_AES_ECB_NOPADDING "AES/ECB/NoPadding"
125
+ #define I_T_LNG_ALG_AES_CBC_PKCS5PADDING "AES/CBC/PKCS5Padding"
126
+ #define I_T_LNG_ALG_AES_CBC_NOPADDING "AES/CBC/NoPadding"
127
+ #define I_T_LNG_ALG_HMACSHA1 "HmacSHA1"
128
+ #define I_T_LNG_ALG_HMACSHA256 "HmacSHA256"
129
+ #define I_T_LNG_ALG_HMACSHA384 "HmacSHA384"
130
+ #define I_T_LNG_ALG_HMACSHA512 "HmacSHA512"
131
+ #define I_T_LNG_ALG_RSA "RSA"
132
+ #define I_T_LNG_ALG_SHA1WITHRSA "SHA1withRSA"
133
+ #define I_T_LNG_ALG_SHA256WITHRSA "SHA256withRSA"
134
+ #define I_T_LNG_ALG_SHA384WITHRSA "SHA384withRSA"
135
+ #define I_T_LNG_ALG_SHA512WITHRSA "SHA512withRSA"
136
+ #define I_T_LNG_ALG_RC4 "RC4"
137
+ #define I_T_LNG_ALG_SEED "SEED"
138
+
139
+ /* Initialize the library by configuration (properties) file or environment
140
+ * variable that points to a configuration file
141
+ */
142
+ typedef enum I_T_InitializationSourceEnum
143
+ {
144
+ I_T_Init_File = 0,
145
+ I_T_Init_Environment = 1
146
+ } I_T_InitializationSource;
147
+
148
+
149
+ /* For bulk operations, specifies whether to use an IV per data element or
150
+ * a single IV for all data elements.
151
+ */
152
+ typedef enum I_T_IVTypeEnum
153
+ {
154
+ I_T_IV_PerElement = 0,
155
+ I_T_IV_Single = 1,
156
+ I_T_IV_None = 2
157
+ } I_T_IVType;
158
+
159
+
160
+ /* Session authentication types */
161
+ typedef enum I_T_AuthTypeEnum
162
+ {
163
+ I_T_Auth_Password = 0
164
+ } I_T_AuthType;
165
+
166
+
167
+ /* Create and modify the state of versioned keys.
168
+ */
169
+ typedef enum I_T_KeyParameterTypeEnum
170
+ {
171
+ I_T_KeyLifecycleState = 0,
172
+ I_T_KeyVersion = 1
173
+ } I_T_KeyParameterType;
174
+
175
+
176
+ typedef enum I_T_KeyParameterValueEnum
177
+ {
178
+ I_T_KeyParameter_State_Active = 0,
179
+ I_T_KeyParameter_State_Restricted = 10,
180
+ I_T_KeyParameter_State_Retired = 20,
181
+ I_T_KeyParameter_Version_Increment = 100
182
+ } I_T_KeyParameterValue;
183
+
184
+
185
+ typedef enum I_T_ExportFormatEnum
186
+ {
187
+ I_T_ExportFormat_PEM_PKCS1_CERT_ONLY,
188
+ I_T_ExportFormat_PEM_PKCS1,
189
+ I_T_ExportFormat_PEM_PKCS8,
190
+ I_T_ExportFormat_PKCS12
191
+ } I_T_ExportFormat;
192
+
193
+ /* Supported key wrapping formats for exporting symmetric key */
194
+ typedef enum I_T_KeyWrapFormatEnum
195
+ {
196
+ I_T_ExportKeyWrapFormat_NONE = 0,
197
+ I_T_ExportKeyWrapFormat_RAW_PKCS1v15 = 1
198
+ } I_T_KeyWrapFormat;
199
+
200
+
201
+ #ifdef __cplusplus
202
+ extern "C" {
203
+ #endif /* __cplusplus */
204
+
205
+
206
+ /*! Initialize the library
207
+ *
208
+ * \param source
209
+ * The source of the initialization information -- either
210
+ * Init_File or Init_Environment.
211
+ * \param path
212
+ * The path to the properties file for Init_File, or the
213
+ * environment variable to read to obtain the location of the path
214
+ * for Init_Environment.
215
+ */
216
+ I_T_RETURN FUNCEXP
217
+ I_C_Initialize(I_T_InitializationSource source,
218
+ const I_T_CHAR * path);
219
+
220
+
221
+ /*! Close the library
222
+ */
223
+ I_T_RETURN FUNCEXP
224
+ I_C_Fini(void);
225
+
226
+
227
+ /*! Open a new session
228
+ *
229
+ * \param session
230
+ * A pointer to a new session object to be returned.
231
+ * \param authType
232
+ * The session authentication type.
233
+ * \param username
234
+ * The username for the session.
235
+ * \param authToken
236
+ * The user's authentication information (i.e., password).
237
+ */
238
+ I_T_RETURN FUNCEXP
239
+ I_C_OpenSession(I_O_Session * session,
240
+ I_T_AuthType authType,
241
+ const I_T_CHAR * username,
242
+ const I_T_CHAR * authToken);
243
+
244
+
245
+ /*! Open a new session with a persistent cache passphrase
246
+ *
247
+ * \param session
248
+ * A pointer to a new session object to be returned.
249
+ * \param authType
250
+ * The session authentication type.
251
+ * \param username
252
+ * The username for the session.
253
+ * \param authToken
254
+ * The user's authentication information (i.e., password).
255
+ * \param passphrase
256
+ * A pointer to the passphrase
257
+ * \param passphraseLength
258
+ * The length of the passphrase
259
+ */
260
+ I_T_RETURN FUNCEXP
261
+ I_C_OpenSessionPersistentCachePassphrase(I_O_Session * session,
262
+ I_T_AuthType authType,
263
+ const I_T_CHAR * username,
264
+ const I_T_CHAR * authToken,
265
+ const I_T_BYTE * passphrase,
266
+ const I_T_UINT passphraseLength);
267
+
268
+ /*!Passphrase callback.
269
+ * \param Session : The current session.
270
+ * \param passphrase : Buffer area to copy passphrase into.
271
+ * \param passphrase_len : Size of buffer allocated. Put passphrase length here.
272
+ */
273
+ typedef int (*I_C_PersistentCacheCallback)(I_O_Session session,
274
+ unsigned char * const passphrase,
275
+ unsigned int * const passphrase_len);
276
+
277
+ /*! Open a new session supplying a persistent cache callback function.
278
+ *
279
+ * \param session
280
+ * A pointer to a new session object to be returned.
281
+ * \param authType
282
+ * The session authentication type.
283
+ * \param username
284
+ * The username for the session.
285
+ * \param authToken
286
+ * The user's authentication information (i.e., password).
287
+ * \param callbackFunction
288
+ * A callback function to be called for perisistent cache access.
289
+ */
290
+ I_T_RETURN FUNCEXP
291
+ I_C_OpenSessionPersistentCacheCallback(I_O_Session * session,
292
+ I_T_AuthType authType,
293
+ const I_T_CHAR * username,
294
+ const I_T_CHAR * authToken,
295
+ I_C_PersistentCacheCallback callbackFunction);
296
+
297
+ /*! Close a session
298
+ *
299
+ * \param session The session to close.
300
+ */
301
+ I_T_RETURN FUNCEXP
302
+ I_C_CloseSession(I_O_Session session);
303
+
304
+
305
+ /*! Get the most recent error code for a session
306
+ *
307
+ * \param session The session.
308
+ * \param errorCode A pointer to the returned error code.
309
+ */
310
+ I_T_RETURN FUNCEXP
311
+ I_C_GetLastError(I_O_Session session,
312
+ I_T_RETURN * errorCode);
313
+
314
+
315
+ /*! Get an error message string corresponding to an error code
316
+ *
317
+ * Returns the error string or NULL if the error code is invalid.
318
+ *
319
+ * \param errorCode The error code to retrieve the string for.
320
+ */
321
+ I_T_PCCHAR FUNCEXP
322
+ I_C_GetErrorString(I_T_RETURN errorCode);
323
+
324
+
325
+ /*! Create a CipherSpec object
326
+ *
327
+ * A CipherSpec defines an algorithm and key. It may be reused in multiple
328
+ * crypto operations and may be used in more than one operation at a time.
329
+ *
330
+ * \param longAlgorithmName
331
+ * A full algorithm specification, such as "AES/CBC/PKCS5Padding".
332
+ * \param keyName
333
+ * The key name.
334
+ * \param cipher
335
+ * A pointer to an I_O_CipherSpec to hold the returned object.
336
+ */
337
+ I_T_RETURN FUNCEXP
338
+ I_C_CreateCipherSpec(const I_T_CHAR * longAlgorithmName,
339
+ const I_T_CHAR * keyName,
340
+ I_O_CipherSpec * cipher);
341
+
342
+
343
+ /*! Delete a CipherSpec object
344
+ *
345
+ * \param cipher The object to delete.
346
+ */
347
+ I_T_RETURN FUNCEXP
348
+ I_C_DeleteCipherSpec(I_O_CipherSpec cipher);
349
+
350
+ /*! Get the size the output will be when operated using a given cipher
351
+ *
352
+ * \param cipher The cipher spec.
353
+ * \param operation The operation that will be performed.
354
+ * \param inputSize The size of the plaintext in bytes.
355
+ * \param outputSize The returned ciphertext size in bytes.
356
+ */
357
+ I_T_RETURN FUNCEXP I_C_CalculateOutputSize(I_O_CipherSpec cipher,
358
+ I_T_Operation operation,
359
+ I_T_UINT inputSize,
360
+ I_T_UINT * outputSize);
361
+
362
+ /*! Get the size the output will be when operated using a given cipher. This function
363
+ * supports Versioned keys.
364
+ *
365
+ * \param session The session.
366
+ * \param cipher The cipher spec.
367
+ * \param operation The operation that will be performed.
368
+ * \param inputSize The size of the plaintext in bytes.
369
+ * \param outputSize The returned ciphertext size in bytes.
370
+ */
371
+ I_T_RETURN FUNCEXP I_C_CalculateOutputSizeForKey(I_O_Session session,
372
+ I_O_CipherSpec cipher,
373
+ I_T_Operation operation,
374
+ I_T_UINT inputSize,
375
+ I_T_UINT * outputSize);
376
+
377
+
378
+ /*! Get the block size of a cipher
379
+ *
380
+ * \param cipher The cipher spec.
381
+ * \param blockSize The returned cipher block size in bytes.
382
+ */
383
+ I_T_RETURN FUNCEXP
384
+ I_C_GetCipherBlockSize(I_O_CipherSpec cipher,
385
+ I_T_UINT * blockSize);
386
+
387
+
388
+ /*! Create a KeyInfo object
389
+ *
390
+ * \param shortAlgorithmName
391
+ * A cryptographic algorithm name, such as "AES" or "DES".
392
+ * \param keySizeInBits
393
+ * The key size in bits. Use 168 for triple DES.
394
+ * \param exportable
395
+ * If true, allows the key to be exported (from a non-FIPS appliance).
396
+ * \param deletable
397
+ * If true, allows the key to be deleted.
398
+ * \param keyInfo
399
+ * A pointer to an I_O_KeyInfo to hold the returned object.
400
+ */
401
+ I_T_RETURN FUNCEXP
402
+ I_C_CreateKeyInfo(const I_T_CHAR * shortAlgorithmName,
403
+ I_T_UINT keySizeInBits,
404
+ I_T_BOOL exportable,
405
+ I_T_BOOL deletable,
406
+ I_O_KeyInfo * keyInfo);
407
+
408
+
409
+ /*! Delete a KeyInfo object
410
+ *
411
+ * \param keyInfo The object to delete.
412
+ */
413
+ I_T_RETURN FUNCEXP
414
+ I_C_DeleteKeyInfo(I_O_KeyInfo keyInfo);
415
+
416
+
417
+ /*! Create a GroupList object
418
+ *
419
+ * A GroupList is a list of user groups and their associated permissions,
420
+ * which allow access to key operations.
421
+ *
422
+ * \param groupList
423
+ * A pointer to an I_O_GroupList to hold the returned object.
424
+ */
425
+ I_T_RETURN FUNCEXP
426
+ I_C_CreateGroupListObject(I_O_GroupList * groupList);
427
+
428
+
429
+ /*! Add a group to a GroupList
430
+ *
431
+ * \param groupList
432
+ * The GroupList in which to add the group.
433
+ * \param groupName
434
+ * The name of the group.
435
+ * \param permissionMask
436
+ * The permissions for the group, such as
437
+ * I_T_Permission_Encrypt|I_T_Permission_Decrypt.
438
+ */
439
+ I_T_RETURN FUNCEXP
440
+ I_C_AddGroupToObject(I_O_GroupList groupList,
441
+ const I_T_CHAR * groupName,
442
+ I_T_UINT permissionMask);
443
+
444
+
445
+ /*! Delete a GroupList object
446
+ *
447
+ * \param groupList The object to delete.
448
+ */
449
+ I_T_RETURN FUNCEXP
450
+ I_C_DeleteGroupListObject(I_O_GroupList groupList);
451
+
452
+
453
+ /*! Create a key.
454
+ *
455
+ * To create a versioned key, append a # to the end of the keyName parameter.
456
+ * This feature is for versions of the NAE server that support versioned keys.
457
+ *
458
+ * \param session The session.
459
+ * \param keyName The name for the new key.
460
+ * \param keyInfo A KeyInfo object (see I_C_CreateKeyInfo()).
461
+ * \param groupList A GroupList object (see I_C_CreateGroupListObject()).
462
+ */
463
+ I_T_RETURN FUNCEXP
464
+ I_C_CreateKey(I_O_Session session,
465
+ const I_T_CHAR * keyName,
466
+ I_O_KeyInfo keyInfo,
467
+ I_O_GroupList groupList);
468
+
469
+
470
+ /*! Destroy a key on the cluster of servers
471
+ *
472
+ * \param session
473
+ * The session.
474
+ * \param keyName
475
+ * The name of the key to irretrievably destroy, obliterating its
476
+ * bits from the universe forever.
477
+ */
478
+ I_T_RETURN FUNCEXP
479
+ I_C_DestroyKey(I_O_Session session,
480
+ const I_T_CHAR * keyName);
481
+
482
+
483
+ /*! Export the public portion of an RSA key pair
484
+ *
485
+ * \param session The session.
486
+ * \param keyName The name of the RSA key to export.
487
+ * \param keyBytes A pointer to the returned RSA public key.
488
+ * The memory pointed to is allocated
489
+ * by this function. The function I_C_Free()
490
+ * should be used to deallocate the memory.
491
+ */
492
+ I_T_RETURN FUNCEXP
493
+ I_C_ExportPublicKey(I_O_Session session,
494
+ const I_T_CHAR * keyName,
495
+ I_T_CHAR ** keyBytes);
496
+
497
+
498
+ /* Synchronous Crypto APIs */
499
+
500
+ /*! Generate random bytes
501
+ *
502
+ * \param session The session.
503
+ * \param randomLength The number of random bytes to be returned.
504
+ * \param outData A buffer to hold returned bytes.
505
+ */
506
+ I_T_RETURN FUNCEXP
507
+ I_C_Random(I_O_Session session,
508
+ I_T_UINT randomLength,
509
+ I_T_BYTE * outData);
510
+
511
+
512
+ /*! Encrypt data in a single chunk
513
+ *
514
+ * Use I_C_Crypt() to encrypt complete chunks of data less than 3K bytes
515
+ * when you want the results immediately. I_C_Crypt() blocks while
516
+ * waiting for the results.
517
+ *
518
+ * \param session The session.
519
+ * \param cipher The cipher spec.
520
+ * \param operation The crypto operation to perform.
521
+ * \param iv The initialization vector for CBC mode block ciphers.
522
+ * \param ivLen The length of the IV.
523
+ * \param inData The data to encrypt or decrypt.
524
+ * \param inDataLen The length of the input data.
525
+ * \param outData A buffer to hold the output data.
526
+ * \param outDataLen In: The length of outData.
527
+ * Out: The number of bytes returned.
528
+ */
529
+ I_T_RETURN FUNCEXP
530
+ I_C_Crypt(I_O_Session session,
531
+ I_O_CipherSpec cipher,
532
+ I_T_Operation operation,
533
+ const I_T_BYTE * iv,
534
+ I_T_UINT ivLen,
535
+ const I_T_BYTE * inData,
536
+ I_T_UINT inDataLen,
537
+ I_T_BYTE * outData,
538
+ I_T_UINT * outDataLen);
539
+
540
+
541
+ /*! Encrypt data with all active versions of a key
542
+ *
543
+ * Use I_C_CryptAllVersions() to encrypt complete chunks of data less than 3K
544
+ * bytes when you want the results immediately. I_C_CryptAllVersions() blocks
545
+ * while waiting for the results.
546
+ *
547
+ * \param session The session.
548
+ * \param cipher The cipher spec.
549
+ * \param operation The crypto operation to perform (encrypt only).
550
+ * \param numOps The number of elements in output data buffer.
551
+ * \param iv The initialization vector for CBC mode block ciphers.
552
+ * \param ivLen The length of the IV.
553
+ * \param inData The data to encrypt or decrypt.
554
+ * \param inDataLen The length of the input data.
555
+ * \param outData A buffer to hold the output data.
556
+ * \param outDataLen In: The length of outData.
557
+ * Out: The number of bytes returned.
558
+ *
559
+ * To determine the value of numOps (i.e., the number of active versioned keys)
560
+ * if unknown to the programmer, call I_C_CryptAllVersions with numOps == 0,
561
+ * iv, inData, outData, and outDataLen == NULL, and inDataLen == 0. On return,
562
+ * *numOps will have the number of active keys.
563
+ */
564
+ I_T_RETURN FUNCEXP
565
+ I_C_CryptAllVersions(I_O_Session session,
566
+ I_O_CipherSpec cipher,
567
+ I_T_Operation operation,
568
+ I_T_UINT* numOps,
569
+ const I_T_BYTE* iv,
570
+ I_T_UINT ivLen,
571
+ const I_T_BYTE* inData,
572
+ I_T_UINT inDataLen,
573
+ I_T_BYTE** outData,
574
+ I_T_UINT* outDataLen);
575
+
576
+ /*! Encrypt data in multiple chunks
577
+ *
578
+ * Use the Init/Update/Final interface (multiple updates are OK) when you
579
+ * want results back from part of your crypto operation before you have
580
+ * all the data ready, or if your data is larger than I_C_Crypt() will
581
+ * allow. I_C_CryptUpdate() and I_C_CryptFinal() block while waiting for
582
+ * the results.
583
+ */
584
+ I_T_RETURN FUNCEXP
585
+ I_C_CryptInit(I_O_Session session,
586
+ I_O_CipherSpec cipher,
587
+ I_T_Operation operation,
588
+ const I_T_BYTE * iv,
589
+ I_T_UINT ivLen,
590
+ I_O_CipherState * state);
591
+
592
+
593
+ I_T_RETURN FUNCEXP
594
+ I_C_CryptUpdate(I_O_Session session,
595
+ I_O_CipherState state,
596
+ const I_T_BYTE * inData,
597
+ I_T_UINT inDataLen,
598
+ I_T_BYTE * outData,
599
+ I_T_UINT * outDataLen);
600
+
601
+
602
+ I_T_RETURN FUNCEXP
603
+ I_C_CryptFinal(I_O_Session session,
604
+ I_O_CipherState state,
605
+ I_T_BYTE * outData,
606
+ I_T_UINT * outDataLen);
607
+
608
+
609
+ /*! Encrypt an array of data elements
610
+ *
611
+ * Use the Bulk interface to operate on a large array of data elements
612
+ * using the same key. Bulk is optimized for high throughput where
613
+ * latency is not a priority. If the ivFlag is I_T_IV_PerElement, then
614
+ * there should be the same number of IVs as the number of inData
615
+ * elements. If the ivFlag is I_T_IV_Single, then there should be one IV.
616
+ */
617
+ I_T_RETURN FUNCEXP
618
+ I_C_CryptBulk(I_O_Session session,
619
+ I_O_CipherSpec cipher,
620
+ I_T_Operation operation,
621
+ I_T_UINT numOps,
622
+ I_T_IVType ivFlag,
623
+ const I_T_BYTE ** ivs,
624
+ I_T_UINT ivLen,
625
+ const I_T_BYTE ** inData,
626
+ I_T_UINT * inDataLen,
627
+ I_T_BYTE ** outData,
628
+ I_T_UINT * outDataLen);
629
+
630
+ /*! Encrypt data in multiple chunks
631
+ *
632
+ * Use the Init/UpdateSend/UpdateRecv/Final interface (multiple updates are OK) when you
633
+ * want results back from part of your crypto operation before you have
634
+ * all the data ready, or if your data is larger than I_C_Crypt() will
635
+ * allow.
636
+ */
637
+
638
+ I_T_RETURN FUNCEXP
639
+ I_C_CryptUpdateSend(I_O_Session handle,
640
+ I_O_CipherState state,
641
+ const I_T_BYTE * InData,
642
+ I_T_UINT InDataLen);
643
+
644
+ I_T_RETURN FUNCEXP
645
+ I_C_CryptUpdateRecv(I_O_Session handle,
646
+ I_O_CipherState state,
647
+ I_T_BYTE * OutData,
648
+ I_T_UINT *OutDataLen);
649
+
650
+ I_T_RETURN FUNCEXP
651
+ I_C_CryptRecvOK(I_O_Session session,
652
+ I_O_CipherState state);
653
+
654
+ /*! Get the attributes of a user
655
+ *
656
+ * \param session
657
+ * A pointer to the current session.
658
+ * \param username
659
+ * The user whose attributes should be retrieved.
660
+ * If a null pointer is sent, then the attributes
661
+ * of the logged in user are retrieved.
662
+ * All users may retrieve their own attributes.
663
+ * Only users with administrative privileges
664
+ * may retrieve attributes of other users.
665
+ * \param pSystemAttributeList
666
+ * On output, *pSystemAttributeList contains a pointer
667
+ * to an AttributeList of the system attributes
668
+ *
669
+ * The attribute names returned are:
670
+ * "ModifyUserInfo" - Whether the user can modify
671
+ * certain user attributes ( currently
672
+ * limited to password )
673
+ * "Group" - A group the user belongs to. Multiple
674
+ * instances are possible - one for each
675
+ * group the user belongs to.
676
+ * "User" - The name of the connected user.
677
+ * \param pCustomAttributeList
678
+ * On output, *pCustomAttributeList contains a pointer
679
+ * to an AttributeList of the custom attributes
680
+ *
681
+ *
682
+ */
683
+ I_T_RETURN FUNCEXP
684
+ I_C_GetUserAttributes(I_O_Session session,
685
+ const I_T_CHAR * username,
686
+ I_O_AttributeList *pSystemAttributeList,
687
+ I_O_AttributeList *pCustomAttributeList);
688
+
689
+ /*! Get the attributes of a key
690
+ *
691
+ * \param session
692
+ * A pointer to the current session.
693
+ * \param keyName
694
+ * A pointer to the key whose attributes
695
+ * should be retrieved.
696
+ * \param pSystemAttributeList
697
+ * On output, *pSystemAttributeList contains a pointer
698
+ * to an attribute list of the system attributes
699
+ *
700
+ * The attribute names returned are:
701
+ * "KeySize" - The size of the key (in bits)
702
+ * "Algorithm" - An algorithm that can be used
703
+ * with the key.
704
+ * Multiple instances may be present -
705
+ * one for each supported algorithm.
706
+ * "Fingerprint" - A hash of the key bytes
707
+ * The following attributes can only be "true" or "false"
708
+ * "Deletable" - Can this key be deleted?
709
+ * "Exportable" - Can this key be exported?
710
+ * "Encrypt" - Can session user encrypt with this key?
711
+ * "Decrypt" - Can session user decrypt with this key?
712
+ * "Sign" - Can session user sign with this key?
713
+ * "SignV" - Can session user verify signature with this key?
714
+ * "MAC" - Can session user compute a MAC with this key?
715
+ * "MACV" - Can session user verify a MAC with this key?
716
+ * "UsePrivate" - Can session user decrypt with the private key?
717
+ * "UsePublic" - Can session user encrypt with the public key?
718
+ *
719
+ * \param pCustomAttributeList
720
+ * On output, *pCustomAttributeList contains a pointer
721
+ * to an attribute list of the custom attributes
722
+ *
723
+ * The user must be the owner of the key, or must have access
724
+ * granted to the key.
725
+ *
726
+ */
727
+ I_T_RETURN FUNCEXP
728
+ I_C_GetKeyAttributes(I_O_Session session,
729
+ const I_T_CHAR * keyName,
730
+ I_O_AttributeList *pSystemAttributeList,
731
+ I_O_AttributeList *pCustomAttributeList);
732
+
733
+ /*! Export key bytes of a symmetric key.
734
+ *
735
+ * \param session
736
+ * A pointer to the current session.
737
+ * \param keyName
738
+ * A pointer to the name of the key that should
739
+ * should be exported. The key must be exportable.
740
+ * \param ppkeyBytes
741
+ * On output, *ppKeyBytes will be assigned a pointer to the
742
+ * key bytes of the key. The memory pointed to is allocated
743
+ * by this function. The function I_C_Free() should be
744
+ * to deallocate the memory.
745
+ * \param CustomAttributeList
746
+ * On output, *pKeyBytesLen will be assigned the number
747
+ * of key bytes of the key.
748
+ *
749
+ * The user must be the owner of the key or must have permission
750
+ * to export the key.
751
+ *
752
+ */
753
+ I_T_RETURN FUNCEXP
754
+ I_C_ExportSymmetricKey(I_O_Session session,
755
+ const I_T_CHAR * keyName,
756
+ I_T_BYTE ** ppKeyBytes,
757
+ I_T_UINT * pKeyBytesLen);
758
+
759
+ /*! Export Wrapped Key.
760
+ *
761
+ * \param session
762
+ * A pointer to the current session.
763
+ * \param keyName
764
+ * A pointer to the name of the key that should
765
+ * should be exported. The key must be exportable.
766
+ * \param wrapPublicKey
767
+ * A Public key to be used for wrapping.
768
+ * \param wrapPublicKeyLen
769
+ * Buffer length of Public key or certificate.
770
+ * \param wrapFormat
771
+ * Decides how to encode the key prior to wrapping
772
+ * and how to encrypt the wrapped key.
773
+ * \param ppWrappedKeyBytes
774
+ * On output, *ppWrappedKeyBytes will be assigned a
775
+ * pointer to the wrapped key bytes of the key. The memory
776
+ * pointed to is allocated by this function. The function
777
+ * I_C_Free() should be to deallocate the memory.
778
+ * \param pWrappedKeyBytesLen
779
+ * On output, *pWrappedKeyBytes will be assigned the number
780
+ * of key bytes of the key.
781
+ *
782
+ */
783
+
784
+ I_T_RETURN FUNCEXP
785
+ I_C_ExportWrappedKey(I_O_Session handle,
786
+ const I_T_CHAR * keyName,
787
+ const I_T_BYTE* wrapPublicKey,
788
+ const I_T_UINT wrapPublicKeyLen,
789
+ const I_T_KeyWrapFormat wrapFormat,
790
+ I_T_BYTE ** ppWrappedKeyBytes,
791
+ I_T_UINT *pWrappedKeyBytesLen);
792
+
793
+
794
+ /*! Clone oldKeyname to newKeyname
795
+ *
796
+ * \param session
797
+ * A pointer to the current session.
798
+ * \param keyName
799
+ * A pointer to the name of the key that should.
800
+ * should be cloned.
801
+ * \param newKeyName
802
+ * A pointer to the name of the new clone.
803
+ */
804
+ I_T_RETURN FUNCEXP
805
+ I_C_CloneKey(I_O_Session handle,
806
+ const I_T_CHAR * keyName,
807
+ const I_T_CHAR * newKeyName);
808
+
809
+ /*! Create an I_O_AttributeList object.
810
+ *
811
+ * \param pCustomAttributeList
812
+ * On output, a pointer to a newly created I_O_AttributeList
813
+ * will be stored in *pAttributeList.
814
+ */
815
+ I_T_RETURN FUNCEXP
816
+ I_C_CreateCustomAttributeList(I_O_AttributeList * pCustomAttributeList);
817
+
818
+ /*! Add an attribute to an I_O_AttributeList object
819
+ *
820
+ * \param customAttributeList
821
+ * An attribute list object to which an attribute should be added.
822
+ * Note that only a custom attribute list may be passed.
823
+ * \param attributeName
824
+ * The name of the attribute. The name must be null terminated
825
+ * strings of at most 64 characters (excluding null termination)
826
+ * and may only contain the following characters:
827
+ * - letters 'a' thru 'z'
828
+ * - letters 'A' thru 'Z'
829
+ * - numerals '0' thru '9'
830
+ * - underscore '_'
831
+ * - hyphen '-'
832
+ * - period '.'
833
+ * The name must start with an alphabetic character.
834
+ * \param attributeValue
835
+ * The value of the attribute.
836
+ * A new attribute will be added to the attribute list
837
+ * if an attribute with the attributeName does not exist.
838
+ * otherwise the value of that attribute will be overwritten
839
+ * with attributeValue.
840
+ * The value must not contain more than 1024 characters,
841
+ * and must be null-terminated strings of 7-bit US ASCII
842
+ * characters.
843
+ */
844
+ I_T_RETURN FUNCEXP
845
+ I_C_AddToAttributeList(I_O_AttributeList customAttributeList,
846
+ const I_T_CHAR * attributeName,
847
+ const I_T_CHAR * attributeValue);
848
+
849
+ /*! Find an attribute value in an I_O_AttributeList object
850
+ *
851
+ * \param attributeList
852
+ * An AttributeList object.
853
+ * \param attributeName
854
+ * The name of the attribute whose value must
855
+ * be found.
856
+ * Both custom and system attribute lists may be passed.
857
+ * \param ppAttributeValue
858
+ * If attributeList contains an attribute with the attributeName,
859
+ * I_E_OK is returned and *ppAttributeValue
860
+ * contains a pointer to the value of the attribute.
861
+ * Otherwise, I_E_END is returned.
862
+ */
863
+ I_T_RETURN FUNCEXP
864
+ I_C_FindInAttributeList(I_O_AttributeList attributeList,
865
+ const I_T_CHAR * attributeName,
866
+ I_T_CHAR ** ppAttributeValue);
867
+
868
+ /*! Retrieve the value of a specific instance of an attribute
869
+ * with the given attributeName.
870
+ * Meant for use with an attributeList that may contain multiple
871
+ * instances of attributes with the same attributeName.
872
+ * Typically used to retrieve the values of all instances
873
+ * of an attributeName.
874
+ *
875
+ * \param attributeList
876
+ * An AttributeList object.
877
+ * Only system attribute lists may be passed.
878
+ * \param attributeName
879
+ * The name of the attribute whose value for a specific
880
+ * instance is to be retrieved.
881
+ * \param ppAttributeValue
882
+ * If attributeList contains the specific instance of
883
+ * an attribute with the attributeName,
884
+ * I_E_OK is returned and *ppAttributeValue
885
+ * contains a pointer to the value of the attribute.
886
+ * Otherwise, I_E_END is returned.
887
+ * There are no "holes" - the lowest value of the
888
+ * parameter instance that causes an I_E_END represents
889
+ * one more than the number of instances
890
+ * that exist with the given attributeName.
891
+ * \param instanceNumber
892
+ * The specific instance of the attribute with the
893
+ * attributeName whose value is to be retrieved.
894
+ * The instance numbering starts with 1 (not with zero!).
895
+ */
896
+ I_T_RETURN FUNCEXP
897
+ I_C_FindInstanceInAttributeList(I_O_AttributeList attributeList,
898
+ const I_T_CHAR * attributeName,
899
+ I_T_CHAR ** ppAttributeValue,
900
+ I_T_UINT instanceNumber);
901
+
902
+ /*! Remove an attribute from an I_O_AttributeList object
903
+ * \param customAttributeList
904
+ * An attribute list object from which to remove an attribute.
905
+ * Note that only a custom attribute list may be passed.
906
+ * \param attributeName
907
+ * The name of the attribute that should be removed.
908
+ * All attribute instances with the name will be removed.
909
+ */
910
+ I_T_RETURN FUNCEXP
911
+ I_C_RemoveFromAttributeList(I_O_AttributeList customAttributeList,
912
+ const I_T_CHAR * attributeName);
913
+
914
+ /*! Destroy an AttributeList object and release resources
915
+ * \param attributeList
916
+ * The AttributeList object to be destroyed.
917
+ * Both custom and system attribute lists may be passed.
918
+ */
919
+ I_T_RETURN FUNCEXP
920
+ I_C_DeleteAttributeList(I_O_AttributeList attributeList);
921
+
922
+ /*! Return information about the encryption provider.
923
+ *
924
+ * As the client can connect to many servers in active and passive failover,
925
+ * the values returned from this will change randomly for any given call
926
+ * depending on which server connection is used.
927
+ *
928
+ * \param session The current session.
929
+ * \param software_version OUT: The version of the software on the NAE server.
930
+ * \param library_version OUT: library versionperform.
931
+ * \param vendor_ID OUT: The name of the vendor.
932
+ * \param model_number OUT: The model number of the server (e.g. "i321")
933
+ * \param serial_number OUT: The serial number (or Box ID) of the NAE server.
934
+ * \param datetime OUT: Timestamp from the server in GMT.
935
+ */
936
+ I_T_RETURN FUNCEXP
937
+ I_C_GetKeyManagerInfo(I_O_Session session,
938
+ /* OUT: */
939
+ I_T_CHAR ** software_version,
940
+ I_T_CHAR ** library_version,
941
+ I_T_CHAR ** vendor_ID,
942
+ I_T_CHAR ** model_number,
943
+ I_T_CHAR ** serial_number,
944
+ I_T_CHAR ** datetime);
945
+
946
+ /*! Log a message on the server.
947
+ *
948
+ * \param session : The current session.
949
+ * \param logMessage : A message to log on the server.
950
+ */
951
+ I_T_RETURN FUNCEXP
952
+ I_C_LogEvent(I_O_Session session,
953
+ const I_T_CHAR * logMessage);
954
+
955
+ /*! Set custom attributes of the key on the server
956
+ *
957
+ * \param session : The current session.
958
+ * \param keyname : The name of the key.
959
+ * \param clearExistingAttributes : Removes existing attributes before setting
960
+ * the given attribute list. Setting this to
961
+ * false will have the passed customAttributeList
962
+ * list merged with the existing values with
963
+ * any common names being overwritten.
964
+ * \param customAttributeList : The new attribute list.
965
+ *
966
+ * Only the owner of the key may modify the attributes.
967
+ */
968
+ I_T_RETURN FUNCEXP
969
+ I_C_SetKeyAttributes(I_O_Session session,
970
+ const I_T_CHAR * keyname,
971
+ I_T_BOOL clearExistingAttributes,
972
+ I_O_AttributeList customAttributeList);
973
+
974
+
975
+ /*!Import a key to the server.
976
+ *
977
+ * \param session : The current session.
978
+ * \param keyname : The name of the new key
979
+ * \param keyBytes : The key bytes to use for the new key
980
+ * \param keyBytesLen : The length of the keyBytes array
981
+ * \param keyInfo : The keyInfo (algorithm name, key size, etc) for the key.
982
+ * \param grouplist : A GroupList object (see I_C_CreateGroupListObject()).
983
+ */
984
+ I_T_RETURN FUNCEXP
985
+ I_C_ImportKey(I_O_Session session,
986
+ const I_T_CHAR *keyname,
987
+ I_T_BYTE *keyBytes,
988
+ I_T_UINT keyBytesLen,
989
+ I_O_KeyInfo keyinfo,
990
+ I_O_GroupList grouplist);
991
+
992
+
993
+ /*! Return the length of the cipher text's header (aka, tag).
994
+ *
995
+ * \param session
996
+ * The current session.
997
+ * \param cipher
998
+ * The cipher spec.
999
+ * \param cipherText
1000
+ * A pointer to a buffer containing tagged cipher text. Must not be NULL
1001
+ * \param cipherTextLen
1002
+ * The length of the cipherText. Must be greater than zero.
1003
+ * \param cipherHeaderLen
1004
+ * On output, cipherHeaderLen will be assigned the number of bytes
1005
+ * consumed by the tag. Must not be NULL.
1006
+ */
1007
+ I_T_RETURN FUNCEXP
1008
+ I_C_GetCiphertextHeaderLength(I_O_Session session,
1009
+ I_O_CipherSpec cipher,
1010
+ const I_T_BYTE * cipherText,
1011
+ I_T_UINT cipherTextLen,
1012
+ I_T_UINT * cipherHeaderLen);
1013
+
1014
+ /*!Deallocate memory
1015
+ *
1016
+ * \param vp : A void pointer. The memory pointed to
1017
+ * will be deallocated.
1018
+ *
1019
+ * Deallocates memory allocated by some ICAPI functions.
1020
+ *
1021
+ */
1022
+ I_T_RETURN FUNCEXP
1023
+ I_C_Free(void *vp);
1024
+
1025
+
1026
+
1027
+ /*!Modifies a key's lifecycle state or version.
1028
+ *
1029
+ * \param session
1030
+ * The current session.
1031
+ * \param keyName
1032
+ * The key name. When the keyParameterType == I_T_KeyLifecycleState,
1033
+ * keyname should be in the format, "key_name#number_to_alter". For
1034
+ * example, given the key name for the versioned key, "SecureKey", and
1035
+ * and the version to modify is, say, 3, keyname should be "SecureKey#3".
1036
+ * When keyParameterType == I_T_KeyVersion, keyname should be in the
1037
+ * format, "key_name", without the "#" and version number.
1038
+ * \param keyParameterType
1039
+ * The parameter type being modified. See the typedef enum for
1040
+ * I_T_KeyParameterType for valid values.
1041
+ * \param keyParameterValue
1042
+ * The key parameter type. See the typedef enum for
1043
+ * I_T_KeyParameterValueEnum.
1044
+ *
1045
+ * Increments key versions, or alters key lifecycle states.
1046
+ *
1047
+ */
1048
+ I_T_RETURN FUNCEXP
1049
+ I_C_SetKeyParameter(I_O_Session session,
1050
+ const I_T_CHAR *keyname,
1051
+ I_T_KeyParameterType keyParameterType,
1052
+ I_T_KeyParameterValue keyParameterValue);
1053
+
1054
+ /*!Destroys a certificate.
1055
+ *
1056
+ * \param sessionHandle
1057
+ * The current session.
1058
+ * \param certificateName
1059
+ * The name of the certificate to delete.
1060
+ *
1061
+ */
1062
+ I_T_RETURN FUNCEXP
1063
+ I_C_DestroyCertificate(I_O_Session sessionHandle,
1064
+ const I_T_CHAR * certificateName);
1065
+
1066
+
1067
+ /*!Export a certificate to a specified format.
1068
+ *
1069
+ * \param sessionHandle
1070
+ * The current session.
1071
+ * \param certificateName
1072
+ * The name of the certificate to export.
1073
+ * \param exportFormat
1074
+ * Format of the exported certificate data.
1075
+ * \param password
1076
+ * Password required when exporting to PKCS#12 format.
1077
+ * \param data
1078
+ * Output buffer that will receive certificate data. The function will
1079
+ * allocate the memory, and it should be freed using I_C_Free when done.
1080
+ * to free the data.
1081
+ * \param dataSize
1082
+ * On input, this parameter specifies the size of the data buffer.
1083
+ * On output, this parameter is set to number of bytes actually
1084
+ * written to the output data buffer.
1085
+ *
1086
+ */
1087
+ I_T_RETURN FUNCEXP
1088
+ I_C_ExportCertificate(I_O_Session sessionHandle,
1089
+ const I_T_CHAR * certificateName,
1090
+ I_T_ExportFormat exportFormat,
1091
+ const I_T_CHAR * password,
1092
+ I_T_CHAR ** data,
1093
+ I_T_UINT * dataSize);
1094
+
1095
+ /*!Export a CA chain to a specified format.
1096
+ *
1097
+ * \param sessionHandle
1098
+ * The current session.
1099
+ * \param caName
1100
+ * The name of the certificate for which CA chain is exported.
1101
+ * \param data
1102
+ * Output buffer that will receive CA chain data. The function will
1103
+ * allocate the memory, and it should be freed using I_C_Free when done.
1104
+ * \param dataSize
1105
+ * On input, this parameter specifies the size of the data buffer.
1106
+ * On output, this parameter is set to number of bytes actually
1107
+ * written to the output data buffer.
1108
+ *
1109
+ */
1110
+ I_T_RETURN FUNCEXP
1111
+ I_C_ExportCAChain(I_O_Session sessionHandle,
1112
+ const I_T_CHAR * caName,
1113
+ I_T_CHAR ** data,
1114
+ I_T_UINT * dataSize);
1115
+
1116
+
1117
+ /*!Import a certificate.
1118
+ *
1119
+ * \param sessionHandle
1120
+ * The current session.
1121
+ * \param certificateName
1122
+ * Name of the certificate to import.
1123
+ * \param deletableFlag
1124
+ * Specify if this certificate can be deleted from the server.
1125
+ * \param exportableFlag
1126
+ * Specify if this certificate can be exported from the server
1127
+ * \param grouplist
1128
+ * A GroupList object (see I_C_CreateGroupListObject()).
1129
+ * \param password
1130
+ * Password required when exporting to PKCS#12 format.
1131
+ * \param data
1132
+ * Input certificate data.
1133
+ * \param dataSize
1134
+ * Size of the import certificate.
1135
+ *
1136
+ */
1137
+ I_T_RETURN FUNCEXP
1138
+ I_C_ImportCertificate(I_O_Session sessionHandle,
1139
+ const I_T_CHAR * certificateName,
1140
+ I_T_BOOL deletableFlag,
1141
+ I_T_BOOL exportableFlag,
1142
+ I_O_GroupList groupList,
1143
+ const I_T_CHAR * password,
1144
+ I_T_CHAR * data,
1145
+ I_T_UINT dataSize);
1146
+
1147
+
1148
+ /* Deprecated Functions - Begin */
1149
+
1150
+ /* Note : This function is deprecated. Use I_C_CalculateOutputSize().
1151
+ * ! Get the size the ciphertext will be when encrypted using a given cipher
1152
+ *
1153
+ * \param cipher The cipher spec.
1154
+ * \param operation The operation that will be performed.
1155
+ * \param plaintextSize The size of the plaintext in bytes.
1156
+ * \param ciphertextSize The returned ciphertext size in bytes.
1157
+ */
1158
+ I_T_RETURN FUNCEXP
1159
+ I_C_CalculateEncipheredSize(I_O_CipherSpec cipher,
1160
+ I_T_Operation operation,
1161
+ I_T_UINT plaintextSize,
1162
+ I_T_UINT * ciphertextSize);
1163
+
1164
+
1165
+ /* Note : This function is deprecated. Use I_C_CalculateOutputSizeForKey().
1166
+ * ! Get the size the ciphertext will be when encrypted using a given cipher
1167
+ *
1168
+ * \param session The session.
1169
+ * \param cipher The cipher spec.
1170
+ * \param operation The operation that will be performed.
1171
+ * \param plaintextSize The size of the plaintext in bytes.
1172
+ * \param ciphertextSize The returned ciphertext size in bytes.
1173
+ */
1174
+ I_T_RETURN FUNCEXP
1175
+ I_C_CalculateEncipheredSizeForKey(I_O_Session session,
1176
+ I_O_CipherSpec cipher,
1177
+ I_T_Operation operation,
1178
+ I_T_UINT plaintextSize,
1179
+ I_T_UINT * ciphertextSize);
1180
+
1181
+ /* Deprecated Functions - End */
1182
+
1183
+ #ifdef __cplusplus
1184
+ }
1185
+ #endif /* __cplusplus */
1186
+
1187
+ #endif /* IngrianICAPI */