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