forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
graphene-pk11.d.ts
2277 lines (2161 loc) · 69.2 KB
/
graphene-pk11.d.ts
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Type definitions for graphene-pk11 v2.0.3
// Project: https://github.com/PeculiarVentures/graphene
// Definitions by: Stepan Miroshin <https://github.com/microshine>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../pkcs11js/pkcs11js.d.ts" />
/**
* A simple layer for interacting with PKCS #11 / PKCS11 / CryptoKI for Node
* v2.0.3
*/
declare module "graphene-pk11" {
import * as pkcs11 from "pkcs11js"
type Handle = Buffer;
type CryptoData = string | Buffer;
class Pkcs11Error extends Error {
code: number;
func: string;
constructor(code: number, func: string);
}
class BaseObject {
protected lib: pkcs11.PKCS11;
constructor(lib?: pkcs11.PKCS11);
}
class HandleObject extends BaseObject {
/**
* handle to pkcs11 object
*/
handle: Handle;
constructor(handle: Handle, lib: pkcs11.PKCS11);
protected getInfo(): void;
}
class Collection<T extends BaseObject> extends BaseObject {
protected items_: Array<any>;
protected classType: any;
/**
* returns length of collection
*/
length: number;
constructor(items: Array<any>, lib: pkcs11.PKCS11, classType: any);
/**
* returns item from collection by index
* @param {number} index of element in collection `[0..n]`
*/
items(index: number): T;
}
function isString(v: any): boolean;
function isNumber(v: any): boolean;
function isBoolean(v: any): boolean;
function isUndefined(v: any): boolean;
function isNull(v: any): boolean;
function isEmpty(v: any): boolean;
function isFunction(v: any): boolean;
function isObject(v: any): boolean;
function isArray(v: any): boolean;
function isFlag(v: any, fv: number): boolean;
function dateFromString(text: string): Date;
// ========== Crypto ==========
class Cipher extends BaseObject {
session: Session;
constructor(session: Session, alg: MechanismType, key: Key, lib: pkcs11.PKCS11);
protected init(alg: MechanismType, key: Key): void;
update(data: CryptoData): Buffer;
final(): Buffer;
once(data: CryptoData, enc: Buffer): Buffer;
once(data: CryptoData, enc: Buffer, cb: (error: Error, data: Buffer) => void): void;
}
class Decipher extends BaseObject {
protected session: Session;
protected blockSize: number;
constructor(session: Session, alg: MechanismType, key: Key, blockSize: number, lib: pkcs11.PKCS11);
protected init(alg: MechanismType, key: Key): void;
update(data: Buffer): Buffer;
final(): Buffer;
once(data: Buffer, dec: Buffer): Buffer;
once(data: Buffer, dec: Buffer, cb: (error: Error, data: Buffer) => void): void;
}
class Digest extends BaseObject {
session: Session;
constructor(session: Session, alg: MechanismType, lib: pkcs11.PKCS11);
protected init(alg: MechanismType): void;
update(data: CryptoData): void;
final(): Buffer;
once(data: CryptoData): Buffer;
once(data: CryptoData, cb: (error: Error, data: Buffer) => void): void;
}
class Sign extends BaseObject {
session: Session;
constructor(session: Session, alg: MechanismType, key: Key, lib: pkcs11.PKCS11);
protected init(alg: MechanismType, key: Key): void;
update(data: CryptoData): void;
final(): Buffer;
once(data: CryptoData): Buffer;
once(data: CryptoData, cb: (error: Error, data: Buffer) => void): void;
}
class Verify extends BaseObject {
session: Session;
constructor(session: Session, alg: MechanismType, key: Key, lib: pkcs11.PKCS11);
protected init(alg: MechanismType, key: Key): void;
update(data: CryptoData): void;
final(signature: Buffer): boolean;
once(data: CryptoData, signature: Buffer): boolean;
once(data: CryptoData, signature: Buffer, cb: (error: Error, valid: boolean) => void): void;
}
// ========== Keys ==========
interface IParams {
toCKI(): any;
}
enum MechParams {
AesCBC,
AesCCM,
AesGCM,
RsaOAEP,
RsaPSS,
EcDH,
}
// AES
class AesCbcParams implements IParams, pkcs11.AesCBC {
/**
* initialization vector
* - must have a fixed size of 16 bytes
*/
iv: Buffer;
/**
* the data
*/
data: Buffer;
type: MechParams;
constructor(iv: Buffer, data?: Buffer);
toCKI(): Buffer;
}
class AesCcmParams implements IParams {
/**
* length of the data where 0 <= dataLength < 2^8L
*/
dataLength: number;
/**
* the nonce
*/
nonce: Buffer;
/**
* the additional authentication data
* - This data is authenticated but not encrypted
*/
aad: Buffer;
/**
* length of authentication tag (output following cipher text) in bits.
* - Can be any value between 0 and 128
*/
macLength: number;
type: MechParams;
constructor(dataLength: number, nonce: Buffer, aad?: Buffer, macLength?: number);
toCKI(): pkcs11.AesCCM;
}
class AesGcmParams implements IParams {
/**
* initialization vector
* - The length of the initialization vector can be any number between 1 and 256.
* 96-bit (12 byte) IV values can be processed more efficiently,
* so that length is recommended for situations in which efficiency is critical.
*/
iv: Buffer;
/**
* pointer to additional authentication data.
* This data is authenticated but not encrypted.
*/
aad: Buffer;
/**
* length of authentication tag (output following cipher text) in bits.
* Can be any value between 0 and 128. Default 128
*/
tagBits: number;
type: MechParams;
constructor(iv: Buffer, aad?: Buffer, tagBits?: number);
toCKI(): pkcs11.AesGCM;
}
// EC
interface INamedCurve {
name: string;
oid: string;
value: Buffer;
size: number;
}
class NamedCurve {
static getByName(name: string): INamedCurve;
static getByOid(oid: string): INamedCurve;
}
enum EcKdf {
NULL,
SHA1,
SHA224,
SHA256,
SHA384,
SHA512,
}
class EcdhParams implements IParams, pkcs11.ECDH1 {
/**
* key derivation function used on the shared secret value
*/
kdf: EcKdf;
/**
* some data shared between the two parties
*/
sharedData: Buffer;
/**
* other party's EC public key value
*/
publicData: Buffer;
type: MechParams;
/**
* Creates an instance of EcdhParams.
*
* @param {EcKdf} kdf key derivation function used on the shared secret value
* @param {Buffer} [sharedData=null] some data shared between the two parties
* @param {Buffer} [publicData=null] other party's EC public key value
*/
constructor(kdf: EcKdf, sharedData?: Buffer, publicData?: Buffer);
toCKI(): pkcs11.ECDH1;
}
// Rsa
enum RsaMgf {
MGF1_SHA1,
MGF1_SHA224,
MGF1_SHA256,
MGF1_SHA384,
MGF1_SHA512,
}
class RsaOaepParams implements IParams {
hashAlgorithm: MechanismEnum;
mgf: RsaMgf;
source: number;
sourceData: Buffer;
type: MechParams;
constructor(hashAlg?: MechanismEnum, mgf?: RsaMgf, sourceData?: Buffer);
toCKI(): pkcs11.RsaOAEP;
}
class RsaPssParams implements IParams {
/**
* hash algorithm used in the PSS encoding;
* - if the signature mechanism does not include message hashing,
* then this value must be the mechanism used by the application to generate
* the message hash;
* - if the signature mechanism includes hashing,
* then this value must match the hash algorithm indicated
* by the signature mechanism
*/
hashAlgorithm: MechanismEnum;
/**
* mask generation function to use on the encoded block
*/
mgf: RsaMgf;
/**
* length, in bytes, of the salt value used in the PSS encoding;
* - typical values are the length of the message hash and zero
*/
saltLength: number;
type: MechParams;
constructor(hashAlg?: MechanismEnum, mgf?: RsaMgf, saltLen?: number);
toCKI(): pkcs11.RsaPSS;
}
// ========== Objects ==========
enum ObjectClass {
DATA,
CERTIFICATE,
PUBLIC_KEY,
PRIVATE_KEY,
SECRET_KEY,
HW_FEATURE,
DOMAIN_PARAMETERS,
MECHANISM,
OTP_KEY,
}
class SessionObject extends HandleObject {
/**
* Session
*/
session: Session;
/**
* gets the size of an object in bytes
*
* @readonly
* @type {number}
*/
size: number;
class: ObjectClass;
/**
* Creates an instance of SessionObject.
*
* @param {SessionObject} object
*/
constructor(object: SessionObject);
/**
* Creates an instance of SessionObject.
*
* @param {Handle} handle
* @param {Session} session
* @param {pkcs11.PKCS11} lib
*/
constructor(handle: Handle, session: Session, lib: pkcs11.PKCS11);
constructor(handle: SessionObject);
/**
* copies an object, creating a new object for the copy
*
* @param {ITemplate} template template for the new object
* @returns {SessionObject}
*/
copy(template: ITemplate): SessionObject;
/**
* destroys an object
*/
destroy(): void;
getAttribute(attr: string): ITemplate;
getAttribute(attrs: ITemplate): ITemplate;
setAttribute(attrs: string, value: any): void;
setAttribute(attrs: ITemplate): void;
get(name: string): any;
set(name: string, value: any): void;
toType<T extends SessionObject>(): T;
}
class SessionObjectCollection extends Collection<SessionObject> {
session: Session;
constructor(items: Array<Handle>, session: Session, lib: pkcs11.PKCS11, classType?: any);
items(index: number): SessionObject;
}
class Storage extends SessionObject {
/**
* `true` if object is a token object;
* `false` if object is a session object. Default is `false`.
*/
token: boolean;
/**
* `true` if object is a private object;
* `false` if object is a public object.
* Default value is token-specific, and may depend on the values of other attributes of the object.
*/
private: boolean;
/**
* `true` if object can be modified. Default is `false`
*/
modifiable: boolean;
/**
* Description of the object (default empty)
*/
label: string;
}
/**
* Data objects (object class `CKO_DATA`) hold information defined by an application.
* Other than providing access to it, Cryptoki does not attach any special meaning to a data object
*
* @export
* @class Data
* @extends {Storage}
*/
class Data extends Storage {
/**
* Description of the application that manages the object (default empty)
*
* @type {string}
*/
application: string;
/**
* DER-encoding of the object identifier indicating the data object type (default empty)
*
* @type {Buffer}
*/
objectId: Buffer;
/**
* Value of the object (default empty)
*
* @type {Buffer}
*/
value: Buffer;
}
class DomainParameters extends Storage {
/**
* Type of key the domain parameters can be used to generate.
*/
keyType: KeyType;
/**
* `CK_TRUE` only if domain parameters were either * generated locally (i.e., on the token)
* with a `C_GenerateKey` * created with a `C_CopyObject` call as a copy of domain parameters
* which had its `CKA_LOCAL` attribute set to `CK_TRUE`
*/
local: boolean;
}
enum KeyType {
RSA,
DSA,
DH,
ECDSA,
EC,
X9_42_DH,
KEA,
GENERIC_SECRET,
RC2,
RC4,
DES,
DES2,
DES3,
CAST,
CAST3,
CAST5,
CAST128,
RC5,
IDEA,
SKIPJACK,
BATON,
JUNIPER,
CDMF,
AES,
GOSTR3410,
GOSTR3411,
GOST28147,
BLOWFISH,
TWOFISH,
SECURID,
HOTP,
ACTI,
CAMELLIA,
ARIA,
}
enum KeyGenMechanism {
AES,
RSA,
RSA_X9_31,
DSA,
DH_PKCS,
DH_X9_42,
GOSTR3410,
GOST28147,
RC2,
RC4,
DES,
DES2,
SECURID,
ACTI,
CAST,
CAST3,
CAST5,
CAST128,
RC5,
IDEA,
GENERIC_SECRET,
SSL3_PRE_MASTER,
CAMELLIA,
ARIA,
SKIPJACK,
KEA,
BATON,
ECDSA,
EC,
JUNIPER,
TWOFISH,
}
/**
* Definition for the base key object class
* - defines the object class `CKO_PUBLIC_KEY`, `CKO_PRIVATE_KEY` and `CKO_SECRET_KEY` for type `CK_OBJECT_CLASS`
* as used in the `CKA_CLASS` attribute of objects
*/
class Key extends Storage {
/**
* Type of key
* - Must be specified when object is created with `C_CreateObject`
* - Must be specified when object is unwrapped with `C_UnwrapKey`
*/
type: KeyType;
/**
* Key identifier for key (default empty)
* - May be modified after object is created with a `C_SetAttributeValue` call,
* or in the process of copying object with a `C_CopyObject` call.
* However, it is possible that a particular token may not permit modification
* of the attribute during the course of a `C_CopyObject` call.
*/
id: Buffer;
/**
* Start date for the key (default empty)
* - May be modified after object is created with a `C_SetAttributeValue` call,
* or in the process of copying object with a `C_CopyObject` call.
* However, it is possible that a particular token may not permit modification
* of the attribute during the course of a `C_CopyObject` call.
*/
startDate: Date;
/**
* End date for the key (default empty)
* - May be modified after object is created with a `C_SetAttributeValue` call,
* or in the process of copying object with a `C_CopyObject` call.
* However, it is possible that a particular token may not permit modification
* of the attribute during the course of a `C_CopyObject` call.
*/
endDate: Date;
/**
* `CK_TRUE` if key supports key derivation
* (i.e., if other keys can be derived from this one (default `CK_FALSE`)
* - May be modified after object is created with a `C_SetAttributeValue` call,
* or in the process of copying object with a `C_CopyObject` call.
* However, it is possible that a particular token may not permit modification
* of the attribute during the course of a `C_CopyObject` call.
* @returns boolean
*/
derive: boolean;
/**
* `CK_TRUE` only if key was either * generated locally (i.e., on the token)
* with a `C_GenerateKey` or `C_GenerateKeyPair` call * created with a `C_CopyObject` call
* as a copy of a key which had its `CKA_LOCAL` attribute set to `CK_TRUE`
* - Must not be specified when object is created with `C_CreateObject`.
* - Must not be specified when object is generated with `C_GenerateKey` or `C_GenerateKeyPair`.
* - Must not be specified when object is unwrapped with `C_UnwrapKey`.
*/
local: boolean;
/**
* Identifier of the mechanism used to generate the key material.
* - Must not be specified when object is created with `C_CreateObject`.
* - Must not be specified when object is generated with `C_GenerateKey` or `C_GenerateKeyPair`.
* - Must not be specified when object is unwrapped with `C_UnwrapKey`.
*/
mechanism: KeyGenMechanism;
allowedMechanisms: void;
}
/**
* Private key objects (object class `CKO_PRIVATE_KEY`) hold private keys
*/
class PrivateKey extends Key {
/**
* DER-encoding of the key subject name (default empty)
* - May be modified after object is created with a `C_SetAttributeValue` call,
* or in the process of copying object with a `C_CopyObject` call.
* However, it is possible that a particular token may not permit modification of the attribute
* during the course of a `C_CopyObject` call.
*/
subject: Buffer;
/**
* `CK_TRUE` if key is sensitive
* - May be modified after object is created with a `C_SetAttributeValue` call,
* or in the process of copying object with a `C_CopyObject` call.
* However, it is possible that a particular token may not permit modification of the attribute
* during the course of a `C_CopyObject` call.
* - Attribute cannot be changed once set to CK_TRUE. It becomes a read only attribute.
* - Default value is token-specific, and may depend on the values of other attributes.
*/
sensitive: boolean;
/**
* `CK_TRUE` if key supports decryption
* - May be modified after object is created with a `C_SetAttributeValue` call,
* or in the process of copying object with a `C_CopyObject` call.
* However, it is possible that a particular token may not permit modification of the attribute
* during the course of a `C_CopyObject` call.
* - Default value is token-specific, and may depend on the values of other attributes.
*/
decrypt: boolean;
/**
* `CK_TRUE` if key supports signatures where the signature is an appendix to the data
* - May be modified after object is created with a `C_SetAttributeValue` call,
* or in the process of copying object with a `C_CopyObject` call.
* However, it is possible that a particular token may not permit modification of the attribute
* during the course of a `C_CopyObject` call.
* - Default value is token-specific, and may depend on the values of other attributes.
*/
sign: boolean;
/**
* `CK_TRUE` if key supports signatures where the data can be recovered from the signature
* - May be modified after object is created with a `C_SetAttributeValue` call,
* or in the process of copying object with a `C_CopyObject` call.
* However, it is possible that a particular token may not permit modification of the attribute
* during the course of a `C_CopyObject` call.
* - Default value is token-specific, and may depend on the values of other attributes.
*/
signRecover: boolean;
/**
* `CK_TRUE` if key supports unwrapping (i.e., can be used to unwrap other keys)
* - May be modified after object is created with a `C_SetAttributeValue` call,
* or in the process of copying object with a `C_CopyObject` call.
* However, it is possible that a particular token may not permit modification of the attribute
* during the course of a `C_CopyObject` call.
* - Default value is token-specific, and may depend on the values of other attributes.
*/
unwrap: boolean;
/**
* `CK_TRUE` if key is extractable and can be wrapped
* - May be modified after object is created with a `C_SetAttributeValue` call,
* or in the process of copying object with a `C_CopyObject` call.
* However, it is possible that a particular token may not permit modification of the attribute
* during the course of a `C_CopyObject` call.
* - Attribute cannot be changed once set to `CK_FALSE`. It becomes a read only attribute.
* - Default value is token-specific, and may depend on the values of other attributes.
*/
extractable: boolean;
/**
* `CK_TRUE` if key has always had the `CKA_SENSITIVE` attribute set to `CK_TRUE`
* - Must not be specified when object is created with `C_CreateObject`.
* - Must not be specified when object is generated with `C_GenerateKey` or `C_GenerateKeyPair`.
* - Must not be specified when object is unwrapped with `C_UnwrapKey`.
*/
alwaysSensitive: boolean;
/**
* `CK_TRUE` if key has never had the `CKA_EXTRACTABLE` attribute set to `CK_TRUE`
* - Must not be specified when object is created with `C_CreateObject`.
* - Must not be specified when object is generated with `C_GenerateKey` or `C_GenerateKeyPair`.
* - Must not be specified when object is unwrapped with `C_UnwrapKey`.
*/
neverExtractable: boolean;
/**
* `CK_TRUE` if the key can only be wrapped with a wrapping key
* that has `CKA_TRUSTED` set to `CK_TRUE`. Default is `CK_FALSE`.
* - Attribute cannot be changed once set to `CK_TRUE`. It becomes a read only attribute.
*/
wrapTrusted: boolean;
/**
* For wrapping keys. The attribute template to apply to any keys unwrapped
* using this wrapping key. Any user supplied template is applied after this template
* as if the object has already been created.
*/
template: void;
alwaysAuthenticate: boolean;
}
/**
* Public key objects (object class CKO_PUBLIC_KEY) hold public keys
*/
class PublicKey extends Key {
/**
* DER-encoding of the key subject name (default empty)
* - May be modified after object is created with a `C_SetAttributeValue` call,
* or in the process of copying object with a `C_CopyObject` call.
* However, it is possible that a particular token may not permit modification of the attribute
* during the course of a `C_CopyObject` call.
*/
subject: Buffer;
/**
* `CK_TRUE` if key supports encryption
* - May be modified after object is created with a `C_SetAttributeValue` call,
* or in the process of copying object with a `C_CopyObject` call.
* However, it is possible that a particular token may not permit modification of the attribute
* during the course of a `C_CopyObject` call.
* - Default value is token-specific, and may depend on the values of other attributes.
*/
encrypt: boolean;
/**
* `CK_TRUE` if key supports verification where the signature is an appendix to the data
* - May be modified after object is created with a `C_SetAttributeValue` call,
* or in the process of copying object with a `C_CopyObject` call.
* However, it is possible that a particular token may not permit modification of the attribute
* during the course of a `C_CopyObject` call.
* - Default value is token-specific, and may depend on the values of other attributes.
*/
verify: boolean;
/**
* `CK_TRUE` if key supports verification where the data is recovered from the signature
* - May be modified after object is created with a `C_SetAttributeValue` call,
* or in the process of copying object with a `C_CopyObject` call.
* However, it is possible that a particular token may not permit modification of the attribute
* during the course of a `C_CopyObject` call.
* - Default value is token-specific, and may depend on the values of other attributes.
*/
verifyRecover: boolean;
/**
* `CK_TRUE` if key supports wrapping (i.e., can be used to wrap other keys)
* - May be modified after object is created with a `C_SetAttributeValue` call,
* or in the process of copying object with a `C_CopyObject` call.
* However, it is possible that a particular token may not permit modification of the attribute
* during the course of a `C_CopyObject` call.
* - Default value is token-specific, and may depend on the values of other attributes.
*/
wrap: boolean;
/**
* The key can be trusted for the application that it was created.
* - The wrapping key can be used to wrap keys with `CKA_WRAP_WITH_TRUSTED` set to `CK_TRUE`.
* - Can only be set to CK_TRUE by the SO user.
*/
trusted: boolean;
/**
* For wrapping keys. The attribute template to match against any keys wrapped using this wrapping key.
* Keys that do not match cannot be wrapped.
*/
template: void;
}
/**
* Secret key objects (object class `CKO_SECRET_KEY`) hold secret keys.
*/
class SecretKey extends Key {
/**
* `CK_TRUE` if key is sensitive
* - May be modified after object is created with a `C_SetAttributeValue` call,
* or in the process of copying object with a `C_CopyObject` call.
* However, it is possible that a particular token may not permit modification of the attribute
* during the course of a `C_CopyObject` call.
* - Attribute cannot be changed once set to `CK_TRUE`. It becomes a read only attribute.
*/
sensitive: boolean;
/**
* `CK_TRUE` if key supports encryption
* - May be modified after object is created with a `C_SetAttributeValue` call,
* or in the process of copying object with a `C_CopyObject` call.
* However, it is possible that a particular token may not permit modification of the attribute
* during the course of a `C_CopyObject` call.
* - Default value is token-specific, and may depend on the values of other attributes.
*/
encrypt: boolean;
/**
* `CK_TRUE` if key supports decryption
* - May be modified after object is created with a `C_SetAttributeValue` call,
* or in the process of copying object with a `C_CopyObject` call.
* However, it is possible that a particular token may not permit modification of the attribute
* during the course of a `C_CopyObject` call.
* - Default value is token-specific, and may depend on the values of other attributes.
*/
decrypt: boolean;
/**
* `CK_TRUE` if key supports verification (i.e., of authentication codes) where the signature is an appendix to the data
* - May be modified after object is created with a `C_SetAttributeValue` call,
* or in the process of copying object with a `C_CopyObject` call.
* However, it is possible that a particular token may not permit modification of the attribute
* during the course of a `C_CopyObject` call.
* - Default value is token-specific, and may depend on the values of other attributes.
*/
verify: boolean;
/**
* `CK_TRUE` if key supports signatures (i.e., authentication codes) where the signature is an appendix to the data
* - May be modified after object is created with a `C_SetAttributeValue` call,
* or in the process of copying object with a `C_CopyObject` call.
* However, it is possible that a particular token may not permit modification of the attribute
* during the course of a `C_CopyObject` call.
* - Default value is token-specific, and may depend on the values of other attributes.
*/
sign: boolean;
/**
* `CK_TRUE` if key supports wrapping (i.e., can be used to wrap other keys)
* - May be modified after object is created with a `C_SetAttributeValue` call,
* or in the process of copying object with a `C_CopyObject` call.
* However, it is possible that a particular token may not permit modification of the attribute
* during the course of a `C_CopyObject` call.
* - Default value is token-specific, and may depend on the values of other attributes.
*/
wrap: boolean;
/**
* `CK_TRUE` if key supports unwrapping (i.e., can be used to unwrap other keys)
* - May be modified after object is created with a `C_SetAttributeValue` call,
* or in the process of copying object with a `C_CopyObject` call.
* However, it is possible that a particular token may not permit modification of the attribute
* during the course of a `C_CopyObject` call.
* - Default value is token-specific, and may depend on the values of other attributes.
*/
unwrap: boolean;
/**
* `CK_TRUE` if key is extractable and can be wrapped
* - May be modified after object is created with a `C_SetAttributeValue` call,
* or in the process of copying object with a `C_CopyObject` call.
* However, it is possible that a particular token may not permit modification of the attribute
* during the course of a `C_CopyObject` call.
* - Attribute cannot be changed once set to `CK_FALSE`. It becomes a read only attribute.
* - Default value is token-specific, and may depend on the values of other attributes.
*/
extractable: boolean;
/**
* `CK_TRUE` if key has always had the `CKA_SENSITIVE` attribute set to `CK_TRUE`
* - Must not be specified when object is created with `C_CreateObject`.
* - Must not be specified when object is generated with `C_GenerateKey` or `C_GenerateKeyPair`.
* - Must not be specified when object is unwrapped with `C_UnwrapKey`.
*/
alwaysSensitive: boolean;
/**
* `CK_TRUE` if key has never had the `CKA_EXTRACTABLE` attribute set to `CK_TRUE`
* - Must not be specified when object is created with `C_CreateObject`.
* - Must not be specified when object is generated with `C_GenerateKey` or `C_GenerateKeyPair`.
* - Must not be specified when object is unwrapped with `C_UnwrapKey`.
*/
neverExtractable: boolean;
/**
* Key checksum
*/
checkValue: Buffer;
/**
* `CK_TRUE` if the key can only be wrapped with a wrapping key
* that has `CKA_TRUSTED` set to `CK_TRUE`. Default is `CK_FALSE`.
* - Attribute cannot be changed once set to `CK_TRUE`. It becomes a read only attribute.
*/
wrapTrusted: boolean;
/**
* The wrapping key can be used to wrap keys with `CKA_WRAP_WITH_TRUSTED` set to `CK_TRUE`.
* - Can only be set to CK_TRUE by the SO user.
*/
trusted: boolean;
/**
* For wrapping keys.
* The attribute template to match against any keys wrapped using this wrapping key.
* Keys that do not match cannot be wrapped.
*/
wrapTemplate: void;
/**
* For wrapping keys.
* The attribute template to apply to any keys unwrapped using this wrapping key.
* Any user supplied template is applied after this template as if the object has already been created.
*/
unwrapTemplate: void;
}
enum CertificateType {
X_509,
X_509_ATTR_CERT,
WTLS,
}
enum CertificateCategory {
Unspecified,
TokenUser,
Authority,
OtherEntity,
}
/**
* Certificate objects (object class CKO_CERTIFICATE) hold public-key or attribute certificates
*/
class Certificate extends Storage {
/**
* Type of certificate
*/
type: CertificateType;
/**
* The certificate can be trusted for the application that it was created.
*/
trusted: boolean;
/**
* Categorization of the certificate
*/
category: CertificateCategory;
/**
* Checksum
*/
checkValue: Buffer;
/**
* Start date for the certificate (default empty)
*/
startDate: Date;
/**
* End date for the certificate (default empty)
*/
endDate: Date;
}
/**
* X.509 attribute certificate objects (certificate type `CKC_X_509_ATTR_CERT`) hold X.509 attribute certificates
*/
class AttributeCertificate extends Certificate {
/**
* DER-encoding of the attribute certificate's subject field.
* This is distinct from the `CKA_SUBJECT` attribute contained in `CKC_X_509` certificates
* because the `ASN.1` syntax and encoding are different.
* - Must be specified when the object is created
*/
owner: Buffer;
/**
* DER-encoding of the attribute certificate's issuer field.
* This is distinct from the `CKA_ISSUER` attribute contained in `CKC_X_509` certificates
* because the ASN.1 syntax and encoding are different. (default empty)
*/
issuer: Buffer;
/**
* DER-encoding of the certificate serial number (default empty)
*/
serialNumber: Buffer;
/**
* BER-encoding of a sequence of object identifier values corresponding
* to the attribute types contained in the certificate.
* When present, this field offers an opportunity for applications
* to search for a particular attribute certificate without fetching
* and parsing the certificate itself. (default empty)
*/
types: Buffer;
/**
* BER-encoding of the certificate
* - Must be specified when the object is created.
*/
value: Buffer;
}
/**
* WTLS certificate objects (certificate type `CKC_WTLS`) hold WTLS public key certificates
*/
class WtlsCertificate extends Certificate {
/**
* WTLS-encoding (Identifier type) of the certificate subject
* - Must be specified when the object is created.
* - Can only be empty if `CKA_VALUE` is empty.
*/
subject: Buffer;
/**
* WTLS-encoding (Identifier type) of the certificate issuer (default empty)
*/
issuer: Buffer;
/**
* Key identifier for public/private key pair (default empty)
*/
id: Buffer;
/**
* WTLS-encoding of the certificate
* - Must be specified when the object is created.
* - Must be non-empty if `CKA_URL` is empty.
*/
value: Buffer;
/**
* If not empty this attribute gives the URL where the complete certificate
* can be obtained (default empty)
* - Must be non-empty if `CKA_VALUE` is empty
*/
url: string;
/**
* DER-encoding of the certificate serial number (default empty)
*/
serialNumber: Buffer;
/**
* SHA-1 hash of the subject public key (default empty)
* - Can only be empty if `CKA_URL` is empty.
*/
subjetcKeyIdentifier: Buffer;
/**
* SHA-1 hash of the issuer public key (default empty)
* - Can only be empty if `CKA_URL` is empty.
*/
authorityKeyIdentifier: Buffer;
}
enum JavaMIDP {
Unspecified,
Manufacturer,
Operator,
ThirdParty,
}
/**
* X.509 certificate objects (certificate type `CKC_X_509`) hold X.509 public key certificates