Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/wrapper/PKCS11.java
41161 views
1
/*
2
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
3
*/
4
5
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
6
*
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions are met:
9
*
10
* 1. Redistributions of source code must retain the above copyright notice,
11
* this list of conditions and the following disclaimer.
12
*
13
* 2. Redistributions in binary form must reproduce the above copyright notice,
14
* this list of conditions and the following disclaimer in the documentation
15
* and/or other materials provided with the distribution.
16
*
17
* 3. The end-user documentation included with the redistribution, if any, must
18
* include the following acknowledgment:
19
*
20
* "This product includes software developed by IAIK of Graz University of
21
* Technology."
22
*
23
* Alternately, this acknowledgment may appear in the software itself, if
24
* and wherever such third-party acknowledgments normally appear.
25
*
26
* 4. The names "Graz University of Technology" and "IAIK of Graz University of
27
* Technology" must not be used to endorse or promote products derived from
28
* this software without prior written permission.
29
*
30
* 5. Products derived from this software may not be called
31
* "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
32
* written permission of Graz University of Technology.
33
*
34
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
35
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
36
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
37
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
38
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
39
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
40
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
41
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
42
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
43
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
44
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
45
* POSSIBILITY OF SUCH DAMAGE.
46
*/
47
48
package sun.security.pkcs11.wrapper;
49
50
import java.io.File;
51
import java.io.IOException;
52
import java.util.*;
53
54
import java.security.AccessController;
55
import java.security.PrivilegedAction;
56
57
import sun.security.util.Debug;
58
59
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
60
import static sun.security.pkcs11.wrapper.PKCS11Exception.*;
61
62
/**
63
* This is the default implementation of the PKCS11 interface. IT connects to
64
* the pkcs11wrapper.dll file, which is the native part of this library.
65
* The strange and awkward looking initialization was chosen to avoid calling
66
* loadLibrary from a static initialization block, because this would complicate
67
* the use in applets.
68
*
69
* @author Karl Scheibelhofer <[email protected]>
70
* @author Martin Schlaeffer <[email protected]>
71
* @invariants (pkcs11ModulePath_ <> null)
72
*/
73
public class PKCS11 {
74
75
/**
76
* The name of the native part of the wrapper; i.e. the filename without
77
* the extension (e.g. ".DLL" or ".so").
78
*/
79
private static final String PKCS11_WRAPPER = "j2pkcs11";
80
81
static {
82
// cannot use LoadLibraryAction because that would make the native
83
// library available to the bootclassloader, but we run in the
84
// extension classloader.
85
@SuppressWarnings("removal")
86
var dummy = AccessController.doPrivileged(new PrivilegedAction<Object>() {
87
public Object run() {
88
System.loadLibrary(PKCS11_WRAPPER);
89
return null;
90
}
91
});
92
boolean enableDebug = Debug.getInstance("sunpkcs11") != null;
93
initializeLibrary(enableDebug);
94
}
95
96
public static void loadNative() {
97
// dummy method that can be called to make sure the native
98
// portion has been loaded. actual loading happens in the
99
// static initializer, hence this method is empty.
100
}
101
102
/* *****************************************************************************
103
* Utility, Resource Clean up
104
******************************************************************************/
105
// always return 0L
106
public static native long freeMechanism(long hMechanism);
107
108
/**
109
* The PKCS#11 module to connect to. This is the PKCS#11 driver of the token;
110
* e.g. pk2priv.dll.
111
*/
112
private final String pkcs11ModulePath;
113
114
private long pNativeData;
115
116
/**
117
* This method does the initialization of the native library. It is called
118
* exactly once for this class.
119
*
120
* @preconditions
121
* @postconditions
122
*/
123
private static native void initializeLibrary(boolean debug);
124
125
// XXX
126
/**
127
* This method does the finalization of the native library. It is called
128
* exactly once for this class. The library uses this method for a clean-up
129
* of any resources.
130
*
131
* @preconditions
132
* @postconditions
133
*/
134
private static native void finalizeLibrary();
135
136
private static final Map<String,PKCS11> moduleMap =
137
new HashMap<String,PKCS11>();
138
139
/**
140
* Connects to the PKCS#11 driver given. The filename must contain the
141
* path, if the driver is not in the system's search path.
142
*
143
* @param pkcs11ModulePath the PKCS#11 library path
144
* @preconditions (pkcs11ModulePath <> null)
145
* @postconditions
146
*/
147
PKCS11(String pkcs11ModulePath, String functionListName)
148
throws IOException {
149
connect(pkcs11ModulePath, functionListName);
150
this.pkcs11ModulePath = pkcs11ModulePath;
151
}
152
153
public static synchronized PKCS11 getInstance(String pkcs11ModulePath,
154
String functionList, CK_C_INITIALIZE_ARGS pInitArgs,
155
boolean omitInitialize) throws IOException, PKCS11Exception {
156
// we may only call C_Initialize once per native .so/.dll
157
// so keep a cache using the (non-canonicalized!) path
158
PKCS11 pkcs11 = moduleMap.get(pkcs11ModulePath);
159
if (pkcs11 == null) {
160
if ((pInitArgs != null)
161
&& ((pInitArgs.flags & CKF_OS_LOCKING_OK) != 0)) {
162
pkcs11 = new PKCS11(pkcs11ModulePath, functionList);
163
} else {
164
pkcs11 = new SynchronizedPKCS11(pkcs11ModulePath, functionList);
165
}
166
if (omitInitialize == false) {
167
try {
168
pkcs11.C_Initialize(pInitArgs);
169
} catch (PKCS11Exception e) {
170
// ignore already-initialized error code
171
// rethrow all other errors
172
if (e.getErrorCode() != CKR_CRYPTOKI_ALREADY_INITIALIZED) {
173
throw e;
174
}
175
}
176
}
177
moduleMap.put(pkcs11ModulePath, pkcs11);
178
}
179
return pkcs11;
180
}
181
182
/**
183
* Connects this object to the specified PKCS#11 library. This method is for
184
* internal use only.
185
* Declared private, because incorrect handling may result in errors in the
186
* native part.
187
*
188
* @param pkcs11ModulePath The PKCS#11 library path.
189
* @preconditions (pkcs11ModulePath <> null)
190
* @postconditions
191
*/
192
private native void connect(String pkcs11ModulePath, String functionListName)
193
throws IOException;
194
195
/**
196
* Disconnects the PKCS#11 library from this object. After calling this
197
* method, this object is no longer connected to a native PKCS#11 module
198
* and any subsequent calls to C_ methods will fail. This method is for
199
* internal use only.
200
* Declared private, because incorrect handling may result in errors in the
201
* native part.
202
*
203
* @preconditions
204
* @postconditions
205
*/
206
private native void disconnect();
207
208
209
// Implementation of PKCS11 methods delegated to native pkcs11wrapper library
210
211
/* *****************************************************************************
212
* General-purpose
213
******************************************************************************/
214
215
/**
216
* C_Initialize initializes the Cryptoki library.
217
* (General-purpose)
218
*
219
* @param pInitArgs if pInitArgs is not NULL it gets casted to
220
* CK_C_INITIALIZE_ARGS_PTR and dereferenced
221
* (PKCS#11 param: CK_VOID_PTR pInitArgs)
222
* @exception PKCS11Exception If function returns other value than CKR_OK.
223
* @preconditions
224
* @postconditions
225
*/
226
native void C_Initialize(Object pInitArgs) throws PKCS11Exception;
227
228
/**
229
* C_Finalize indicates that an application is done with the
230
* Cryptoki library
231
* (General-purpose)
232
*
233
* @param pReserved is reserved. Should be NULL_PTR
234
* (PKCS#11 param: CK_VOID_PTR pReserved)
235
* @exception PKCS11Exception If function returns other value than CKR_OK.
236
* @preconditions (pReserved == null)
237
* @postconditions
238
*/
239
public native void C_Finalize(Object pReserved) throws PKCS11Exception;
240
241
242
/**
243
* C_GetInfo returns general information about Cryptoki.
244
* (General-purpose)
245
*
246
* @return the information.
247
* (PKCS#11 param: CK_INFO_PTR pInfo)
248
* @exception PKCS11Exception If function returns other value than CKR_OK.
249
* @preconditions
250
* @postconditions (result <> null)
251
*/
252
public native CK_INFO C_GetInfo() throws PKCS11Exception;
253
254
255
/* *****************************************************************************
256
* Slot and token management
257
******************************************************************************/
258
259
/**
260
* C_GetSlotList obtains a list of slots in the system.
261
* (Slot and token management)
262
*
263
* @param tokenPresent if true only Slot IDs with a token are returned
264
* (PKCS#11 param: CK_BBOOL tokenPresent)
265
* @return a long array of slot IDs and number of Slot IDs
266
* (PKCS#11 param: CK_SLOT_ID_PTR pSlotList, CK_ULONG_PTR pulCount)
267
* @exception PKCS11Exception If function returns other value than CKR_OK.
268
* @preconditions
269
* @postconditions (result <> null)
270
*/
271
public native long[] C_GetSlotList(boolean tokenPresent)
272
throws PKCS11Exception;
273
274
275
/**
276
* C_GetSlotInfo obtains information about a particular slot in
277
* the system.
278
* (Slot and token management)
279
*
280
* @param slotID the ID of the slot
281
* (PKCS#11 param: CK_SLOT_ID slotID)
282
* @return the slot information
283
* (PKCS#11 param: CK_SLOT_INFO_PTR pInfo)
284
* @exception PKCS11Exception If function returns other value than CKR_OK.
285
* @preconditions
286
* @postconditions (result <> null)
287
*/
288
public native CK_SLOT_INFO C_GetSlotInfo(long slotID) throws PKCS11Exception;
289
290
291
/**
292
* C_GetTokenInfo obtains information about a particular token
293
* in the system.
294
* (Slot and token management)
295
*
296
* @param slotID ID of the token's slot
297
* (PKCS#11 param: CK_SLOT_ID slotID)
298
* @return the token information
299
* (PKCS#11 param: CK_TOKEN_INFO_PTR pInfo)
300
* @exception PKCS11Exception If function returns other value than CKR_OK.
301
* @preconditions
302
* @postconditions (result <> null)
303
*/
304
public native CK_TOKEN_INFO C_GetTokenInfo(long slotID)
305
throws PKCS11Exception;
306
307
308
/**
309
* C_GetMechanismList obtains a list of mechanism types
310
* supported by a token.
311
* (Slot and token management)
312
*
313
* @param slotID ID of the token's slot
314
* (PKCS#11 param: CK_SLOT_ID slotID)
315
* @return a long array of mechanism types and number of mechanism types
316
* (PKCS#11 param: CK_MECHANISM_TYPE_PTR pMechanismList,
317
* CK_ULONG_PTR pulCount)
318
* @exception PKCS11Exception If function returns other value than CKR_OK.
319
* @preconditions
320
* @postconditions (result <> null)
321
*/
322
public native long[] C_GetMechanismList(long slotID) throws PKCS11Exception;
323
324
325
/**
326
* C_GetMechanismInfo obtains information about a particular
327
* mechanism possibly supported by a token.
328
* (Slot and token management)
329
*
330
* @param slotID ID of the token's slot
331
* (PKCS#11 param: CK_SLOT_ID slotID)
332
* @param type type of mechanism
333
* (PKCS#11 param: CK_MECHANISM_TYPE type)
334
* @return the mechanism info
335
* (PKCS#11 param: CK_MECHANISM_INFO_PTR pInfo)
336
* @exception PKCS11Exception If function returns other value than CKR_OK.
337
* @preconditions
338
* @postconditions (result <> null)
339
*/
340
public native CK_MECHANISM_INFO C_GetMechanismInfo(long slotID, long type)
341
throws PKCS11Exception;
342
343
344
/**
345
* C_InitToken initializes a token.
346
* (Slot and token management)
347
*
348
* @param slotID ID of the token's slot
349
* (PKCS#11 param: CK_SLOT_ID slotID)
350
* @param pPin the SO's initial PIN and the length in bytes of the PIN
351
* (PKCS#11 param: CK_CHAR_PTR pPin, CK_ULONG ulPinLen)
352
* @param pLabel 32-byte token label (blank padded)
353
* (PKCS#11 param: CK_UTF8CHAR_PTR pLabel)
354
* @exception PKCS11Exception If function returns other value than CKR_OK.
355
* @preconditions
356
* @postconditions
357
*/
358
// public native void C_InitToken(long slotID, char[] pPin, char[] pLabel)
359
// throws PKCS11Exception;
360
361
362
/**
363
* C_InitPIN initializes the normal user's PIN.
364
* (Slot and token management)
365
*
366
* @param hSession the session's handle
367
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
368
* @param pPin the normal user's PIN and the length in bytes of the PIN
369
* (PKCS#11 param: CK_CHAR_PTR pPin, CK_ULONG ulPinLen)
370
* @exception PKCS11Exception If function returns other value than CKR_OK.
371
* @preconditions
372
* @postconditions
373
*/
374
// public native void C_InitPIN(long hSession, char[] pPin)
375
// throws PKCS11Exception;
376
377
378
/**
379
* C_SetPIN modifies the PIN of the user who is logged in.
380
* (Slot and token management)
381
*
382
* @param hSession the session's handle
383
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
384
* @param pOldPin the old PIN and the length of the old PIN
385
* (PKCS#11 param: CK_CHAR_PTR pOldPin, CK_ULONG ulOldLen)
386
* @param pNewPin the new PIN and the length of the new PIN
387
* (PKCS#11 param: CK_CHAR_PTR pNewPin, CK_ULONG ulNewLen)
388
* @exception PKCS11Exception If function returns other value than CKR_OK.
389
* @preconditions
390
* @postconditions
391
*/
392
// public native void C_SetPIN(long hSession, char[] pOldPin, char[] pNewPin)
393
// throws PKCS11Exception;
394
395
396
397
/* *****************************************************************************
398
* Session management
399
******************************************************************************/
400
401
/**
402
* C_OpenSession opens a session between an application and a
403
* token.
404
* (Session management)
405
*
406
* @param slotID the slot's ID
407
* (PKCS#11 param: CK_SLOT_ID slotID)
408
* @param flags of CK_SESSION_INFO
409
* (PKCS#11 param: CK_FLAGS flags)
410
* @param pApplication passed to callback
411
* (PKCS#11 param: CK_VOID_PTR pApplication)
412
* @param Notify the callback function
413
* (PKCS#11 param: CK_NOTIFY Notify)
414
* @return the session handle
415
* (PKCS#11 param: CK_SESSION_HANDLE_PTR phSession)
416
* @exception PKCS11Exception If function returns other value than CKR_OK.
417
* @preconditions
418
* @postconditions
419
*/
420
public native long C_OpenSession(long slotID, long flags,
421
Object pApplication, CK_NOTIFY Notify) throws PKCS11Exception;
422
423
424
/**
425
* C_CloseSession closes a session between an application and a
426
* token.
427
* (Session management)
428
*
429
* @param hSession the session's handle
430
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
431
* @exception PKCS11Exception If function returns other value than CKR_OK.
432
* @preconditions
433
* @postconditions
434
*/
435
public native void C_CloseSession(long hSession) throws PKCS11Exception;
436
437
438
/**
439
* C_CloseAllSessions closes all sessions with a token.
440
* (Session management)
441
*
442
* @param slotID the ID of the token's slot
443
* (PKCS#11 param: CK_SLOT_ID slotID)
444
* @exception PKCS11Exception If function returns other value than CKR_OK.
445
* @preconditions
446
* @postconditions
447
*/
448
// public native void C_CloseAllSessions(long slotID) throws PKCS11Exception;
449
450
451
/**
452
* C_GetSessionInfo obtains information about the session.
453
* (Session management)
454
*
455
* @param hSession the session's handle
456
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
457
* @return the session info
458
* (PKCS#11 param: CK_SESSION_INFO_PTR pInfo)
459
* @exception PKCS11Exception If function returns other value than CKR_OK.
460
* @preconditions
461
* @postconditions (result <> null)
462
*/
463
public native CK_SESSION_INFO C_GetSessionInfo(long hSession)
464
throws PKCS11Exception;
465
466
467
/**
468
* C_GetOperationState obtains the state of the cryptographic operation
469
* in a session.
470
* (Session management)
471
*
472
* @param hSession session's handle
473
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
474
* @return the state and the state length
475
* (PKCS#11 param: CK_BYTE_PTR pOperationState,
476
* CK_ULONG_PTR pulOperationStateLen)
477
* @exception PKCS11Exception If function returns other value than CKR_OK.
478
* @preconditions
479
* @postconditions (result <> null)
480
*/
481
public native byte[] C_GetOperationState(long hSession)
482
throws PKCS11Exception;
483
484
485
/**
486
* C_SetOperationState restores the state of the cryptographic
487
* operation in a session.
488
* (Session management)
489
*
490
* @param hSession session's handle
491
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
492
* @param pOperationState the state and the state length
493
* (PKCS#11 param: CK_BYTE_PTR pOperationState,
494
* CK_ULONG ulOperationStateLen)
495
* @param hEncryptionKey en/decryption key
496
* (PKCS#11 param: CK_OBJECT_HANDLE hEncryptionKey)
497
* @param hAuthenticationKey sign/verify key
498
* (PKCS#11 param: CK_OBJECT_HANDLE hAuthenticationKey)
499
* @exception PKCS11Exception If function returns other value than CKR_OK.
500
* @preconditions
501
* @postconditions
502
*/
503
public native void C_SetOperationState(long hSession, byte[] pOperationState,
504
long hEncryptionKey, long hAuthenticationKey) throws PKCS11Exception;
505
506
507
/**
508
* C_Login logs a user into a token.
509
* (Session management)
510
*
511
* @param hSession the session's handle
512
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
513
* @param userType the user type
514
* (PKCS#11 param: CK_USER_TYPE userType)
515
* @param pPin the user's PIN and the length of the PIN
516
* (PKCS#11 param: CK_CHAR_PTR pPin, CK_ULONG ulPinLen)
517
* @exception PKCS11Exception If function returns other value than CKR_OK.
518
* @preconditions
519
* @postconditions
520
*/
521
public native void C_Login(long hSession, long userType, char[] pPin)
522
throws PKCS11Exception;
523
524
525
/**
526
* C_Logout logs a user out from a token.
527
* (Session management)
528
*
529
* @param hSession the session's handle
530
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
531
* @exception PKCS11Exception If function returns other value than CKR_OK.
532
* @preconditions
533
* @postconditions
534
*/
535
public native void C_Logout(long hSession) throws PKCS11Exception;
536
537
538
539
/* *****************************************************************************
540
* Object management
541
******************************************************************************/
542
543
/**
544
* C_CreateObject creates a new object.
545
* (Object management)
546
*
547
* @param hSession the session's handle
548
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
549
* @param pTemplate the object's template and number of attributes in
550
* template
551
* (PKCS#11 param: CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount)
552
* @return the object's handle
553
* (PKCS#11 param: CK_OBJECT_HANDLE_PTR phObject)
554
* @exception PKCS11Exception If function returns other value than CKR_OK.
555
* @preconditions
556
* @postconditions
557
*/
558
public native long C_CreateObject(long hSession, CK_ATTRIBUTE[] pTemplate)
559
throws PKCS11Exception;
560
561
562
/**
563
* C_CopyObject copies an object, creating a new object for the
564
* copy.
565
* (Object management)
566
*
567
* @param hSession the session's handle
568
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
569
* @param hObject the object's handle
570
* (PKCS#11 param: CK_OBJECT_HANDLE hObject)
571
* @param pTemplate the template for the new object and number of attributes
572
* in template
573
* (PKCS#11 param: CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount)
574
* @return the handle of the copy
575
* (PKCS#11 param: CK_OBJECT_HANDLE_PTR phNewObject)
576
* @exception PKCS11Exception If function returns other value than CKR_OK.
577
* @preconditions
578
* @postconditions
579
*/
580
public native long C_CopyObject(long hSession, long hObject,
581
CK_ATTRIBUTE[] pTemplate) throws PKCS11Exception;
582
583
584
/**
585
* C_DestroyObject destroys an object.
586
* (Object management)
587
*
588
* @param hSession the session's handle
589
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
590
* @param hObject the object's handle
591
* (PKCS#11 param: CK_OBJECT_HANDLE hObject)
592
* @exception PKCS11Exception If function returns other value than CKR_OK.
593
* @preconditions
594
* @postconditions
595
*/
596
public native void C_DestroyObject(long hSession, long hObject)
597
throws PKCS11Exception;
598
599
600
/**
601
* C_GetObjectSize gets the size of an object in bytes.
602
* (Object management)
603
*
604
* @param hSession the session's handle
605
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
606
* @param hObject the object's handle
607
* (PKCS#11 param: CK_OBJECT_HANDLE hObject)
608
* @return the size of the object
609
* (PKCS#11 param: CK_ULONG_PTR pulSize)
610
* @exception PKCS11Exception If function returns other value than CKR_OK.
611
* @preconditions
612
* @postconditions
613
*/
614
// public native long C_GetObjectSize(long hSession, long hObject)
615
// throws PKCS11Exception;
616
617
618
/**
619
* C_GetAttributeValue obtains the value of one or more object
620
* attributes. The template attributes also receive the values.
621
* (Object management)
622
* note: in PKCS#11 pTemplate and the result template are the same
623
*
624
* @param hSession the session's handle
625
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
626
* @param hObject the object's handle
627
* (PKCS#11 param: CK_OBJECT_HANDLE hObject)
628
* @param pTemplate specifies the attributes and number of attributes to get
629
* The template attributes also receive the values.
630
* (PKCS#11 param: CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount)
631
* @exception PKCS11Exception If function returns other value than CKR_OK.
632
* @preconditions (pTemplate <> null)
633
* @postconditions (result <> null)
634
*/
635
public native void C_GetAttributeValue(long hSession, long hObject,
636
CK_ATTRIBUTE[] pTemplate) throws PKCS11Exception;
637
638
639
/**
640
* C_SetAttributeValue modifies the value of one or more object
641
* attributes
642
* (Object management)
643
*
644
* @param hSession the session's handle
645
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
646
* @param hObject the object's handle
647
* (PKCS#11 param: CK_OBJECT_HANDLE hObject)
648
* @param pTemplate specifies the attributes and values to get; number of
649
* attributes in the template
650
* (PKCS#11 param: CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount)
651
* @exception PKCS11Exception If function returns other value than CKR_OK.
652
* @preconditions (pTemplate <> null)
653
* @postconditions
654
*/
655
public native void C_SetAttributeValue(long hSession, long hObject,
656
CK_ATTRIBUTE[] pTemplate) throws PKCS11Exception;
657
658
659
/**
660
* C_FindObjectsInit initializes a search for token and session
661
* objects that match a template.
662
* (Object management)
663
*
664
* @param hSession the session's handle
665
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
666
* @param pTemplate the object's attribute values to match and the number of
667
* attributes in search template
668
* (PKCS#11 param: CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount)
669
* @exception PKCS11Exception If function returns other value than CKR_OK.
670
* @preconditions
671
* @postconditions
672
*/
673
public native void C_FindObjectsInit(long hSession, CK_ATTRIBUTE[] pTemplate)
674
throws PKCS11Exception;
675
676
677
/**
678
* C_FindObjects continues a search for token and session
679
* objects that match a template, obtaining additional object
680
* handles.
681
* (Object management)
682
*
683
* @param hSession the session's handle
684
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
685
* @param ulMaxObjectCount the max. object handles to get
686
* (PKCS#11 param: CK_ULONG ulMaxObjectCount)
687
* @return the object's handles and the actual number of objects returned
688
* (PKCS#11 param: CK_ULONG_PTR pulObjectCount)
689
* @exception PKCS11Exception If function returns other value than CKR_OK.
690
* @preconditions
691
* @postconditions (result <> null)
692
*/
693
public native long[] C_FindObjects(long hSession, long ulMaxObjectCount)
694
throws PKCS11Exception;
695
696
697
/**
698
* C_FindObjectsFinal finishes a search for token and session
699
* objects.
700
* (Object management)
701
*
702
* @param hSession the session's handle
703
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
704
* @exception PKCS11Exception If function returns other value than CKR_OK.
705
* @preconditions
706
* @postconditions
707
*/
708
public native void C_FindObjectsFinal(long hSession) throws PKCS11Exception;
709
710
711
712
/* *****************************************************************************
713
* Encryption and decryption
714
******************************************************************************/
715
716
/**
717
* C_EncryptInit initializes an encryption operation.
718
* (Encryption and decryption)
719
*
720
* @param hSession the session's handle
721
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
722
* @param pMechanism the encryption mechanism
723
* (PKCS#11 param: CK_MECHANISM_PTR pMechanism)
724
* @param hKey the handle of the encryption key
725
* (PKCS#11 param: CK_OBJECT_HANDLE hKey)
726
* @exception PKCS11Exception If function returns other value than CKR_OK.
727
* @preconditions
728
* @postconditions
729
*/
730
public native void C_EncryptInit(long hSession, CK_MECHANISM pMechanism,
731
long hKey) throws PKCS11Exception;
732
733
734
/**
735
* C_Encrypt encrypts single-part data.
736
* (Encryption and decryption)
737
*
738
* @param hSession the session's handle
739
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
740
* @param directIn the address of the to-be-encrypted data
741
* @param in buffer containing the to-be-encrypted data
742
* @param inOfs buffer offset of the to-be-encrypted data
743
* @param inLen length of the to-be-encrypted data
744
* (PKCS#11 param: CK_BYTE_PTR pData, CK_ULONG ulDataLen)
745
* @param directOut the address for the encrypted data
746
* @param out buffer for the encrypted data
747
* @param outOfs buffer offset for the encrypted data
748
* @param outLen buffer size for the encrypted data
749
* @return the length of encrypted data
750
* (PKCS#11 param: CK_BYTE_PTR pEncryptedData,
751
* CK_ULONG_PTR pulEncryptedDataLen)
752
* @exception PKCS11Exception If function returns other value than CKR_OK.
753
* @preconditions
754
* @postconditions
755
*/
756
public native int C_Encrypt(long hSession, long directIn, byte[] in,
757
int inOfs, int inLen, long directOut, byte[] out, int outOfs,
758
int outLen) throws PKCS11Exception;
759
760
761
/**
762
* C_EncryptUpdate continues a multiple-part encryption
763
* operation.
764
* (Encryption and decryption)
765
*
766
* @param hSession the session's handle
767
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
768
* @param directIn the address of the to-be-encrypted data
769
* @param in buffer containing the to-be-encrypted data
770
* @param inOfs buffer offset of the to-be-encrypted data
771
* @param inLen length of the to-be-encrypted data
772
* (PKCS#11 param: CK_BYTE_PTR pPart, CK_ULONG ulPartLen)
773
* @param directOut the address for the encrypted data
774
* @param out buffer for the encrypted data
775
* @param outOfs buffer offset for the encrypted data
776
* @param outLen buffer size for the encrypted data
777
* @return the length of encrypted data for this update
778
* (PKCS#11 param: CK_BYTE_PTR pEncryptedPart,
779
* CK_ULONG_PTR pulEncryptedPartLen)
780
* @exception PKCS11Exception If function returns other value than CKR_OK.
781
* @preconditions
782
* @postconditions
783
*/
784
public native int C_EncryptUpdate(long hSession, long directIn, byte[] in,
785
int inOfs, int inLen, long directOut, byte[] out, int outOfs,
786
int outLen) throws PKCS11Exception;
787
788
789
/**
790
* C_EncryptFinal finishes a multiple-part encryption
791
* operation.
792
* (Encryption and decryption)
793
*
794
* @param hSession the session's handle
795
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
796
* @param directOut the address for the encrypted data
797
* @param out buffer for the encrypted data
798
* @param outOfs buffer offset for the encrypted data
799
* @param outLen buffer size for the encrypted data
800
* @return the length of the last part of the encrypted data
801
* (PKCS#11 param: CK_BYTE_PTR pLastEncryptedPart,
802
* CK_ULONG_PTR pulLastEncryptedPartLen)
803
* @exception PKCS11Exception If function returns other value than CKR_OK.
804
* @preconditions
805
* @postconditions
806
*/
807
public native int C_EncryptFinal(long hSession, long directOut, byte[] out,
808
int outOfs, int outLen) throws PKCS11Exception;
809
810
811
/**
812
* C_DecryptInit initializes a decryption operation.
813
* (Encryption and decryption)
814
*
815
* @param hSession the session's handle
816
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
817
* @param pMechanism the decryption mechanism
818
* (PKCS#11 param: CK_MECHANISM_PTR pMechanism)
819
* @param hKey the handle of the decryption key
820
* (PKCS#11 param: CK_OBJECT_HANDLE hKey)
821
* @exception PKCS11Exception If function returns other value than CKR_OK.
822
* @preconditions
823
* @postconditions
824
*/
825
public native void C_DecryptInit(long hSession, CK_MECHANISM pMechanism,
826
long hKey) throws PKCS11Exception;
827
828
829
/**
830
* C_Decrypt decrypts encrypted data in a single part.
831
* (Encryption and decryption)
832
*
833
* @param hSession the session's handle
834
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
835
* @param directIn the address of the to-be-decrypted data
836
* @param in buffer containing the to-be-decrypted data
837
* @param inOfs buffer offset of the to-be-decrypted data
838
* @param inLen length of the to-be-decrypted data
839
* (PKCS#11 param: CK_BYTE_PTR pDecryptedData,
840
* CK_ULONG ulDecryptedDataLen)
841
* @param directOut the address for the decrypted data
842
* @param out buffer for the decrypted data
843
* @param outOfs buffer offset for the decrypted data
844
* @param outLen buffer size for the decrypted data
845
* @return the length of decrypted data
846
* (PKCS#11 param: CK_BYTE_PTR pData, CK_ULONG_PTR pulDataLen)
847
* @exception PKCS11Exception If function returns other value than CKR_OK.
848
* @preconditions
849
* @postconditions
850
*/
851
public native int C_Decrypt(long hSession, long directIn, byte[] in,
852
int inOfs, int inLen, long directOut, byte[] out, int outOfs,
853
int outLen) throws PKCS11Exception;
854
855
856
/**
857
* C_DecryptUpdate continues a multiple-part decryption
858
* operation.
859
* (Encryption and decryption)
860
*
861
* @param hSession the session's handle
862
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
863
* @param directIn the address of the to-be-decrypted data
864
* @param in buffer containing the to-be-decrypted data
865
* @param inOfs buffer offset of the to-be-decrypted data
866
* @param inLen length of the to-be-decrypted data
867
* (PKCS#11 param: CK_BYTE_PTR pDecryptedPart,
868
* CK_ULONG ulDecryptedPartLen)
869
* @param directOut the address for the decrypted data
870
* @param out buffer for the decrypted data
871
* @param outOfs buffer offset for the decrypted data
872
* @param outLen buffer size for the decrypted data
873
* @return the length of decrypted data for this update
874
* (PKCS#11 param: CK_BYTE_PTR pPart, CK_ULONG_PTR pulPartLen)
875
* @exception PKCS11Exception If function returns other value than CKR_OK.
876
* @preconditions
877
* @postconditions
878
*/
879
public native int C_DecryptUpdate(long hSession, long directIn, byte[] in,
880
int inOfs, int inLen, long directOut, byte[] out, int outOfs,
881
int outLen) throws PKCS11Exception;
882
883
884
/**
885
* C_DecryptFinal finishes a multiple-part decryption
886
* operation.
887
* (Encryption and decryption)
888
*
889
* @param hSession the session's handle
890
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
891
* @param directOut the address for the decrypted data
892
* @param out buffer for the decrypted data
893
* @param outOfs buffer offset for the decrypted data
894
* @param outLen buffer size for the decrypted data
895
* @return the length of this last part of decrypted data
896
* (PKCS#11 param: CK_BYTE_PTR pLastPart,
897
* CK_ULONG_PTR pulLastPartLen)
898
* @exception PKCS11Exception If function returns other value than CKR_OK.
899
* @preconditions
900
* @postconditions
901
*/
902
public native int C_DecryptFinal(long hSession, long directOut, byte[] out,
903
int outOfs, int outLen) throws PKCS11Exception;
904
905
906
907
/* *****************************************************************************
908
* Message digesting
909
******************************************************************************/
910
911
/**
912
* C_DigestInit initializes a message-digesting operation.
913
* (Message digesting)
914
*
915
* @param hSession the session's handle
916
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
917
* @param pMechanism the digesting mechanism
918
* (PKCS#11 param: CK_MECHANISM_PTR pMechanism)
919
* @exception PKCS11Exception If function returns other value than CKR_OK.
920
* @preconditions
921
* @postconditions
922
*/
923
public native void C_DigestInit(long hSession, CK_MECHANISM pMechanism)
924
throws PKCS11Exception;
925
926
927
// note that C_DigestSingle does not exist in PKCS#11
928
// we combined the C_DigestInit and C_Digest into a single function
929
// to save on Java<->C transitions and save 5-10% on small digests
930
// this made the C_Digest method redundant, it has been removed
931
/**
932
* C_Digest digests data in a single part.
933
* (Message digesting)
934
*
935
* @param hSession the session's handle
936
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
937
* @param data the data to get digested and the data's length
938
* (PKCS#11 param: CK_BYTE_PTR pData, CK_ULONG ulDataLen)
939
* @return the message digest and the length of the message digest
940
* (PKCS#11 param: CK_BYTE_PTR pDigest, CK_ULONG_PTR pulDigestLen)
941
* @exception PKCS11Exception If function returns other value than CKR_OK.
942
* @preconditions (data <> null)
943
* @postconditions (result <> null)
944
*/
945
public native int C_DigestSingle(long hSession, CK_MECHANISM pMechanism,
946
byte[] in, int inOfs, int inLen, byte[] digest, int digestOfs,
947
int digestLen) throws PKCS11Exception;
948
949
950
/**
951
* C_DigestUpdate continues a multiple-part message-digesting
952
* operation.
953
* (Message digesting)
954
*
955
* @param hSession the session's handle
956
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
957
* @param pPart the data to get digested and the data's length
958
* (PKCS#11 param: CK_BYTE_PTR pPart, CK_ULONG ulPartLen)
959
* @exception PKCS11Exception If function returns other value than CKR_OK.
960
* @preconditions (pPart <> null)
961
* @postconditions
962
*/
963
public native void C_DigestUpdate(long hSession, long directIn, byte[] in,
964
int inOfs, int inLen) throws PKCS11Exception;
965
966
967
/**
968
* C_DigestKey continues a multi-part message-digesting
969
* operation, by digesting the value of a secret key as part of
970
* the data already digested.
971
* (Message digesting)
972
*
973
* @param hSession the session's handle
974
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
975
* @param hKey the handle of the secret key to be digested
976
* (PKCS#11 param: CK_OBJECT_HANDLE hKey)
977
* @exception PKCS11Exception If function returns other value than CKR_OK.
978
* @preconditions
979
* @postconditions
980
*/
981
public native void C_DigestKey(long hSession, long hKey)
982
throws PKCS11Exception;
983
984
985
/**
986
* C_DigestFinal finishes a multiple-part message-digesting
987
* operation.
988
* (Message digesting)
989
*
990
* @param hSession the session's handle
991
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
992
* @return the message digest and the length of the message digest
993
* (PKCS#11 param: CK_BYTE_PTR pDigest, CK_ULONG_PTR pulDigestLen)
994
* @exception PKCS11Exception If function returns other value than CKR_OK.
995
* @preconditions
996
* @postconditions (result <> null)
997
*/
998
public native int C_DigestFinal(long hSession, byte[] pDigest, int digestOfs,
999
int digestLen) throws PKCS11Exception;
1000
1001
1002
1003
/* *****************************************************************************
1004
* Signing and MACing
1005
******************************************************************************/
1006
1007
/**
1008
* C_SignInit initializes a signature (private key encryption)
1009
* operation, where the signature is (will be) an appendix to
1010
* the data, and plaintext cannot be recovered from the
1011
* signature.
1012
* (Signing and MACing)
1013
*
1014
* @param hSession the session's handle
1015
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
1016
* @param pMechanism the signature mechanism
1017
* (PKCS#11 param: CK_MECHANISM_PTR pMechanism)
1018
* @param hKey the handle of the signature key
1019
* (PKCS#11 param: CK_OBJECT_HANDLE hKey)
1020
* @exception PKCS11Exception If function returns other value than CKR_OK.
1021
* @preconditions
1022
* @postconditions
1023
*/
1024
public native void C_SignInit(long hSession, CK_MECHANISM pMechanism,
1025
long hKey) throws PKCS11Exception;
1026
1027
1028
/**
1029
* C_Sign signs (encrypts with private key) data in a single
1030
* part, where the signature is (will be) an appendix to the
1031
* data, and plaintext cannot be recovered from the signature.
1032
* (Signing and MACing)
1033
*
1034
* @param hSession the session's handle
1035
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
1036
* @param pData the data to sign and the data's length
1037
* (PKCS#11 param: CK_BYTE_PTR pData, CK_ULONG ulDataLen)
1038
* @return the signature and the signature's length
1039
* (PKCS#11 param: CK_BYTE_PTR pSignature,
1040
* CK_ULONG_PTR pulSignatureLen)
1041
* @exception PKCS11Exception If function returns other value than CKR_OK.
1042
* @preconditions (pData <> null)
1043
* @postconditions (result <> null)
1044
*/
1045
public native byte[] C_Sign(long hSession, byte[] pData)
1046
throws PKCS11Exception;
1047
1048
1049
/**
1050
* C_SignUpdate continues a multiple-part signature operation,
1051
* where the signature is (will be) an appendix to the data,
1052
* and plaintext cannot be recovered from the signature.
1053
* (Signing and MACing)
1054
*
1055
* @param hSession the session's handle
1056
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
1057
* @param pPart the data part to sign and the data part's length
1058
* (PKCS#11 param: CK_BYTE_PTR pPart, CK_ULONG ulPartLen)
1059
* @exception PKCS11Exception If function returns other value than CKR_OK.
1060
* @preconditions (pPart <> null)
1061
* @postconditions
1062
*/
1063
public native void C_SignUpdate(long hSession, long directIn, byte[] in,
1064
int inOfs, int inLen) throws PKCS11Exception;
1065
1066
1067
/**
1068
* C_SignFinal finishes a multiple-part signature operation,
1069
* returning the signature.
1070
* (Signing and MACing)
1071
*
1072
* @param hSession the session's handle
1073
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
1074
* @param expectedLen expected signature length, can be 0 if unknown
1075
* @return the signature and the signature's length
1076
* (PKCS#11 param: CK_BYTE_PTR pSignature,
1077
* CK_ULONG_PTR pulSignatureLen)
1078
* @exception PKCS11Exception If function returns other value than CKR_OK.
1079
* @preconditions
1080
* @postconditions (result <> null)
1081
*/
1082
public native byte[] C_SignFinal(long hSession, int expectedLen)
1083
throws PKCS11Exception;
1084
1085
1086
/**
1087
* C_SignRecoverInit initializes a signature operation, where
1088
* the data can be recovered from the signature.
1089
* (Signing and MACing)
1090
*
1091
* @param hSession the session's handle
1092
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
1093
* @param pMechanism the signature mechanism
1094
* (PKCS#11 param: CK_MECHANISM_PTR pMechanism)
1095
* @param hKey the handle of the signature key
1096
* (PKCS#11 param: CK_OBJECT_HANDLE hKey)
1097
* @exception PKCS11Exception If function returns other value than CKR_OK.
1098
* @preconditions
1099
* @postconditions
1100
*/
1101
public native void C_SignRecoverInit(long hSession, CK_MECHANISM pMechanism,
1102
long hKey) throws PKCS11Exception;
1103
1104
1105
/**
1106
* C_SignRecover signs data in a single operation, where the
1107
* data can be recovered from the signature.
1108
* (Signing and MACing)
1109
*
1110
* @param hSession the session's handle
1111
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
1112
* @param pData the data to sign and the data's length
1113
* (PKCS#11 param: CK_BYTE_PTR pData, CK_ULONG ulDataLen)
1114
* @return the signature and the signature's length
1115
* (PKCS#11 param: CK_BYTE_PTR pSignature,
1116
* CK_ULONG_PTR pulSignatureLen)
1117
* @exception PKCS11Exception If function returns other value than CKR_OK.
1118
* @preconditions (pData <> null)
1119
* @postconditions (result <> null)
1120
*/
1121
public native int C_SignRecover(long hSession, byte[] in, int inOfs,
1122
int inLen, byte[] out, int outOufs, int outLen)
1123
throws PKCS11Exception;
1124
1125
1126
1127
/* *****************************************************************************
1128
* Verifying signatures and MACs
1129
******************************************************************************/
1130
1131
/**
1132
* C_VerifyInit initializes a verification operation, where the
1133
* signature is an appendix to the data, and plaintext cannot
1134
* cannot be recovered from the signature (e.g. DSA).
1135
* (Signing and MACing)
1136
*
1137
* @param hSession the session's handle
1138
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
1139
* @param pMechanism the verification mechanism
1140
* (PKCS#11 param: CK_MECHANISM_PTR pMechanism)
1141
* @param hKey the handle of the verification key
1142
* (PKCS#11 param: CK_OBJECT_HANDLE hKey)
1143
* @exception PKCS11Exception If function returns other value than CKR_OK.
1144
* @preconditions
1145
* @postconditions
1146
*/
1147
public native void C_VerifyInit(long hSession, CK_MECHANISM pMechanism,
1148
long hKey) throws PKCS11Exception;
1149
1150
1151
/**
1152
* C_Verify verifies a signature in a single-part operation,
1153
* where the signature is an appendix to the data, and plaintext
1154
* cannot be recovered from the signature.
1155
* (Signing and MACing)
1156
*
1157
* @param hSession the session's handle
1158
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
1159
* @param pData the signed data and the signed data's length
1160
* (PKCS#11 param: CK_BYTE_PTR pData, CK_ULONG ulDataLen)
1161
* @param pSignature the signature to verify and the signature's length
1162
* (PKCS#11 param: CK_BYTE_PTR pSignature, CK_ULONG ulSignatureLen)
1163
* @exception PKCS11Exception If function returns other value than CKR_OK.
1164
* @preconditions (pData <> null) and (pSignature <> null)
1165
* @postconditions
1166
*/
1167
public native void C_Verify(long hSession, byte[] pData, byte[] pSignature)
1168
throws PKCS11Exception;
1169
1170
1171
/**
1172
* C_VerifyUpdate continues a multiple-part verification
1173
* operation, where the signature is an appendix to the data,
1174
* and plaintext cannot be recovered from the signature.
1175
* (Signing and MACing)
1176
*
1177
* @param hSession the session's handle
1178
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
1179
* @param pPart the signed data part and the signed data part's length
1180
* (PKCS#11 param: CK_BYTE_PTR pPart, CK_ULONG ulPartLen)
1181
* @exception PKCS11Exception If function returns other value than CKR_OK.
1182
* @preconditions (pPart <> null)
1183
* @postconditions
1184
*/
1185
public native void C_VerifyUpdate(long hSession, long directIn, byte[] in,
1186
int inOfs, int inLen) throws PKCS11Exception;
1187
1188
1189
/**
1190
* C_VerifyFinal finishes a multiple-part verification
1191
* operation, checking the signature.
1192
* (Signing and MACing)
1193
*
1194
* @param hSession the session's handle
1195
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
1196
* @param pSignature the signature to verify and the signature's length
1197
* (PKCS#11 param: CK_BYTE_PTR pSignature, CK_ULONG ulSignatureLen)
1198
* @exception PKCS11Exception If function returns other value than CKR_OK.
1199
* @preconditions (pSignature <> null)
1200
* @postconditions
1201
*/
1202
public native void C_VerifyFinal(long hSession, byte[] pSignature)
1203
throws PKCS11Exception;
1204
1205
1206
/**
1207
* C_VerifyRecoverInit initializes a signature verification
1208
* operation, where the data is recovered from the signature.
1209
* (Signing and MACing)
1210
*
1211
* @param hSession the session's handle
1212
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
1213
* @param pMechanism the verification mechanism
1214
* (PKCS#11 param: CK_MECHANISM_PTR pMechanism)
1215
* @param hKey the handle of the verification key
1216
* (PKCS#11 param: CK_OBJECT_HANDLE hKey)
1217
* @exception PKCS11Exception If function returns other value than CKR_OK.
1218
* @preconditions
1219
* @postconditions
1220
*/
1221
public native void C_VerifyRecoverInit(long hSession,
1222
CK_MECHANISM pMechanism, long hKey) throws PKCS11Exception;
1223
1224
1225
/**
1226
* C_VerifyRecover verifies a signature in a single-part
1227
* operation, where the data is recovered from the signature.
1228
* (Signing and MACing)
1229
*
1230
* @param hSession the session's handle
1231
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
1232
* @param pSignature the signature to verify and the signature's length
1233
* (PKCS#11 param: CK_BYTE_PTR pSignature, CK_ULONG ulSignatureLen)
1234
* @return the recovered data and the recovered data's length
1235
* (PKCS#11 param: CK_BYTE_PTR pData, CK_ULONG_PTR pulDataLen)
1236
* @exception PKCS11Exception If function returns other value than CKR_OK.
1237
* @preconditions (pSignature <> null)
1238
* @postconditions (result <> null)
1239
*/
1240
public native int C_VerifyRecover(long hSession, byte[] in, int inOfs,
1241
int inLen, byte[] out, int outOufs, int outLen)
1242
throws PKCS11Exception;
1243
1244
1245
1246
/* *****************************************************************************
1247
* Dual-function cryptographic operations
1248
******************************************************************************/
1249
1250
/**
1251
* C_DigestEncryptUpdate continues a multiple-part digesting
1252
* and encryption operation.
1253
* (Dual-function cryptographic operations)
1254
*
1255
* @param hSession the session's handle
1256
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
1257
* @param pPart the data part to digest and to encrypt and the data's length
1258
* (PKCS#11 param: CK_BYTE_PTR pPart, CK_ULONG ulPartLen)
1259
* @return the digested and encrypted data part and the data part's length
1260
* (PKCS#11 param: CK_BYTE_PTR pEncryptedPart,
1261
* CK_ULONG_PTR pulEncryptedPartLen)
1262
* @exception PKCS11Exception If function returns other value than CKR_OK.
1263
* @preconditions (pPart <> null)
1264
* @postconditions
1265
*/
1266
// public native byte[] C_DigestEncryptUpdate(long hSession, byte[] pPart)
1267
// throws PKCS11Exception;
1268
1269
1270
/**
1271
* C_DecryptDigestUpdate continues a multiple-part decryption and
1272
* digesting operation.
1273
* (Dual-function cryptographic operations)
1274
*
1275
* @param hSession the session's handle
1276
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
1277
* @param pEncryptedPart the encrypted data part to decrypt and to digest
1278
* and encrypted data part's length
1279
* (PKCS#11 param: CK_BYTE_PTR pEncryptedPart,
1280
* CK_ULONG ulEncryptedPartLen)
1281
* @return the decrypted and digested data part and the data part's length
1282
* (PKCS#11 param: CK_BYTE_PTR pPart, CK_ULONG_PTR pulPartLen)
1283
* @exception PKCS11Exception If function returns other value than CKR_OK.
1284
* @preconditions (pEncryptedPart <> null)
1285
* @postconditions
1286
*/
1287
// public native byte[] C_DecryptDigestUpdate(long hSession,
1288
// byte[] pEncryptedPart) throws PKCS11Exception;
1289
1290
1291
/**
1292
* C_SignEncryptUpdate continues a multiple-part signing and
1293
* encryption operation.
1294
* (Dual-function cryptographic operations)
1295
*
1296
* @param hSession the session's handle
1297
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
1298
* @param pPart the data part to sign and to encrypt and the data part's
1299
* length
1300
* (PKCS#11 param: CK_BYTE_PTR pPart, CK_ULONG ulPartLen)
1301
* @return the signed and encrypted data part and the data part's length
1302
* (PKCS#11 param: CK_BYTE_PTR pEncryptedPart,
1303
* CK_ULONG_PTR pulEncryptedPartLen)
1304
* @exception PKCS11Exception If function returns other value than CKR_OK.
1305
* @preconditions (pPart <> null)
1306
* @postconditions
1307
*/
1308
// public native byte[] C_SignEncryptUpdate(long hSession, byte[] pPart)
1309
// throws PKCS11Exception;
1310
1311
1312
/**
1313
* C_DecryptVerifyUpdate continues a multiple-part decryption and
1314
* verify operation.
1315
* (Dual-function cryptographic operations)
1316
*
1317
* @param hSession the session's handle
1318
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
1319
* @param pEncryptedPart the encrypted data part to decrypt and to verify
1320
* and the data part's length
1321
* (PKCS#11 param: CK_BYTE_PTR pEncryptedPart,
1322
* CK_ULONG ulEncryptedPartLen)
1323
* @return the decrypted and verified data part and the data part's length
1324
* (PKCS#11 param: CK_BYTE_PTR pPart, CK_ULONG_PTR pulPartLen)
1325
* @exception PKCS11Exception If function returns other value than CKR_OK.
1326
* @preconditions (pEncryptedPart <> null)
1327
* @postconditions
1328
*/
1329
// public native byte[] C_DecryptVerifyUpdate(long hSession,
1330
// byte[] pEncryptedPart) throws PKCS11Exception;
1331
1332
1333
/* *****************************************************************************
1334
* Key management
1335
******************************************************************************/
1336
1337
/**
1338
* getNativeKeyInfo gets the key object attributes and values as an opaque
1339
* byte array to be used in createNativeKey method.
1340
* (Key management)
1341
*
1342
* @param hSession the session's handle
1343
* @param hKey key's handle
1344
* @param hWrappingKey key handle for wrapping the extracted sensitive keys.
1345
* -1 if not used.
1346
* @param pWrappingMech mechanism for wrapping the extracted sensitive keys
1347
* @return an opaque byte array containing the key object attributes
1348
* and values
1349
* @exception PKCS11Exception If an internal PKCS#11 function returns other
1350
* value than CKR_OK.
1351
* @preconditions
1352
* @postconditions
1353
*/
1354
public native byte[] getNativeKeyInfo(long hSession, long hKey,
1355
long hWrappingKey, CK_MECHANISM pWrappingMech) throws PKCS11Exception;
1356
1357
/**
1358
* createNativeKey creates a key object with attributes and values
1359
* specified by parameter as an opaque byte array.
1360
* (Key management)
1361
*
1362
* @param hSession the session's handle
1363
* @param keyInfo opaque byte array containing key object attributes
1364
* and values
1365
* @param hWrappingKey key handle for unwrapping the extracted sensitive keys.
1366
* -1 if not used.
1367
* @param pWrappingMech mechanism for unwrapping the extracted sensitive keys
1368
* @return key object handle
1369
* @exception PKCS11Exception If an internal PKCS#11 function returns other
1370
* value than CKR_OK.
1371
* @preconditions
1372
* @postconditions
1373
*/
1374
public native long createNativeKey(long hSession, byte[] keyInfo,
1375
long hWrappingKey, CK_MECHANISM pWrappingMech) throws PKCS11Exception;
1376
1377
/**
1378
* C_GenerateKey generates a secret key, creating a new key
1379
* object.
1380
* (Key management)
1381
*
1382
* @param hSession the session's handle
1383
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
1384
* @param pMechanism the key generation mechanism
1385
* (PKCS#11 param: CK_MECHANISM_PTR pMechanism)
1386
* @param pTemplate the template for the new key and the number of
1387
* attributes in the template
1388
* (PKCS#11 param: CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount)
1389
* @return the handle of the new key
1390
* (PKCS#11 param: CK_OBJECT_HANDLE_PTR phKey)
1391
* @exception PKCS11Exception If function returns other value than CKR_OK.
1392
* @preconditions
1393
* @postconditions
1394
*/
1395
public native long C_GenerateKey(long hSession, CK_MECHANISM pMechanism,
1396
CK_ATTRIBUTE[] pTemplate) throws PKCS11Exception;
1397
1398
1399
/**
1400
* C_GenerateKeyPair generates a public-key/private-key pair,
1401
* creating new key objects.
1402
* (Key management)
1403
*
1404
* @param hSession the session's handle
1405
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
1406
* @param pMechanism the key generation mechanism
1407
* (PKCS#11 param: CK_MECHANISM_PTR pMechanism)
1408
* @param pPublicKeyTemplate the template for the new public key and the
1409
* number of attributes in the template
1410
* (PKCS#11 param: CK_ATTRIBUTE_PTR pPublicKeyTemplate,
1411
* CK_ULONG ulPublicKeyAttributeCount)
1412
* @param pPrivateKeyTemplate the template for the new private key and the
1413
* number of attributes in the template
1414
* (PKCS#11 param: CK_ATTRIBUTE_PTR pPrivateKeyTemplate
1415
* CK_ULONG ulPrivateKeyAttributeCount)
1416
* @return a long array with exactly two elements and the public key handle
1417
* as the first element and the private key handle as the second
1418
* element
1419
* (PKCS#11 param: CK_OBJECT_HANDLE_PTR phPublicKey,
1420
* CK_OBJECT_HANDLE_PTR phPrivateKey)
1421
* @exception PKCS11Exception If function returns other value than CKR_OK.
1422
* @preconditions (pMechanism <> null)
1423
* @postconditions (result <> null) and (result.length == 2)
1424
*/
1425
public native long[] C_GenerateKeyPair(long hSession,
1426
CK_MECHANISM pMechanism, CK_ATTRIBUTE[] pPublicKeyTemplate,
1427
CK_ATTRIBUTE[] pPrivateKeyTemplate) throws PKCS11Exception;
1428
1429
1430
1431
/**
1432
* C_WrapKey wraps (i.e., encrypts) a key.
1433
* (Key management)
1434
*
1435
* @param hSession the session's handle
1436
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
1437
* @param pMechanism the wrapping mechanism
1438
* (PKCS#11 param: CK_MECHANISM_PTR pMechanism)
1439
* @param hWrappingKey the handle of the wrapping key
1440
* (PKCS#11 param: CK_OBJECT_HANDLE hWrappingKey)
1441
* @param hKey the handle of the key to be wrapped
1442
* (PKCS#11 param: CK_OBJECT_HANDLE hKey)
1443
* @return the wrapped key and the length of the wrapped key
1444
* (PKCS#11 param: CK_BYTE_PTR pWrappedKey,
1445
* CK_ULONG_PTR pulWrappedKeyLen)
1446
* @exception PKCS11Exception If function returns other value than CKR_OK.
1447
* @preconditions
1448
* @postconditions (result <> null)
1449
*/
1450
public native byte[] C_WrapKey(long hSession, CK_MECHANISM pMechanism,
1451
long hWrappingKey, long hKey) throws PKCS11Exception;
1452
1453
1454
/**
1455
* C_UnwrapKey unwraps (decrypts) a wrapped key, creating a new
1456
* key object.
1457
* (Key management)
1458
*
1459
* @param hSession the session's handle
1460
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
1461
* @param pMechanism the unwrapping mechanism
1462
* (PKCS#11 param: CK_MECHANISM_PTR pMechanism)
1463
* @param hUnwrappingKey the handle of the unwrapping key
1464
* (PKCS#11 param: CK_OBJECT_HANDLE hUnwrappingKey)
1465
* @param pWrappedKey the wrapped key to unwrap and the wrapped key's length
1466
* (PKCS#11 param: CK_BYTE_PTR pWrappedKey, CK_ULONG ulWrappedKeyLen)
1467
* @param pTemplate the template for the new key and the number of
1468
* attributes in the template
1469
* (PKCS#11 param: CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount)
1470
* @return the handle of the unwrapped key
1471
* (PKCS#11 param: CK_OBJECT_HANDLE_PTR phKey)
1472
* @exception PKCS11Exception If function returns other value than CKR_OK.
1473
* @preconditions (pWrappedKey <> null)
1474
* @postconditions
1475
*/
1476
public native long C_UnwrapKey(long hSession, CK_MECHANISM pMechanism,
1477
long hUnwrappingKey, byte[] pWrappedKey, CK_ATTRIBUTE[] pTemplate)
1478
throws PKCS11Exception;
1479
1480
1481
/**
1482
* C_DeriveKey derives a key from a base key, creating a new key
1483
* object.
1484
* (Key management)
1485
*
1486
* @param hSession the session's handle
1487
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
1488
* @param pMechanism the key derivation mechanism
1489
* (PKCS#11 param: CK_MECHANISM_PTR pMechanism)
1490
* @param hBaseKey the handle of the base key
1491
* (PKCS#11 param: CK_OBJECT_HANDLE hBaseKey)
1492
* @param pTemplate the template for the new key and the number of
1493
* attributes in the template
1494
* (PKCS#11 param: CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount)
1495
* @return the handle of the derived key
1496
* (PKCS#11 param: CK_OBJECT_HANDLE_PTR phKey)
1497
* @exception PKCS11Exception If function returns other value than CKR_OK.
1498
* @preconditions
1499
* @postconditions
1500
*/
1501
public native long C_DeriveKey(long hSession, CK_MECHANISM pMechanism,
1502
long hBaseKey, CK_ATTRIBUTE[] pTemplate) throws PKCS11Exception;
1503
1504
1505
1506
/* *****************************************************************************
1507
* Random number generation
1508
******************************************************************************/
1509
1510
/**
1511
* C_SeedRandom mixes additional seed material into the token's
1512
* random number generator.
1513
* (Random number generation)
1514
*
1515
* @param hSession the session's handle
1516
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
1517
* @param pSeed the seed material and the seed material's length
1518
* (PKCS#11 param: CK_BYTE_PTR pSeed, CK_ULONG ulSeedLen)
1519
* @exception PKCS11Exception If function returns other value than CKR_OK.
1520
* @preconditions (pSeed <> null)
1521
* @postconditions
1522
*/
1523
public native void C_SeedRandom(long hSession, byte[] pSeed)
1524
throws PKCS11Exception;
1525
1526
1527
/**
1528
* C_GenerateRandom generates random data.
1529
* (Random number generation)
1530
*
1531
* @param hSession the session's handle
1532
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
1533
* @param RandomData receives the random data and the length of RandomData
1534
* is the length of random data to be generated
1535
* (PKCS#11 param: CK_BYTE_PTR pRandomData, CK_ULONG ulRandomLen)
1536
* @exception PKCS11Exception If function returns other value than CKR_OK.
1537
* @preconditions (randomData <> null)
1538
* @postconditions
1539
*/
1540
public native void C_GenerateRandom(long hSession, byte[] randomData)
1541
throws PKCS11Exception;
1542
1543
1544
1545
/* *****************************************************************************
1546
* Parallel function management
1547
******************************************************************************/
1548
1549
/**
1550
* C_GetFunctionStatus is a legacy function; it obtains an
1551
* updated status of a function running in parallel with an
1552
* application.
1553
* (Parallel function management)
1554
*
1555
* @param hSession the session's handle
1556
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
1557
* @exception PKCS11Exception If function returns other value than CKR_OK.
1558
* @preconditions
1559
* @postconditions
1560
*/
1561
// public native void C_GetFunctionStatus(long hSession)
1562
// throws PKCS11Exception;
1563
1564
1565
/**
1566
* C_CancelFunction is a legacy function; it cancels a function
1567
* running in parallel.
1568
* (Parallel function management)
1569
*
1570
* @param hSession the session's handle
1571
* (PKCS#11 param: CK_SESSION_HANDLE hSession)
1572
* @exception PKCS11Exception If function returns other value than CKR_OK.
1573
* @preconditions
1574
* @postconditions
1575
*/
1576
// public native void C_CancelFunction(long hSession) throws PKCS11Exception;
1577
1578
1579
1580
/* *****************************************************************************
1581
* Functions added in for Cryptoki Version 2.01 or later
1582
******************************************************************************/
1583
1584
/**
1585
* C_WaitForSlotEvent waits for a slot event (token insertion,
1586
* removal, etc.) to occur.
1587
* (General-purpose)
1588
*
1589
* @param flags blocking/nonblocking flag
1590
* (PKCS#11 param: CK_FLAGS flags)
1591
* @param pReserved reserved. Should be null
1592
* (PKCS#11 param: CK_VOID_PTR pReserved)
1593
* @return the slot ID where the event occurred
1594
* (PKCS#11 param: CK_SLOT_ID_PTR pSlot)
1595
* @exception PKCS11Exception If function returns other value than CKR_OK.
1596
* @preconditions (pRserved == null)
1597
* @postconditions
1598
*/
1599
// public native long C_WaitForSlotEvent(long flags, Object pRserved)
1600
// throws PKCS11Exception;
1601
1602
/**
1603
* Returns the string representation of this object.
1604
*
1605
* @return The string representation of object
1606
*/
1607
public String toString() {
1608
return "Module name: " + pkcs11ModulePath;
1609
}
1610
1611
/**
1612
* Calls disconnect() to cleanup the native part of the wrapper. Once this
1613
* method is called, this object cannot be used any longer. Any subsequent
1614
* call to a C_* method will result in a runtime exception.
1615
*
1616
* @exception Throwable If finalization fails.
1617
*/
1618
@SuppressWarnings("deprecation")
1619
protected void finalize() throws Throwable {
1620
disconnect();
1621
}
1622
1623
// PKCS11 subclass that has all methods synchronized and delegating to the
1624
// parent. Used for tokens that only support single threaded access
1625
static class SynchronizedPKCS11 extends PKCS11 {
1626
1627
SynchronizedPKCS11(String pkcs11ModulePath, String functionListName)
1628
throws IOException {
1629
super(pkcs11ModulePath, functionListName);
1630
}
1631
1632
synchronized void C_Initialize(Object pInitArgs) throws PKCS11Exception {
1633
super.C_Initialize(pInitArgs);
1634
}
1635
1636
public synchronized void C_Finalize(Object pReserved)
1637
throws PKCS11Exception {
1638
super.C_Finalize(pReserved);
1639
}
1640
1641
public synchronized CK_INFO C_GetInfo() throws PKCS11Exception {
1642
return super.C_GetInfo();
1643
}
1644
1645
public synchronized long[] C_GetSlotList(boolean tokenPresent)
1646
throws PKCS11Exception {
1647
return super.C_GetSlotList(tokenPresent);
1648
}
1649
1650
public synchronized CK_SLOT_INFO C_GetSlotInfo(long slotID)
1651
throws PKCS11Exception {
1652
return super.C_GetSlotInfo(slotID);
1653
}
1654
1655
public synchronized CK_TOKEN_INFO C_GetTokenInfo(long slotID)
1656
throws PKCS11Exception {
1657
return super.C_GetTokenInfo(slotID);
1658
}
1659
1660
public synchronized long[] C_GetMechanismList(long slotID)
1661
throws PKCS11Exception {
1662
return super.C_GetMechanismList(slotID);
1663
}
1664
1665
public synchronized CK_MECHANISM_INFO C_GetMechanismInfo(long slotID,
1666
long type) throws PKCS11Exception {
1667
return super.C_GetMechanismInfo(slotID, type);
1668
}
1669
1670
public synchronized long C_OpenSession(long slotID, long flags,
1671
Object pApplication, CK_NOTIFY Notify) throws PKCS11Exception {
1672
return super.C_OpenSession(slotID, flags, pApplication, Notify);
1673
}
1674
1675
public synchronized void C_CloseSession(long hSession)
1676
throws PKCS11Exception {
1677
super.C_CloseSession(hSession);
1678
}
1679
1680
public synchronized CK_SESSION_INFO C_GetSessionInfo(long hSession)
1681
throws PKCS11Exception {
1682
return super.C_GetSessionInfo(hSession);
1683
}
1684
1685
public synchronized void C_Login(long hSession, long userType, char[] pPin)
1686
throws PKCS11Exception {
1687
super.C_Login(hSession, userType, pPin);
1688
}
1689
1690
public synchronized void C_Logout(long hSession) throws PKCS11Exception {
1691
super.C_Logout(hSession);
1692
}
1693
1694
public synchronized long C_CreateObject(long hSession,
1695
CK_ATTRIBUTE[] pTemplate) throws PKCS11Exception {
1696
return super.C_CreateObject(hSession, pTemplate);
1697
}
1698
1699
public synchronized long C_CopyObject(long hSession, long hObject,
1700
CK_ATTRIBUTE[] pTemplate) throws PKCS11Exception {
1701
return super.C_CopyObject(hSession, hObject, pTemplate);
1702
}
1703
1704
public synchronized void C_DestroyObject(long hSession, long hObject)
1705
throws PKCS11Exception {
1706
super.C_DestroyObject(hSession, hObject);
1707
}
1708
1709
public synchronized void C_GetAttributeValue(long hSession, long hObject,
1710
CK_ATTRIBUTE[] pTemplate) throws PKCS11Exception {
1711
super.C_GetAttributeValue(hSession, hObject, pTemplate);
1712
}
1713
1714
public synchronized void C_SetAttributeValue(long hSession, long hObject,
1715
CK_ATTRIBUTE[] pTemplate) throws PKCS11Exception {
1716
super.C_SetAttributeValue(hSession, hObject, pTemplate);
1717
}
1718
1719
public synchronized void C_FindObjectsInit(long hSession,
1720
CK_ATTRIBUTE[] pTemplate) throws PKCS11Exception {
1721
super.C_FindObjectsInit(hSession, pTemplate);
1722
}
1723
1724
public synchronized long[] C_FindObjects(long hSession,
1725
long ulMaxObjectCount) throws PKCS11Exception {
1726
return super.C_FindObjects(hSession, ulMaxObjectCount);
1727
}
1728
1729
public synchronized void C_FindObjectsFinal(long hSession)
1730
throws PKCS11Exception {
1731
super.C_FindObjectsFinal(hSession);
1732
}
1733
1734
public synchronized void C_EncryptInit(long hSession,
1735
CK_MECHANISM pMechanism, long hKey) throws PKCS11Exception {
1736
super.C_EncryptInit(hSession, pMechanism, hKey);
1737
}
1738
1739
public synchronized int C_Encrypt(long hSession, long directIn, byte[] in,
1740
int inOfs, int inLen, long directOut, byte[] out, int outOfs, int outLen)
1741
throws PKCS11Exception {
1742
return super.C_Encrypt(hSession, directIn, in, inOfs, inLen,
1743
directOut, out, outOfs, outLen);
1744
}
1745
1746
public synchronized int C_EncryptUpdate(long hSession, long directIn,
1747
byte[] in, int inOfs, int inLen, long directOut, byte[] out,
1748
int outOfs, int outLen) throws PKCS11Exception {
1749
return super.C_EncryptUpdate(hSession, directIn, in, inOfs, inLen,
1750
directOut, out, outOfs, outLen);
1751
}
1752
1753
public synchronized int C_EncryptFinal(long hSession, long directOut,
1754
byte[] out, int outOfs, int outLen) throws PKCS11Exception {
1755
return super.C_EncryptFinal(hSession, directOut, out, outOfs, outLen);
1756
}
1757
1758
public synchronized void C_DecryptInit(long hSession,
1759
CK_MECHANISM pMechanism, long hKey) throws PKCS11Exception {
1760
super.C_DecryptInit(hSession, pMechanism, hKey);
1761
}
1762
1763
public synchronized int C_Decrypt(long hSession, long directIn,
1764
byte[] in, int inOfs, int inLen, long directOut, byte[] out,
1765
int outOfs, int outLen) throws PKCS11Exception {
1766
return super.C_Decrypt(hSession, directIn, in, inOfs, inLen,
1767
directOut, out, outOfs, outLen);
1768
}
1769
1770
public synchronized int C_DecryptUpdate(long hSession, long directIn,
1771
byte[] in, int inOfs, int inLen, long directOut, byte[] out,
1772
int outOfs, int outLen) throws PKCS11Exception {
1773
return super.C_DecryptUpdate(hSession, directIn, in, inOfs, inLen,
1774
directOut, out, outOfs, outLen);
1775
}
1776
1777
public synchronized int C_DecryptFinal(long hSession, long directOut,
1778
byte[] out, int outOfs, int outLen) throws PKCS11Exception {
1779
return super.C_DecryptFinal(hSession, directOut, out, outOfs, outLen);
1780
}
1781
1782
public synchronized void C_DigestInit(long hSession, CK_MECHANISM pMechanism)
1783
throws PKCS11Exception {
1784
super.C_DigestInit(hSession, pMechanism);
1785
}
1786
1787
public synchronized int C_DigestSingle(long hSession,
1788
CK_MECHANISM pMechanism, byte[] in, int inOfs, int inLen,
1789
byte[] digest, int digestOfs, int digestLen) throws PKCS11Exception {
1790
return super.C_DigestSingle(hSession, pMechanism, in, inOfs, inLen,
1791
digest, digestOfs, digestLen);
1792
}
1793
1794
public synchronized void C_DigestUpdate(long hSession, long directIn,
1795
byte[] in, int inOfs, int inLen) throws PKCS11Exception {
1796
super.C_DigestUpdate(hSession, directIn, in, inOfs, inLen);
1797
}
1798
1799
public synchronized void C_DigestKey(long hSession, long hKey)
1800
throws PKCS11Exception {
1801
super.C_DigestKey(hSession, hKey);
1802
}
1803
1804
public synchronized int C_DigestFinal(long hSession, byte[] pDigest,
1805
int digestOfs, int digestLen) throws PKCS11Exception {
1806
return super.C_DigestFinal(hSession, pDigest, digestOfs, digestLen);
1807
}
1808
1809
public synchronized void C_SignInit(long hSession, CK_MECHANISM pMechanism,
1810
long hKey) throws PKCS11Exception {
1811
super.C_SignInit(hSession, pMechanism, hKey);
1812
}
1813
1814
public synchronized byte[] C_Sign(long hSession, byte[] pData)
1815
throws PKCS11Exception {
1816
return super.C_Sign(hSession, pData);
1817
}
1818
1819
public synchronized void C_SignUpdate(long hSession, long directIn,
1820
byte[] in, int inOfs, int inLen) throws PKCS11Exception {
1821
super.C_SignUpdate(hSession, directIn, in, inOfs, inLen);
1822
}
1823
1824
public synchronized byte[] C_SignFinal(long hSession, int expectedLen)
1825
throws PKCS11Exception {
1826
return super.C_SignFinal(hSession, expectedLen);
1827
}
1828
1829
public synchronized void C_SignRecoverInit(long hSession,
1830
CK_MECHANISM pMechanism, long hKey) throws PKCS11Exception {
1831
super.C_SignRecoverInit(hSession, pMechanism, hKey);
1832
}
1833
1834
public synchronized int C_SignRecover(long hSession, byte[] in, int inOfs,
1835
int inLen, byte[] out, int outOufs, int outLen)
1836
throws PKCS11Exception {
1837
return super.C_SignRecover(hSession, in, inOfs, inLen, out, outOufs,
1838
outLen);
1839
}
1840
1841
public synchronized void C_VerifyInit(long hSession, CK_MECHANISM pMechanism,
1842
long hKey) throws PKCS11Exception {
1843
super.C_VerifyInit(hSession, pMechanism, hKey);
1844
}
1845
1846
public synchronized void C_Verify(long hSession, byte[] pData,
1847
byte[] pSignature) throws PKCS11Exception {
1848
super.C_Verify(hSession, pData, pSignature);
1849
}
1850
1851
public synchronized void C_VerifyUpdate(long hSession, long directIn,
1852
byte[] in, int inOfs, int inLen) throws PKCS11Exception {
1853
super.C_VerifyUpdate(hSession, directIn, in, inOfs, inLen);
1854
}
1855
1856
public synchronized void C_VerifyFinal(long hSession, byte[] pSignature)
1857
throws PKCS11Exception {
1858
super.C_VerifyFinal(hSession, pSignature);
1859
}
1860
1861
public synchronized void C_VerifyRecoverInit(long hSession,
1862
CK_MECHANISM pMechanism, long hKey) throws PKCS11Exception {
1863
super.C_VerifyRecoverInit(hSession, pMechanism, hKey);
1864
}
1865
1866
public synchronized int C_VerifyRecover(long hSession, byte[] in, int inOfs,
1867
int inLen, byte[] out, int outOufs, int outLen)
1868
throws PKCS11Exception {
1869
return super.C_VerifyRecover(hSession, in, inOfs, inLen, out, outOufs,
1870
outLen);
1871
}
1872
1873
public synchronized long C_GenerateKey(long hSession,
1874
CK_MECHANISM pMechanism, CK_ATTRIBUTE[] pTemplate)
1875
throws PKCS11Exception {
1876
return super.C_GenerateKey(hSession, pMechanism, pTemplate);
1877
}
1878
1879
public synchronized long[] C_GenerateKeyPair(long hSession,
1880
CK_MECHANISM pMechanism, CK_ATTRIBUTE[] pPublicKeyTemplate,
1881
CK_ATTRIBUTE[] pPrivateKeyTemplate)
1882
throws PKCS11Exception {
1883
return super.C_GenerateKeyPair(hSession, pMechanism, pPublicKeyTemplate,
1884
pPrivateKeyTemplate);
1885
}
1886
1887
public synchronized byte[] C_WrapKey(long hSession, CK_MECHANISM pMechanism,
1888
long hWrappingKey, long hKey) throws PKCS11Exception {
1889
return super.C_WrapKey(hSession, pMechanism, hWrappingKey, hKey);
1890
}
1891
1892
public synchronized long C_UnwrapKey(long hSession, CK_MECHANISM pMechanism,
1893
long hUnwrappingKey, byte[] pWrappedKey, CK_ATTRIBUTE[] pTemplate)
1894
throws PKCS11Exception {
1895
return super.C_UnwrapKey(hSession, pMechanism, hUnwrappingKey,
1896
pWrappedKey, pTemplate);
1897
}
1898
1899
public synchronized long C_DeriveKey(long hSession, CK_MECHANISM pMechanism,
1900
long hBaseKey, CK_ATTRIBUTE[] pTemplate) throws PKCS11Exception {
1901
return super.C_DeriveKey(hSession, pMechanism, hBaseKey, pTemplate);
1902
}
1903
1904
public synchronized void C_SeedRandom(long hSession, byte[] pSeed)
1905
throws PKCS11Exception {
1906
super.C_SeedRandom(hSession, pSeed);
1907
}
1908
1909
public synchronized void C_GenerateRandom(long hSession, byte[] randomData)
1910
throws PKCS11Exception {
1911
super.C_GenerateRandom(hSession, randomData);
1912
}
1913
}
1914
}
1915
1916