src/jdk.crypto.cryptoki/share/native/libj2pkcs11/pkcs11wrapper.h
author valeriep
Tue, 11 Jun 2019 21:30:28 +0000
changeset 55332 f492567244ab
parent 53257 5170dc2bcf64
child 57737 6bbb4af131e3
permissions -rw-r--r--
8080462: Update SunPKCS11 provider with PKCS11 v2.40 support Summary: Added support for GCM, PSS, and other mechanisms Reviewed-by: jnimeh
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
55332
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
     2
 * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
/* Copyright  (c) 2002 Graz University of Technology. All rights reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * Redistribution and use in  source and binary forms, with or without
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * modification, are permitted  provided that the following conditions are met:
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * 1. Redistributions of  source code must retain the above copyright notice,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 *    this list of conditions and the following disclaimer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * 2. Redistributions in  binary form must reproduce the above copyright notice,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *    this list of conditions and the following disclaimer in the documentation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 *    and/or other materials provided with the distribution.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * 3. The end-user documentation included with the redistribution, if any, must
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *    include the following acknowledgment:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *    "This product includes software developed by IAIK of Graz University of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 *     Technology."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 *    Alternately, this acknowledgment may appear in the software itself, if
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 *    and wherever such third-party acknowledgments normally appear.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * 4. The names "Graz University of Technology" and "IAIK of Graz University of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 *    Technology" must not be used to endorse or promote products derived from
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 *    this software without prior written permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * 5. Products derived from this software may not be called
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 *    "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 *    written permission of Graz University of Technology.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 *  THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *  OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *  OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *  POSSIBILITY  OF SUCH DAMAGE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * pkcs11wrapper.h
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * 18.05.2001
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * declaration of all functions used by pkcs11wrapper.c
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
22964
59c522d83ed9 8034856: gcc warnings compiling src/solaris/native/sun/security/pkcs11
alanb
parents: 13678
diff changeset
    58
#ifndef _PKCS11WRAPPER_H
59c522d83ed9 8034856: gcc warnings compiling src/solaris/native/sun/security/pkcs11
alanb
parents: 13678
diff changeset
    59
#define _PKCS11WRAPPER_H 1
59c522d83ed9 8034856: gcc warnings compiling src/solaris/native/sun/security/pkcs11
alanb
parents: 13678
diff changeset
    60
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
/* disable asserts in product mode */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
#ifndef DEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
  #ifndef NDEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    #define NDEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
  #endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
/* extra PKCS#11 constants not in the standard include files */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
#define CKA_NETSCAPE_BASE                       (0x80000000 + 0x4E534350)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
#define CKA_NETSCAPE_TRUST_BASE                 (CKA_NETSCAPE_BASE + 0x2000)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
#define CKA_NETSCAPE_TRUST_SERVER_AUTH          (CKA_NETSCAPE_TRUST_BASE + 8)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
#define CKA_NETSCAPE_TRUST_CLIENT_AUTH          (CKA_NETSCAPE_TRUST_BASE + 9)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
#define CKA_NETSCAPE_TRUST_CODE_SIGNING (CKA_NETSCAPE_TRUST_BASE + 10)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
#define CKA_NETSCAPE_TRUST_EMAIL_PROTECTION     (CKA_NETSCAPE_TRUST_BASE + 11)
55332
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
    76
#define CKA_NETSCAPE_DB                         0xD5A0DB00
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
    77
#define CKM_NSS_TLS_PRF_GENERAL                 0x80000373
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 Define the PKCS#11 functions to include and exclude. Reduces the size
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 of the binary somewhat.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 This list needs to be kept in sync with the mapfile and PKCS11.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
#define P11_ENABLE_C_INITIALIZE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
#define P11_ENABLE_C_FINALIZE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
#define P11_ENABLE_C_GETINFO
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
#define P11_ENABLE_C_GETSLOTLIST
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
#define P11_ENABLE_C_GETSLOTINFO
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
#define P11_ENABLE_C_GETTOKENINFO
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
#define P11_ENABLE_C_GETMECHANISMLIST
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
#define P11_ENABLE_C_GETMECHANISMINFO
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
#undef  P11_ENABLE_C_INITTOKEN
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
#undef  P11_ENABLE_C_INITPIN
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
#undef  P11_ENABLE_C_SETPIN
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
#define P11_ENABLE_C_OPENSESSION
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
#define P11_ENABLE_C_CLOSESESSION
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
#undef  P11_ENABLE_C_CLOSEALLSESSIONS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
#define P11_ENABLE_C_GETSESSIONINFO
11507
bd978326a655 6414899: P11Digest should support cloning
valeriep
parents: 10798
diff changeset
   103
#define P11_ENABLE_C_GETOPERATIONSTATE
bd978326a655 6414899: P11Digest should support cloning
valeriep
parents: 10798
diff changeset
   104
#define P11_ENABLE_C_SETOPERATIONSTATE
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
#define P11_ENABLE_C_LOGIN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
#define P11_ENABLE_C_LOGOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
#define P11_ENABLE_C_CREATEOBJECT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
#define P11_ENABLE_C_COPYOBJECT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
#define P11_ENABLE_C_DESTROYOBJECT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
#undef  P11_ENABLE_C_GETOBJECTSIZE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
#define P11_ENABLE_C_GETATTRIBUTEVALUE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
#define P11_ENABLE_C_SETATTRIBUTEVALUE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
#define P11_ENABLE_C_FINDOBJECTSINIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
#define P11_ENABLE_C_FINDOBJECTS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
#define P11_ENABLE_C_FINDOBJECTSFINAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
#define P11_ENABLE_C_ENCRYPTINIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
#define P11_ENABLE_C_ENCRYPT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
#define P11_ENABLE_C_ENCRYPTUPDATE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
#define P11_ENABLE_C_ENCRYPTFINAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
#define P11_ENABLE_C_DECRYPTINIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
#define P11_ENABLE_C_DECRYPT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
#define P11_ENABLE_C_DECRYPTUPDATE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
#define P11_ENABLE_C_DECRYPTFINAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
#define P11_ENABLE_C_DIGESTINIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
#define P11_ENABLE_C_DIGEST
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
#define P11_ENABLE_C_DIGESTUPDATE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
#define P11_ENABLE_C_DIGESTKEY
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
#define P11_ENABLE_C_DIGESTFINAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
#define P11_ENABLE_C_SIGNINIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
#define P11_ENABLE_C_SIGN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
#define P11_ENABLE_C_SIGNUPDATE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
#define P11_ENABLE_C_SIGNFINAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
#define P11_ENABLE_C_SIGNRECOVERINIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
#define P11_ENABLE_C_SIGNRECOVER
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
#define P11_ENABLE_C_VERIFYINIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
#define P11_ENABLE_C_VERIFY
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
#define P11_ENABLE_C_VERIFYUPDATE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
#define P11_ENABLE_C_VERIFYFINAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
#define P11_ENABLE_C_VERIFYRECOVERINIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
#define P11_ENABLE_C_VERIFYRECOVER
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
#undef  P11_ENABLE_C_DIGESTENCRYPTUPDATE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
#undef  P11_ENABLE_C_DECRYPTDIGESTUPDATE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
#undef  P11_ENABLE_C_SIGNENCRYPTUPDATE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
#undef  P11_ENABLE_C_DECRYPTVERIFYUPDATE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
#define P11_ENABLE_C_GENERATEKEY
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
#define P11_ENABLE_C_GENERATEKEYPAIR
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
#define P11_ENABLE_C_WRAPKEY
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
#define P11_ENABLE_C_UNWRAPKEY
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
#define P11_ENABLE_C_DERIVEKEY
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
#define P11_ENABLE_C_SEEDRANDOM
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
#define P11_ENABLE_C_GENERATERANDOM
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
#undef  P11_ENABLE_C_GETFUNCTIONSTATUS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
#undef  P11_ENABLE_C_CANCELFUNCTION
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
#undef  P11_ENABLE_C_WAITFORSLOTEVENT
53257
5170dc2bcf64 6913047: Long term memory leak when using PKCS11 and JCE exceeds 32 bit process address space
mbalao
parents: 51800
diff changeset
   155
#define P11_ENABLE_GETNATIVEKEYINFO
5170dc2bcf64 6913047: Long term memory leak when using PKCS11 and JCE exceeds 32 bit process address space
mbalao
parents: 51800
diff changeset
   156
#define P11_ENABLE_CREATENATIVEKEY
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
55332
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   158
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
/* include the platform dependent part of the header */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
#include "p11_md.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
#include "pkcs11.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
#include <jni.h>
2180
9994f4f08a59 6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents: 2
diff changeset
   164
#include <jni_util.h>
39142
bf48a9f13cf2 8074580: sun/security/pkcs11/rsa/TestKeyPairGenerator.java fails due to PKCS11Exception: CKR_FUNCTION_FAILED
asmotrak
parents: 25859
diff changeset
   165
#include <stdarg.h>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
#define MAX_STACK_BUFFER_LEN (4 * 1024)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
#define MAX_HEAP_BUFFER_LEN (64 * 1024)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
#define MAX_DIGEST_LEN (64)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
#ifndef min
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
#define min(a, b)       (((a) < (b)) ? (a) : (b))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
#define ckBBoolToJBoolean(x) ((x == TRUE) ? JNI_TRUE : JNI_FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
#define jBooleanToCKBBool(x) ((x == JNI_TRUE) ? TRUE : FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
#define ckByteToJByte(x) ((jbyte) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
#define jByteToCKByte(x) ((CK_BYTE) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
#define ckLongToJLong(x) ((jlong) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
#define jLongToCKLong(x) ((CK_LONG) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
#define ckULongToJLong(x) ((jlong) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
#define jLongToCKULong(x) ((CK_ULONG) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
// For CK_UNAVAILABLE_INFORMATION, always return -1 to avoid 32/64 bit problems.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
#define ckULongSpecialToJLong(x) (((x) == CK_UNAVAILABLE_INFORMATION) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    ? (jlong)-1 : ((jlong) x))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
#define ckCharToJChar(x) ((jchar) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
#define jCharToCKChar(x) ((CK_CHAR) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
#define ckUTF8CharToJChar(x) ((jchar) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
#define jCharToCKUTF8Char(x) ((CK_UTF8CHAR) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
#define ckFlageToJLong(x) ((jlong) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
#define ckVoidPtrToJObject(x) ((jobject) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
#define jObjectToCKVoidPtr(x) ((CK_VOID_PTR) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
#define jIntToCKLong(x)         ((CK_LONG) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
#define jIntToCKULong(x)        ((CK_ULONG) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
#define ckLongToJInt(x)         ((jint) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
#define ckULongToJInt(x)        ((jint) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
#define ckULongToJSize(x)       ((jsize) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
#define unsignedIntToCKULong(x) ((CK_ULONG) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
#ifdef P11_DEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
#define TRACE0(s) { printf(s); fflush(stdout); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
#define TRACE1(s, p1) { printf(s, p1); fflush(stdout); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
#define TRACE2(s, p1, p2) { printf(s, p1, p2); fflush(stdout); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
#define TRACE3(s, p1, p2, p3) { printf(s, p1, p2, p3); fflush(stdout); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
#define TRACE0(s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
#define TRACE1(s, p1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
#define TRACE2(s, p1, p2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
#define TRACE3(s, p1, p2, p3)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
#define TRACE_INTEND
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
#define TRACE_UNINTEND
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
39142
bf48a9f13cf2 8074580: sun/security/pkcs11/rsa/TestKeyPairGenerator.java fails due to PKCS11Exception: CKR_FUNCTION_FAILED
asmotrak
parents: 25859
diff changeset
   224
/* debug output */
bf48a9f13cf2 8074580: sun/security/pkcs11/rsa/TestKeyPairGenerator.java fails due to PKCS11Exception: CKR_FUNCTION_FAILED
asmotrak
parents: 25859
diff changeset
   225
extern jboolean debug;
bf48a9f13cf2 8074580: sun/security/pkcs11/rsa/TestKeyPairGenerator.java fails due to PKCS11Exception: CKR_FUNCTION_FAILED
asmotrak
parents: 25859
diff changeset
   226
void printDebug(const char *format, ...);
bf48a9f13cf2 8074580: sun/security/pkcs11/rsa/TestKeyPairGenerator.java fails due to PKCS11Exception: CKR_FUNCTION_FAILED
asmotrak
parents: 25859
diff changeset
   227
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
#define CK_ASSERT_OK 0L
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
55332
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   230
#define CLASS_P11PSSSIGNATURE "sun/security/pkcs11/P11PSSSignature"
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   231
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
#define CLASS_INFO "sun/security/pkcs11/wrapper/CK_INFO"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
#define CLASS_VERSION "sun/security/pkcs11/wrapper/CK_VERSION"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
#define CLASS_SLOT_INFO "sun/security/pkcs11/wrapper/CK_SLOT_INFO"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
#define CLASS_TOKEN_INFO "sun/security/pkcs11/wrapper/CK_TOKEN_INFO"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
#define CLASS_MECHANISM "sun/security/pkcs11/wrapper/CK_MECHANISM"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
#define CLASS_MECHANISM_INFO "sun/security/pkcs11/wrapper/CK_MECHANISM_INFO"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
#define CLASS_SESSION_INFO "sun/security/pkcs11/wrapper/CK_SESSION_INFO"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
#define CLASS_ATTRIBUTE "sun/security/pkcs11/wrapper/CK_ATTRIBUTE"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
#define CLASS_DATE "sun/security/pkcs11/wrapper/CK_DATE"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
#define CLASS_PKCS11EXCEPTION "sun/security/pkcs11/wrapper/PKCS11Exception"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
#define CLASS_PKCS11RUNTIMEEXCEPTION "sun/security/pkcs11/wrapper/PKCS11RuntimeException"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
#define CLASS_FILE_NOT_FOUND_EXCEPTION "java/io/FileNotFoundException"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
#define CLASS_C_INITIALIZE_ARGS "sun/security/pkcs11/wrapper/CK_C_INITIALIZE_ARGS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
#define CLASS_CREATEMUTEX "sun/security/pkcs11/wrapper/CK_CREATEMUTEX"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
#define CLASS_DESTROYMUTEX "sun/security/pkcs11/wrapper/CK_DESTROYMUTEX"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
#define CLASS_LOCKMUTEX "sun/security/pkcs11/wrapper/CK_LOCKMUTEX"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
#define CLASS_UNLOCKMUTEX "sun/security/pkcs11/wrapper/CK_UNLOCKMUTEX"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
#define CLASS_NOTIFY "sun/security/pkcs11/wrapper/CK_NOTIFY"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
/* mechanism parameter classes */
55332
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   253
#define CLASS_AES_CTR_PARAMS "sun/security/pkcs11/wrapper/CK_AES_CTR_PARAMS"
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   254
#define CLASS_GCM_PARAMS "sun/security/pkcs11/wrapper/CK_GCM_PARAMS"
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   255
#define CLASS_CCM_PARAMS "sun/security/pkcs11/wrapper/CK_CCM_PARAMS"
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   256
#define CLASS_RSA_PKCS_PSS_PARAMS "sun/security/pkcs11/wrapper/CK_RSA_PKCS_PSS_PARAMS"
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   257
#define CLASS_RSA_PKCS_OAEP_PARAMS "sun/security/pkcs11/wrapper/CK_RSA_PKCS_OAEP_PARAMS"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
#define CLASS_MAC_GENERAL_PARAMS "sun/security/pkcs11/wrapper/CK_MAC_GENERAL_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
#define CLASS_PBE_PARAMS "sun/security/pkcs11/wrapper/CK_PBE_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
#define PBE_INIT_VECTOR_SIZE 8
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
#define CLASS_PKCS5_PBKD2_PARAMS "sun/security/pkcs11/wrapper/CK_PKCS5_PBKD2_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
#define CLASS_EXTRACT_PARAMS "sun/security/pkcs11/wrapper/CK_EXTRACT_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
#define CLASS_ECDH1_DERIVE_PARAMS "sun/security/pkcs11/wrapper/CK_ECDH1_DERIVE_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
#define CLASS_ECDH2_DERIVE_PARAMS "sun/security/pkcs11/wrapper/CK_ECDH2_DERIVE_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
#define CLASS_X9_42_DH1_DERIVE_PARAMS "sun/security/pkcs11/wrapper/CK_X9_42_DH1_DERIVE_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
#define CLASS_X9_42_DH2_DERIVE_PARAMS "sun/security/pkcs11/wrapper/CK_X9_42_DH2_DERIVE_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
#define CLASS_KEA_DERIVE_PARAMS "sun/security/pkcs11/wrapper/CK_KEA_DERIVE_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
#define CLASS_RC2_PARAMS "sun/security/pkcs11/wrapper/CK_RC2_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
#define CLASS_RC2_CBC_PARAMS "sun/security/pkcs11/wrapper/CK_RC2_CBC_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
#define CLASS_RC2_MAC_GENERAL_PARAMS "sun/security/pkcs11/wrapper/CK_RC2_MAC_GENERAL_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
#define CLASS_RC5_PARAMS "sun/security/pkcs11/wrapper/CK_RC5_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
#define CLASS_RC5_CBC_PARAMS "sun/security/pkcs11/wrapper/CK_RC5_CBC_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
#define CLASS_RC5_MAC_GENERAL_PARAMS "sun/security/pkcs11/wrapper/CK_RC5_MAC_GENERAL_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
#define CLASS_SKIPJACK_PRIVATE_WRAP_PARAMS "sun/security/pkcs11/wrapper/CK_SKIPJACK_PRIVATE_WRAP_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
#define CLASS_SKIPJACK_RELAYX_PARAMS "sun/security/pkcs11/wrapper/CK_SKIPJACK_RELAYX_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
#define CLASS_KEY_WRAP_SET_OAEP_PARAMS "sun/security/pkcs11/wrapper/CK_KEY_WRAP_SET_OAEP_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
#define CLASS_KEY_DERIVATION_STRING_DATA "sun/security/pkcs11/wrapper/CK_KEY_DERIVATION_STRING_DATA"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
#define CLASS_SSL3_RANDOM_DATA "sun/security/pkcs11/wrapper/CK_SSL3_RANDOM_DATA"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
// CLASS_SSL3_RANDOM_DATA is used by CLASS_SSL3_MASTER_KEY_DERIVE_PARAMS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
#define CLASS_SSL3_KEY_MAT_OUT "sun/security/pkcs11/wrapper/CK_SSL3_KEY_MAT_OUT"
51800
bccd9966f1ed 8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents: 47216
diff changeset
   287
// CLASS_SSL3_KEY_MAT_OUT is used by CLASS_SSL3_KEY_MAT_PARAMS and CK_TLS12_KEY_MAT_PARAMS
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
#define CLASS_SSL3_MASTER_KEY_DERIVE_PARAMS "sun/security/pkcs11/wrapper/CK_SSL3_MASTER_KEY_DERIVE_PARAMS"
51800
bccd9966f1ed 8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents: 47216
diff changeset
   289
#define CLASS_TLS12_MASTER_KEY_DERIVE_PARAMS "sun/security/pkcs11/wrapper/CK_TLS12_MASTER_KEY_DERIVE_PARAMS"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
#define CLASS_SSL3_KEY_MAT_PARAMS "sun/security/pkcs11/wrapper/CK_SSL3_KEY_MAT_PARAMS"
51800
bccd9966f1ed 8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents: 47216
diff changeset
   291
#define CLASS_TLS12_KEY_MAT_PARAMS "sun/security/pkcs11/wrapper/CK_TLS12_KEY_MAT_PARAMS"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
#define CLASS_TLS_PRF_PARAMS "sun/security/pkcs11/wrapper/CK_TLS_PRF_PARAMS"
51800
bccd9966f1ed 8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents: 47216
diff changeset
   293
#define CLASS_TLS_MAC_PARAMS "sun/security/pkcs11/wrapper/CK_TLS_MAC_PARAMS"
55332
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   294
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
/* function to convert a PKCS#11 return value other than CK_OK into a Java Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
 * or to throw a PKCS11RuntimeException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
jlong ckAssertReturnValueOK(JNIEnv *env, CK_RV returnValue);
10798
413b731e1818 7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents: 8542
diff changeset
   301
void throwOutOfMemoryError(JNIEnv *env, const char *message);
413b731e1818 7103549: Remove dependencies on libjava and libjvm from security libraries
chegar
parents: 8542
diff changeset
   302
void throwNullPointerException(JNIEnv *env, const char *message);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
void throwIOException(JNIEnv *env, const char *message);
2180
9994f4f08a59 6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents: 2
diff changeset
   304
void throwPKCS11RuntimeException(JNIEnv *env, const char *message);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
void throwDisconnectedRuntimeException(JNIEnv *env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
55332
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   307
/* functions to free CK structures and pointers
2180
9994f4f08a59 6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents: 2
diff changeset
   308
 */
9994f4f08a59 6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents: 2
diff changeset
   309
void freeCKAttributeArray(CK_ATTRIBUTE_PTR attrPtr, int len);
55332
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   310
void freeCKMechanismPtr(CK_MECHANISM_PTR mechPtr);
2180
9994f4f08a59 6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents: 2
diff changeset
   311
55332
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   312
/* functions to convert Java arrays to a CK-type array and the array length */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
void jBooleanArrayToCKBBoolArray(JNIEnv *env, const jbooleanArray jArray, CK_BBOOL **ckpArray, CK_ULONG_PTR ckLength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
void jByteArrayToCKByteArray(JNIEnv *env, const jbyteArray jArray, CK_BYTE_PTR *ckpArray, CK_ULONG_PTR ckLength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
void jLongArrayToCKULongArray(JNIEnv *env, const jlongArray jArray, CK_ULONG_PTR *ckpArray, CK_ULONG_PTR ckLength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
void jCharArrayToCKCharArray(JNIEnv *env, const jcharArray jArray, CK_CHAR_PTR *ckpArray, CK_ULONG_PTR ckLength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
void jCharArrayToCKUTF8CharArray(JNIEnv *env, const jcharArray jArray, CK_UTF8CHAR_PTR *ckpArray, CK_ULONG_PTR ckLength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
void jStringToCKUTF8CharArray(JNIEnv *env, const jstring jArray, CK_UTF8CHAR_PTR *ckpArray, CK_ULONG_PTR ckpLength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
void jAttributeArrayToCKAttributeArray(JNIEnv *env, jobjectArray jAArray, CK_ATTRIBUTE_PTR *ckpArray, CK_ULONG_PTR ckpLength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
/*void jObjectArrayToCKVoidPtrArray(JNIEnv *env, const jobjectArray jArray, CK_VOID_PTR_PTR ckpArray, CK_ULONG_PTR ckpLength); */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
55332
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   324
/* functions to convert a CK-type array and the array length to a Java array */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
3321
fed33393bc52 6823905: crash in sun.security.pkcs11.wrapper.PKCS11.C_Sign during stress-test
valeriep
parents: 2180
diff changeset
   326
jbyteArray ckByteArrayToJByteArray(JNIEnv *env, const CK_BYTE_PTR ckpArray, CK_ULONG ckLength);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
jlongArray ckULongArrayToJLongArray(JNIEnv *env, const CK_ULONG_PTR ckpArray, CK_ULONG ckLength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
jcharArray ckCharArrayToJCharArray(JNIEnv *env, const CK_CHAR_PTR ckpArray, CK_ULONG length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
jcharArray ckUTF8CharArrayToJCharArray(JNIEnv *env, const CK_UTF8CHAR_PTR ckpArray, CK_ULONG ckLength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
55332
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   332
/* functions to convert a CK-type structure or a pointer to a CK-value to a Java object */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
jobject ckBBoolPtrToJBooleanObject(JNIEnv *env, const CK_BBOOL* ckpValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
jobject ckULongPtrToJLongObject(JNIEnv *env, const CK_ULONG_PTR ckpValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
jobject ckDatePtrToJDateObject(JNIEnv *env, const CK_DATE *ckpValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
jobject ckVersionPtrToJVersion(JNIEnv *env, const CK_VERSION_PTR ckpVersion);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
jobject ckSessionInfoPtrToJSessionInfo(JNIEnv *env, const CK_SESSION_INFO_PTR ckpSessionInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
jobject ckAttributePtrToJAttribute(JNIEnv *env, const CK_ATTRIBUTE_PTR ckpAttribute);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
55332
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   342
/* function to convert the CK-value used by the CK_ATTRIBUTE structure to a Java object */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
jobject ckAttributeValueToJObject(JNIEnv *env, const CK_ATTRIBUTE_PTR ckpAttribute);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
55332
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   347
/* functions to convert a Java object to a CK-type structure or a pointer to a CK-value */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
CK_BBOOL* jBooleanObjectToCKBBoolPtr(JNIEnv *env, jobject jObject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
CK_BYTE_PTR jByteObjectToCKBytePtr(JNIEnv *env, jobject jObject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
CK_ULONG* jIntegerObjectToCKULongPtr(JNIEnv *env, jobject jObject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
CK_ULONG* jLongObjectToCKULongPtr(JNIEnv *env, jobject jObject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
CK_CHAR_PTR jCharObjectToCKCharPtr(JNIEnv *env, jobject jObject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
CK_VERSION_PTR jVersionToCKVersionPtr(JNIEnv *env, jobject jVersion);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
CK_DATE * jDateObjectPtrToCKDatePtr(JNIEnv *env, jobject jDate);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
CK_ATTRIBUTE jAttributeToCKAttribute(JNIEnv *env, jobject jAttribute);
55332
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   357
CK_MECHANISM_PTR jMechanismToCKMechanismPtr(JNIEnv *env, jobject jMechanism);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
55332
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   360
/* functions to convert Java objects used by the Mechanism and Attribute class to a CK-type structure */
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   361
CK_VOID_PTR jObjectToPrimitiveCKObjectPtr(JNIEnv *env, jobject jObject, CK_ULONG *ckpLength);
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   362
CK_VOID_PTR jMechParamToCKMechParamPtr(JNIEnv *env, jobject jParam, CK_MECHANISM_TYPE, CK_ULONG
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   363
*ckpLength);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
/* functions to convert a specific Java mechanism parameter object to a CK-mechanism parameter structure */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
55332
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   368
void jRsaPkcsOaepParamToCKRsaPkcsOaepParam(JNIEnv *env, jobject jParam, CK_RSA_PKCS_OAEP_PARAMS_PTR ckParamPtr);
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   369
void jPbeParamToCKPbeParam(JNIEnv *env, jobject jParam, CK_PBE_PARAMS_PTR ckParamPtr);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
void copyBackPBEInitializationVector(JNIEnv *env, CK_MECHANISM *ckMechanism, jobject jMechanism);
55332
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   371
void jPkcs5Pbkd2ParamToCKPkcs5Pbkd2Param(JNIEnv *env, jobject jParam, CK_PKCS5_PBKD2_PARAMS_PTR ckParamPtr);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
void copyBackSetUnwrappedKey(JNIEnv *env, CK_MECHANISM *ckMechanism, jobject jMechanism);
55332
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   373
void jSsl3MasterKeyDeriveParamToCKSsl3MasterKeyDeriveParam(JNIEnv *env, jobject jParam, CK_SSL3_MASTER_KEY_DERIVE_PARAMS_PTR ckParamPtr);
51800
bccd9966f1ed 8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents: 47216
diff changeset
   374
void ssl3CopyBackClientVersion(JNIEnv *env, CK_MECHANISM *ckMechanism, jobject jMechanism);
bccd9966f1ed 8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents: 47216
diff changeset
   375
void tls12CopyBackClientVersion(JNIEnv *env, CK_MECHANISM *ckMechanism, jobject jMechanism);
55332
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   376
void jSsl3KeyMatParamToCKSsl3KeyMatParam(JNIEnv *env, jobject jParam, CK_SSL3_KEY_MAT_PARAMS_PTR ckParamPtr);
51800
bccd9966f1ed 8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents: 47216
diff changeset
   377
void ssl3CopyBackKeyMatParams(JNIEnv *env, CK_MECHANISM *ckMechanism, jobject jMechanism);
bccd9966f1ed 8029661: Support TLS v1.2 algorithm in SunPKCS11 provider
mbalao
parents: 47216
diff changeset
   378
void tls12CopyBackKeyMatParams(JNIEnv *env, CK_MECHANISM *ckMechanism, jobject jMechanism);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
CK_KEY_DERIVATION_STRING_DATA jKeyDerivationStringDataToCKKeyDerivationStringData(JNIEnv *env, jobject jParam);
55332
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   380
void jRsaPkcsPssParamToCKRsaPkcsPssParam(JNIEnv *env, jobject jParam, CK_RSA_PKCS_PSS_PARAMS_PTR ckParamPtr);
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   381
void jEcdh1DeriveParamToCKEcdh1DeriveParam(JNIEnv *env, jobject jParam, CK_ECDH1_DERIVE_PARAMS_PTR ckParamPtr);
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   382
void jEcdh2DeriveParamToCKEcdh2DeriveParam(JNIEnv *env, jobject jParam,
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   383
CK_ECDH2_DERIVE_PARAMS_PTR ckParamPtr);
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   384
void jX942Dh1DeriveParamToCKX942Dh1DeriveParam(JNIEnv *env, jobject jParam, CK_X9_42_DH1_DERIVE_PARAMS_PTR ckParamPtr);
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   385
void jX942Dh2DeriveParamToCKX942Dh2DeriveParam(JNIEnv *env, jobject jParam, CK_X9_42_DH2_DERIVE_PARAMS_PTR ckParamPtr);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
/* functions to convert the InitArgs object for calling the right Java mutex functions */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
CK_C_INITIALIZE_ARGS_PTR makeCKInitArgsAdapter(JNIEnv *env, jobject pInitArgs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
#ifndef NO_CALLBACKS /* if the library should not make callbacks; e.g. no javai.lib or jvm.lib available */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
CK_RV callJCreateMutex(CK_VOID_PTR_PTR ppMutex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
CK_RV callJDestroyMutex(CK_VOID_PTR pMutex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
CK_RV callJLockMutex(CK_VOID_PTR pMutex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
CK_RV callJUnlockMutex(CK_VOID_PTR pMutex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
#endif /* NO_CALLBACKS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
void putModuleEntry(JNIEnv *env, jobject pkcs11Implementation, ModuleData *moduleData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
ModuleData * removeModuleEntry(JNIEnv *env, jobject pkcs11Implementation);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
CK_FUNCTION_LIST_PTR getFunctionList(JNIEnv *env, jobject pkcs11Implementation);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
/* A structure to encapsulate the required data for a Notify callback */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
struct NotifyEncapsulation {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    /* The object that implements the CK_NOTIFY interface and which should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * notified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    jobject jNotifyObject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    /* The data object to pass back to the Notify object upon callback. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    jobject jApplicationData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
typedef struct NotifyEncapsulation NotifyEncapsulation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
/* The function for handling notify callbacks. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
CK_RV notifyCallback(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    CK_SESSION_HANDLE hSession,     /* the session's handle */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    CK_NOTIFICATION   event,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    CK_VOID_PTR       pApplication  /* passed to C_OpenSession */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
/* A node of the list of notify callbacks. To be able to free the resources after use. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
struct NotifyListNode {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    /* The handle of the session this notify object is attached to*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    CK_SESSION_HANDLE hSession;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    /* Reference to the Notify encapsulation object that was passed to C_OpenSession. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    NotifyEncapsulation *notifyEncapsulation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    /* Pointer to the next node in the list. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
    struct NotifyListNode *next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
typedef struct NotifyListNode NotifyListNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
void putNotifyEntry(JNIEnv *env, CK_SESSION_HANDLE hSession, NotifyEncapsulation *notifyEncapsulation);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
NotifyEncapsulation * removeNotifyEntry(JNIEnv *env, CK_SESSION_HANDLE hSession);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
NotifyEncapsulation * removeFirstNotifyEntry(JNIEnv *env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
jobject createLockObject(JNIEnv *env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
void destroyLockObject(JNIEnv *env, jobject jLockObject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
extern jfieldID pNativeDataID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
extern jfieldID mech_mechanismID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
extern jfieldID mech_pParameterID;
55332
f492567244ab 8080462: Update SunPKCS11 provider with PKCS11 v2.40 support
valeriep
parents: 53257
diff changeset
   449
extern jfieldID mech_pHandleID;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
extern jclass jByteArrayClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
extern jclass jLongClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
#ifndef NO_CALLBACKS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
extern NotifyListNode *notifyListHead;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
extern jobject notifyListLock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
extern jobject jInitArgsObject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
extern CK_C_INITIALIZE_ARGS_PTR ckpGlobalInitArgs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
#endif /* NO_CALLBACKS */
2180
9994f4f08a59 6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents: 2
diff changeset
   461
9994f4f08a59 6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents: 2
diff changeset
   462
#ifdef P11_MEMORYDEBUG
9994f4f08a59 6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents: 2
diff changeset
   463
#include <stdlib.h>
9994f4f08a59 6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents: 2
diff changeset
   464
9994f4f08a59 6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents: 2
diff changeset
   465
/* Simple malloc/free dumper */
9994f4f08a59 6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents: 2
diff changeset
   466
void *p11malloc(size_t c, char *file, int line);
9994f4f08a59 6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents: 2
diff changeset
   467
void p11free(void *p, char *file, int line);
9994f4f08a59 6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents: 2
diff changeset
   468
13678
5c8001201f98 7197771: Adjust jdk sources to avoid use of implementation defined value of __FILE__
ohair
parents: 11507
diff changeset
   469
/* Use THIS_FILE when it is available. */
5c8001201f98 7197771: Adjust jdk sources to avoid use of implementation defined value of __FILE__
ohair
parents: 11507
diff changeset
   470
#ifndef THIS_FILE
5c8001201f98 7197771: Adjust jdk sources to avoid use of implementation defined value of __FILE__
ohair
parents: 11507
diff changeset
   471
    #define THIS_FILE __FILE__
5c8001201f98 7197771: Adjust jdk sources to avoid use of implementation defined value of __FILE__
ohair
parents: 11507
diff changeset
   472
#endif
5c8001201f98 7197771: Adjust jdk sources to avoid use of implementation defined value of __FILE__
ohair
parents: 11507
diff changeset
   473
5c8001201f98 7197771: Adjust jdk sources to avoid use of implementation defined value of __FILE__
ohair
parents: 11507
diff changeset
   474
#define malloc(c)       (p11malloc((c), THIS_FILE, __LINE__))
5c8001201f98 7197771: Adjust jdk sources to avoid use of implementation defined value of __FILE__
ohair
parents: 11507
diff changeset
   475
#define free(c)         (p11free((c), THIS_FILE, __LINE__))
2180
9994f4f08a59 6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents: 2
diff changeset
   476
9994f4f08a59 6812738: SSL stress test with GF leads to 32 bit max process size in less than 5 minutes with PCKS11 provider
valeriep
parents: 2
diff changeset
   477
#endif
22964
59c522d83ed9 8034856: gcc warnings compiling src/solaris/native/sun/security/pkcs11
alanb
parents: 13678
diff changeset
   478
59c522d83ed9 8034856: gcc warnings compiling src/solaris/native/sun/security/pkcs11
alanb
parents: 13678
diff changeset
   479
#endif /* _PKCS11WRAPPER_H */