-
-
Notifications
You must be signed in to change notification settings - Fork 34
/
index.d.ts
2486 lines (2397 loc) · 82 KB
/
index.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 pkcs11js v1.1.2
// Project: https://github.com/PeculiarVentures/pkcs11js
// Definitions by: Stepan Miroshin <https://github.com/microshine>
/// <reference types="node" />
/**
* A Node.js implementation of the PKCS#11 2.30 interface
*/
declare module "pkcs11js" {
/**
* PKCS#11 handle type
*/
type Handle = Buffer;
/**
* Structure that describes the version
*/
interface Version {
/**
* Major version number (the integer portion of the version)
*/
major: number;
/**
* minor version number (the hundredths portion of the version)
*/
minor: number;
}
/**
* Provides general information about Cryptoki
*/
interface ModuleInfo {
/**
* Cryptoki interface version number, for compatibility with future revisions of this interface
*/
cryptokiVersion: Version;
/**
* ID of the Cryptoki library manufacturer.
* Must be padded with the blank character (' ').
*/
manufacturerID: string;
/**
* Bit flags reserved for future versions. Must be zero for this version
*/
flags: number;
/**
* Character-string description of the library.
* Must be padded with the blank character (' ')
*/
libraryDescription: string;
/**
* Cryptoki library version number
*/
libraryVersion: Version;
}
/**
* Provides information about a slot
*/
interface SlotInfo {
/**
* Character-string description of the slot.
* Must be padded with the blank character (' ')
*/
slotDescription: string;
/**
* ID of the slot manufacturer.
* Must be padded with the blank character (' ')
*/
manufacturerID: string;
/**
* Bits flags that provide capabilities of the slot
*/
flags: number;
/**
* Version number of the slot's hardware
*/
hardwareVersion: Version;
/**
* Version number of the slot's firmware
*/
firmwareVersion: Version;
}
/**
* Provides information about a token
*/
interface TokenInfo {
/**
* Application-defined label, assigned during token initialization.
* Must be padded with the blank character (' ')
*/
label: string;
/**
* ID of the device manufacturer.
* Must be padded with the blank character (' ')
*/
manufacturerID: string;
/**
* Model of the device.
* Must be padded with the blank character (' ')
*/
model: string;
/**
* Character-string serial number of the device.
* Must be padded with the blank character (' ')
*/
serialNumber: string;
/**
* Bit flags indicating capabilities and status of the device
*/
flags: number;
/**
* Maximum number of sessions that can be opened with the token at one time by a single application
*/
maxSessionCount: number;
/**
* Number of sessions that this application currently has open with the token
*/
sessionCount: number;
/**
* Maximum number of read/write sessions that can be opened with the token at one time by a single application
*/
maxRwSessionCount: number;
/**
* Number of read/write sessions that this application currently has open with the token
*/
rwSessionCount: number;
/**
* Maximum length in bytes of the PIN
*/
maxPinLen: number;
/**
* Minimum length in bytes of the PIN
*/
minPinLen: number;
/**
* version number of hardware
*/
hardwareVersion: Version;
/**
* Version number of firmware
*/
firmwareVersion: Version;
/**
* Current time as a character-string of length 16, represented in the format YYYYMMDDhhmmssxx
* (4 characters for the year; 2 characters each for the month, the day, the hour, the minute,
* and the second; and 2 additional reserved '0' characters).
* The value of this field only makes sense for tokens equipped with a clock,
* as indicated in the token information flags
*/
utcTime: string;
/**
* The total amount of memory on the token in bytes in which public objects may be stored
*/
totalPublicMemory: number;
/**
* The amount of free (unused) memory on the token in bytes for public objects
*/
freePublicMemory: number;
/**
* The total amount of memory on the token in bytes in which private objects may be stored
*/
totalPrivateMemory: number;
/**
* The amount of free (unused) memory on the token in bytes for private objects
*/
freePrivateMemory: number;
}
/**
* Provides information about a particular mechanism
*/
interface MechanismInfo {
/**
* The minimum size of the key for the mechanism
*/
minKeySize: number;
/**
* The maximum size of the key for the mechanism
*/
maxKeySize: number;
/**
* Bit flags specifying mechanism capabilities
*/
flags: number;
}
/**
* Provides information about a session
*/
interface SessionInfo {
/**
* ID of the slot that interfaces with the token
*/
slotID: Buffer;
/**
* The state of the session
*/
state: number;
/**
* Bit flags that define the type of session
*/
flags: number;
/**
* An error code defined by the cryptographic device
*/
deviceError: number;
}
type Template = Attribute[];
interface AttributeResult {
type: number;
value: Buffer;
}
type TemplateResult = AttributeResult[];
/**
* A structure that includes the type and value of an attribute
*/
interface Attribute {
/**
* The attribute type
*/
type: number;
/**
* The value of the attribute
*/
value?: number | boolean | string | Buffer | Date;
}
/**
* A structure that specifies a particular mechanism and any parameters it requires
*/
interface Mechanism {
/**
* The type of mechanism
*/
mechanism: number;
/**
* The parameter if required by the mechanism
*/
parameter?: Buffer | number | IParams;
}
//#region Crypto parameters
/**
* A base structure of a parameter
*/
interface IParams {
/**
* Type of crypto param. Uses constants CK_PARAMS_*
*/
type: number;
}
/**
* A structure that provides the parameters for the {@link CKM_ECDH1_DERIVE} and {@link CKM_ECDH1_COFACTOR_DERIVE}
* key derivation mechanisms, where each party contributes one key pair
*/
interface ECDH1 extends IParams {
/**
* Key derivation function used on the shared secret value
*/
kdf: number;
/**
* Some data shared between the two parties
*/
sharedData?: Buffer;
/**
* The other party's EC public key
*/
publicData: Buffer;
}
interface AesCBC extends IParams {
iv: Buffer;
data?: Buffer;
}
interface AesCCM extends IParams {
dataLen: number;
nonce?: Buffer;
aad?: Buffer;
macLen: number;
}
interface AesGCM extends IParams {
iv?: Buffer;
aad?: Buffer;
ivBits: number;
tagBits: number;
}
interface RsaOAEP extends IParams {
hashAlg: number;
mgf: number;
source: number;
sourceData?: Buffer;
}
interface RsaPSS extends IParams {
hashAlg: number;
mgf: number;
saltLen: number;
}
interface Ecdh2Derive extends IParams {
kdf: number;
sharedData?: Buffer;
publicData: Buffer;
privateDataLen: number;
privateData: Handle;
publicData2?: Buffer;
}
interface EcmqvDerive extends IParams {
kdf: number;
sharedData?: Buffer;
publicData: Buffer;
privateDataLen: number;
publicData2?: Buffer;
privateData: Handle;
}
interface X942DH1Derive extends IParams {
kdf: number;
otherInfo?: Buffer;
publicData: Buffer;
privateData: Handle;
}
interface X942DH2Derive extends IParams {
kdf: number;
otherInfo?: Buffer;
publicData: Buffer;
privateData: Handle;
privateDataLen: number;
publicData2?: Buffer;
}
interface X942MQvDeriveParams {
kdf: number;
otherInfo?: Buffer;
publicData: Buffer;
privateData: Handle;
publicData2?: Buffer;
publicKey: Handle;
}
interface RC2CBCParams extends IParams {
effectiveBits: number;
iv: Buffer;
}
interface RC2MACGeneralParams extends IParams {
effectiveBits: number;
macLength: number;
}
interface RC5Params extends IParams {
wordSize: number;
rounds: number;
}
interface RC5CBCParams extends RC5Params {
wordSize: number;
rounds: number;
iv: Buffer;
}
interface RC5MACGeneralParams extends RC5Params {
wordSize: number;
rounds: number;
macLength: number;
}
interface DesCbcEncryptDataParams extends IParams {
iv: Buffer;
data?: Buffer;
}
interface SkipjackPrivateWrapParams extends IParams {
password: Buffer;
publicData: Buffer;
primeP: Buffer;
baseG: Buffer;
subprimeQ: Buffer;
randomA: Buffer;
}
interface SkipjackRelayXParams extends IParams {
oldWrappedX: Buffer;
oldPassword: Buffer;
oldPublicData: Buffer;
oldRandomA: Buffer;
newPassword: Buffer;
newPublicData: Buffer;
newRandomA: Buffer;
}
interface PbeParams extends IParams {
initVector: Buffer;
password: Buffer;
salt: Buffer;
iteration: number;
}
interface KeyWrapSetOaepParams extends IParams {
bc: number;
x: Buffer;
}
interface GcmParams extends IParams {
iv: Buffer;
ivBits: number;
aad?: Buffer;
tagBits?: number;
}
interface CcmParams extends IParams {
dataLen: number;
nonce?: Buffer;
aad?: Buffer;
macLen?: number;
}
interface GostR3410DeriveParams extends IParams {
kdf: number;
publicData: Buffer;
ukm?: Buffer;
}
interface GostR3410KeyWrapParams extends IParams {
wrapOID: Buffer;
ukm?: Buffer;
key: Handle;
}
//#endregion
interface KeyPair {
privateKey: Handle;
publicKey: Handle;
}
interface InitializationOptions {
/**
* NSS library parameters
*/
libraryParameters?: string;
/**
* bit flags specifying options for {@link PKCS11.C_Initialize}
* - CKF_LIBRARY_CANT_CREATE_OS_THREADS. True if application threads which are executing calls to the library
* may not use native operating system calls to spawn new threads; false if they may
* - CKF_OS_LOCKING_OK. True if the library can use the native operation system threading model for locking;
* false otherwise
*/
flags?: number;
}
/**
* A Structure which contains a Cryptoki version and each function in the Cryptoki API
*/
export class PKCS11 {
/**
* Library path
*/
public libPath: string;
/**
* Creates an instance of PKCS11
* @param libPath The path to PKCS#11 library
*/
constructor(libPath?: string);
/**
* Loads dynamic library with PKCS#11 interface
* @param path The path to PKCS#11 library
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public load(path: string): void;
/**
* Initializes the Cryptoki library
* @param options Initialization options
* Supports implementation of standard `CK_C_INITIALIZE_ARGS` and extended NSS format.
* - if `options` is null or empty, it calls native `C_Initialize` with `NULL`
* - if `options` doesn't have `libraryParameters`, it uses `CK_C_INITIALIZE_ARGS` structure
* - if `options` has `libraryParameters`, it uses extended NSS structure
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_Initialize(options?: InitializationOptions): void;
/**
* Closes dynamic library
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public close(): void;
/**
* Indicates that an application is done with the Cryptoki library
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_Finalize(): void;
/**
* Returns general information about Cryptoki
* @returns Information about Cryptoki
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_GetInfo(): ModuleInfo;
//#region Slot and token management
/**
* Obtains a list of slots in the system
* @param [tokenPresent] Only slots with tokens?
* @returns Array of slot IDs
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_GetSlotList(tokenPresent?: boolean): Handle[];
/**
* Obtains information about a particular slot in the system
* @param slot The ID of the slot
* @returns Information about a slot
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_GetSlotInfo(slot: Handle): SlotInfo;
/**
* Obtains information about a particular token in the system
* @param slot ID of the token's slot
* @returns Information about a token
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_GetTokenInfo(slot: Handle): TokenInfo;
/**
* Initializes a token
* @param slot ID of the token's slot
* @param [pin] The SO's initial PIN
* @returns 32-byte token label (blank padded)
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_InitToken(slot: Handle, pin?: string, label?: string): string;
/**
* Initializes the normal user's PIN
* @param session The session's handle
* @param pin The normal user's PIN
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_InitPIN(session: Handle, pin?: string): void;
/**
* Modifies the PIN of the user who is logged in
* @param session The session's handle
* @param oldPin The old PIN
* @param newPin The new PIN
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_SetPIN(session: Handle, oldPin: string, newPin: string): void;
/**
* Obtains a list of mechanism types supported by a token
* @param slot ID of token's slot
* @returns A list of mechanism types
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_GetMechanismList(slot: Handle): number[];
/**
* Obtains information about a particular mechanism possibly supported by a token
* @param slot ID of the token's slot
* @param mech Type of mechanism
* @returns Information about mechanism
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_GetMechanismInfo(slot: Handle, mech: number): MechanismInfo;
//#endregion
//#region Session management
/**
* Opens a session between an application and a token
* @param slot The slot's ID
* @param flags From CK_SESSION_INFO
* @returns Session handle
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_OpenSession(slot: Handle, flags: number): Handle;
/**
* Closes a session between an application and a token
* @param session The session's handle
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_CloseSession(session: Handle): void;
/**
* Closes all sessions with a token
* @param slot The token's slot
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_CloseAllSessions(slot: Handle): void;
/**
* Obtains information about the session
* @param session The session's handle
* @returns Receives session info
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_GetSessionInfo(session: Handle): SessionInfo;
/**
* Logs a user into a token
* @param session The session's handle
* @param userType The user type
* @param [pin] The user's PIN
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_Login(session: Handle, userType: number, pin?: string): void;
/**
* Logs a user out from a token
* @param session The session's handle
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_Logout(session: Handle): void;
//#endregion
//#region Object management
/**
* Creates a new object
* @param session The session's handle
* @param template The object's template
* @returns A new object's handle
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_CreateObject(session: Handle, template: Template): Handle;
/**
* Copies an object, creating a new object for the copy
* @param session The session's handle
* @param object The object's handle
* @param template Template for new object
* @returns A handle of copy
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_CopyObject(
session: Handle,
object: Handle,
template: Template
): Handle;
/**
* Destroys an object
* @param session The session's handle
* @param object The object's handle
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_DestroyObject(session: Handle, object: Handle): void;
/**
* Gets the size of an object in bytes
* @param session The session's handle
* @param object The object's handle
* @returns Size of an object in bytes
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_GetObjectSize(session: Handle, object: Handle): number;
/**
* Initializes a search for token and session objects that match a template
* @param session The session's handle
* @param template Attribute values to match
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_FindObjectsInit(session: Handle, template: Template): void;
/**
* Continues a search for token and session
* objects that match a template, obtaining additional object
* handles
* @param session The session's handle
* @param maxObjectCount The maximum number of object handles to be returned. Default value is 1.
* @returns List of handles
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_FindObjects(session: Handle, maxObjectCount: number): Handle[];
/**
* Continues a search for token and session
* objects that match a template, obtaining additional object
* handles
* @param session The session's handle
* @returns Object's handle. If object is not found
* the result is null
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_FindObjects(session: Handle): Handle | null;
/**
* Finishes a search for token and session objects
* @param session The session's handle
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_FindObjectsFinal(session: Handle): void;
/**
* Obtains the value of one or more object attributes
* @param session The session's handle
* @param object The object's handle
* @param template Specifies attrs; gets values
* @returns List of Attributes with values
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_GetAttributeValue(
session: Handle,
object: Handle,
template: Template
): TemplateResult;
/**
* Modifies the value of one or more object attributes
* @param session The session's handle
* @param object The object's handle
* @param template Specifies attrs and values
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_SetAttributeValue(
session: Handle,
object: Handle,
template: Template
): void;
//#endregion
//#region Encryption and decryption
/**
* Initializes an encryption operation
* @param session The session's handle
* @param mechanism The encryption mechanism
* @param key Handle of encryption key
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_EncryptInit(
session: Handle,
mechanism: Mechanism,
key: Handle
): void;
/**
* Encrypts single-part data
* @param session The session's handle
* @param inData Incoming data
* @param outData Output data
* @returns Sliced output data with encrypted message
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_Encrypt(session: Handle, inData: Buffer, outData: Buffer): Buffer;
/**
* Encrypts single-part data
* @param session The session's handle
* @param inData Incoming data
* @param outData Output data
* @param cb Async callback with sliced output data
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_Encrypt(
session: Handle,
inData: Buffer,
outData: Buffer,
cb: (error: Error, data: Buffer) => void
): void;
/**
* Encrypts single-part data
* @param session The session's handle
* @param inData Incoming data
* @param outData Output data
* @returns Sliced output data with encrypted message
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_EncryptAsync(
session: Handle,
inData: Buffer,
outData: Buffer
): Promise<Buffer>;
/**
* Continues a multiple-part encryption operation
* @param session The session's handle
* @param inData Incoming data
* @param outData Output data
* @returns Sliced output data
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_EncryptUpdate(
session: Handle,
inData: Buffer,
outData: Buffer
): Buffer;
/**
* Finishes a multiple-part encryption operation
* @param session The session's handle
* @param outData Last output data
* @returns Sliced output data
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_EncryptFinal(session: Handle, outData: Buffer): Buffer;
/**
* Finishes a multiple-part encryption operation
* @param session The session's handle
* @param outData Last output data
* @param cb Async callback with sliced output data
*/
public C_EncryptFinal(
session: Handle,
outData: Buffer,
cb: (error: Error, data: Buffer) => void
): void;
/**
* Finishes a multiple-part encryption operation
* @param session The session's handle
* @param outData Last output data
* @returns Sliced output data
*/
public C_EncryptFinalAsync(
session: Handle,
outData: Buffer
): Promise<Buffer>;
/**
* Initializes a decryption operation
* @param session The session's handle
* @param mechanism The decryption mechanism
* @param key Handle of decryption key
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_DecryptInit(
session: Handle,
mechanism: Mechanism,
key: Handle
): void;
/**
* Decrypts encrypted data in a single part
* @param session The session's handle
* @param inData Incoming data
* @param outData Output data
* @returns Sliced output data with decrypted message
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_Decrypt(session: Handle, inData: Buffer, outData: Buffer): Buffer;
/**
* Decrypts encrypted data in a single part
* @param session The session's handle
* @param inData Incoming data
* @param outData Output data
* @param cb Async callback with sliced output data
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_Decrypt(
session: Handle,
inData: Buffer,
outData: Buffer,
cb: (error: Error, data: Buffer) => void
): void;
/**
* Decrypts encrypted data in a single part
* @param session The session's handle
* @param inData Incoming data
* @param outData Output data
* @returns Sliced output data with decrypted message
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_DecryptAsync(
session: Handle,
inData: Buffer,
outData: Buffer
): Promise<Buffer>;
/**
* continues a multiple-part decryption operation
* @param session The session's handle
* @param inData Incoming data
* @param outData Output data
* @returns Sliced output data with decrypted block
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_DecryptUpdate(
session: Handle,
inData: Buffer,
outData: Buffer
): Buffer;
/**
* Finishes a multiple-part decryption operation
* @param session The session's handle
* @param outData Last part of output data
* @returns Sliced output data with decrypted final block
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_DecryptFinal(session: Handle, outData: Buffer): Buffer;
/**
* Finishes a multiple-part decryption operation
* @param session The session's handle
* @param outData Last part of output data
* @param cb Async callback with sliced output data with decrypted final block
*/
public C_DecryptFinal(
session: Handle,
outData: Buffer,
cb: (error: Error, data: Buffer) => void
): void;
/**
* Finishes a multiple-part decryption operation
* @param session The session's handle
* @param outData Last part of output data
* @returns Sliced output data with decrypted final block
*/
public C_DecryptFinalAsync(
session: Handle,
outData: Buffer
): Promise<Buffer>;
/* Message digesting */
/**
* Initializes a message-digesting operation
* @param session The session's handle
* @param mechanism Digesting mechanism
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_DigestInit(session: Handle, mechanism: Mechanism): void;
/**
* Digests data in a single part
* @param session The session's handle
* @param inData Incoming data
* @param outData Output data
* @returns Sliced output data
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_Digest(session: Handle, inData: Buffer, outData: Buffer): Buffer;
/**
* Digests data in a single part
* @param session The session's handle
* @param inData Incoming data
* @param outData Output data
* @param cb Async callback with sliced output data
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_Digest(
session: Handle,
inData: Buffer,
outData: Buffer,
cb: (error: Error, data: Buffer) => void
): void;
/**
* Digests data in a single part
* @param session The session's handle
* @param inData Incoming data
* @param outData Output data
* @returns Sliced output data
* @throws {@link NativeError} if native error occurs
* @throws {@link Pkcs11Error} if Cryptoki error occurs
*/
public C_DigestAsync(
session: Handle,
inData: Buffer,
outData: Buffer
): Promise<Buffer>;
/**
* continues a multiple-part message-digesting operation
* operation, by digesting the value of a secret key as part of
* the data already digested
* @param session The session's handle