jdk/src/share/native/sun/security/pkcs11/wrapper/pkcs11wrapper.h
author valeriep
Tue, 22 Feb 2011 12:01:35 -0800
changeset 8542 62c7b10ce177
parent 5506 202f599c92aa
child 10798 413b731e1818
permissions -rw-r--r--
6604496: Support for CKM_AES_CTR (counter mode) Summary: Enhanced SunPKCS11 provider to support AES/CTR/NoPadding transformation. Reviewed-by: vinnie
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
8542
62c7b10ce177 6604496: Support for CKM_AES_CTR (counter mode)
valeriep
parents: 5506
diff changeset
     2
 * Copyright (c) 2003, 2011, 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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
/* disable asserts in product mode */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
#ifndef DEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
  #ifndef NDEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    #define NDEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
  #endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
/* extra PKCS#11 constants not in the standard include files */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
#define CKA_NETSCAPE_BASE                       (0x80000000 + 0x4E534350)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
#define CKA_NETSCAPE_TRUST_BASE                 (CKA_NETSCAPE_BASE + 0x2000)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
#define CKA_NETSCAPE_TRUST_SERVER_AUTH          (CKA_NETSCAPE_TRUST_BASE + 8)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
#define CKA_NETSCAPE_TRUST_CLIENT_AUTH          (CKA_NETSCAPE_TRUST_BASE + 9)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
#define CKA_NETSCAPE_TRUST_CODE_SIGNING (CKA_NETSCAPE_TRUST_BASE + 10)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
#define CKA_NETSCAPE_TRUST_EMAIL_PROTECTION     (CKA_NETSCAPE_TRUST_BASE + 11)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 Define the PKCS#11 functions to include and exclude. Reduces the size
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 of the binary somewhat.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 This list needs to be kept in sync with the mapfile and PKCS11.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
#define P11_ENABLE_C_INITIALIZE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
#define P11_ENABLE_C_FINALIZE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
#define P11_ENABLE_C_GETINFO
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
#define P11_ENABLE_C_GETSLOTLIST
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
#define P11_ENABLE_C_GETSLOTINFO
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
#define P11_ENABLE_C_GETTOKENINFO
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
#define P11_ENABLE_C_GETMECHANISMLIST
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
#define P11_ENABLE_C_GETMECHANISMINFO
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
#undef  P11_ENABLE_C_INITTOKEN
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
#undef  P11_ENABLE_C_INITPIN
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
#undef  P11_ENABLE_C_SETPIN
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
#define P11_ENABLE_C_OPENSESSION
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
#define P11_ENABLE_C_CLOSESESSION
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
#undef  P11_ENABLE_C_CLOSEALLSESSIONS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
#define P11_ENABLE_C_GETSESSIONINFO
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
#undef  P11_ENABLE_C_GETOPERATIONSTATE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
#undef  P11_ENABLE_C_SETOPERATIONSTATE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
#define P11_ENABLE_C_LOGIN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
#define P11_ENABLE_C_LOGOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
#define P11_ENABLE_C_CREATEOBJECT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
#define P11_ENABLE_C_COPYOBJECT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
#define P11_ENABLE_C_DESTROYOBJECT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
#undef  P11_ENABLE_C_GETOBJECTSIZE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
#define P11_ENABLE_C_GETATTRIBUTEVALUE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
#define P11_ENABLE_C_SETATTRIBUTEVALUE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
#define P11_ENABLE_C_FINDOBJECTSINIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
#define P11_ENABLE_C_FINDOBJECTS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
#define P11_ENABLE_C_FINDOBJECTSFINAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
#define P11_ENABLE_C_ENCRYPTINIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
#define P11_ENABLE_C_ENCRYPT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
#define P11_ENABLE_C_ENCRYPTUPDATE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
#define P11_ENABLE_C_ENCRYPTFINAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
#define P11_ENABLE_C_DECRYPTINIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
#define P11_ENABLE_C_DECRYPT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
#define P11_ENABLE_C_DECRYPTUPDATE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
#define P11_ENABLE_C_DECRYPTFINAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
#define P11_ENABLE_C_DIGESTINIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
#define P11_ENABLE_C_DIGEST
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
#define P11_ENABLE_C_DIGESTUPDATE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
#define P11_ENABLE_C_DIGESTKEY
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
#define P11_ENABLE_C_DIGESTFINAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
#define P11_ENABLE_C_SIGNINIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
#define P11_ENABLE_C_SIGN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
#define P11_ENABLE_C_SIGNUPDATE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
#define P11_ENABLE_C_SIGNFINAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
#define P11_ENABLE_C_SIGNRECOVERINIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
#define P11_ENABLE_C_SIGNRECOVER
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
#define P11_ENABLE_C_VERIFYINIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
#define P11_ENABLE_C_VERIFY
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
#define P11_ENABLE_C_VERIFYUPDATE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
#define P11_ENABLE_C_VERIFYFINAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
#define P11_ENABLE_C_VERIFYRECOVERINIT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
#define P11_ENABLE_C_VERIFYRECOVER
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
#undef  P11_ENABLE_C_DIGESTENCRYPTUPDATE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
#undef  P11_ENABLE_C_DECRYPTDIGESTUPDATE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
#undef  P11_ENABLE_C_SIGNENCRYPTUPDATE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
#undef  P11_ENABLE_C_DECRYPTVERIFYUPDATE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
#define P11_ENABLE_C_GENERATEKEY
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
#define P11_ENABLE_C_GENERATEKEYPAIR
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
#define P11_ENABLE_C_WRAPKEY
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
#define P11_ENABLE_C_UNWRAPKEY
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
#define P11_ENABLE_C_DERIVEKEY
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
#define P11_ENABLE_C_SEEDRANDOM
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
#define P11_ENABLE_C_GENERATERANDOM
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
#undef  P11_ENABLE_C_GETFUNCTIONSTATUS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
#undef  P11_ENABLE_C_CANCELFUNCTION
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
#undef  P11_ENABLE_C_WAITFORSLOTEVENT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
/* include the platform dependent part of the header */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
#include "p11_md.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
#include "pkcs11.h"
8542
62c7b10ce177 6604496: Support for CKM_AES_CTR (counter mode)
valeriep
parents: 5506
diff changeset
   156
#include "pkcs-11v2-20a3.h"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
#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
   158
#include <jni_util.h>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
#define MAX_STACK_BUFFER_LEN (4 * 1024)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
#define MAX_HEAP_BUFFER_LEN (64 * 1024)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
#define MAX_DIGEST_LEN (64)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
#ifndef min
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
#define min(a, b)       (((a) < (b)) ? (a) : (b))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
#define ckBBoolToJBoolean(x) ((x == TRUE) ? JNI_TRUE : JNI_FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
#define jBooleanToCKBBool(x) ((x == JNI_TRUE) ? TRUE : FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
#define ckByteToJByte(x) ((jbyte) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
#define jByteToCKByte(x) ((CK_BYTE) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
#define ckLongToJLong(x) ((jlong) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
#define jLongToCKLong(x) ((CK_LONG) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
#define ckULongToJLong(x) ((jlong) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
#define jLongToCKULong(x) ((CK_ULONG) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
// For CK_UNAVAILABLE_INFORMATION, always return -1 to avoid 32/64 bit problems.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
#define ckULongSpecialToJLong(x) (((x) == CK_UNAVAILABLE_INFORMATION) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    ? (jlong)-1 : ((jlong) x))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
#define ckCharToJChar(x) ((jchar) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
#define jCharToCKChar(x) ((CK_CHAR) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
#define ckUTF8CharToJChar(x) ((jchar) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
#define jCharToCKUTF8Char(x) ((CK_UTF8CHAR) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
#define ckFlageToJLong(x) ((jlong) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
#define ckVoidPtrToJObject(x) ((jobject) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
#define jObjectToCKVoidPtr(x) ((CK_VOID_PTR) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
#define jIntToCKLong(x)         ((CK_LONG) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
#define jIntToCKULong(x)        ((CK_ULONG) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
#define ckLongToJInt(x)         ((jint) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
#define ckULongToJInt(x)        ((jint) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
#define ckULongToJSize(x)       ((jsize) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
#define unsignedIntToCKULong(x) ((CK_ULONG) x)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
#ifdef P11_DEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
#define TRACE0(s) { printf(s); fflush(stdout); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
#define TRACE1(s, p1) { printf(s, p1); fflush(stdout); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
#define TRACE2(s, p1, p2) { printf(s, p1, p2); fflush(stdout); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
#define TRACE3(s, p1, p2, p3) { printf(s, p1, p2, p3); fflush(stdout); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
#define TRACE0(s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
#define TRACE1(s, p1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
#define TRACE2(s, p1, p2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
#define TRACE3(s, p1, p2, p3)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
#define TRACE_INTEND
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
#define TRACE_UNINTEND
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
#define CK_ASSERT_OK 0L
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
#define CLASS_INFO "sun/security/pkcs11/wrapper/CK_INFO"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
#define CLASS_VERSION "sun/security/pkcs11/wrapper/CK_VERSION"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
#define CLASS_SLOT_INFO "sun/security/pkcs11/wrapper/CK_SLOT_INFO"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
#define CLASS_TOKEN_INFO "sun/security/pkcs11/wrapper/CK_TOKEN_INFO"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
#define CLASS_MECHANISM "sun/security/pkcs11/wrapper/CK_MECHANISM"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
#define CLASS_MECHANISM_INFO "sun/security/pkcs11/wrapper/CK_MECHANISM_INFO"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
#define CLASS_SESSION_INFO "sun/security/pkcs11/wrapper/CK_SESSION_INFO"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
#define CLASS_ATTRIBUTE "sun/security/pkcs11/wrapper/CK_ATTRIBUTE"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
#define CLASS_DATE "sun/security/pkcs11/wrapper/CK_DATE"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
#define CLASS_PKCS11EXCEPTION "sun/security/pkcs11/wrapper/PKCS11Exception"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
#define CLASS_PKCS11RUNTIMEEXCEPTION "sun/security/pkcs11/wrapper/PKCS11RuntimeException"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
#define CLASS_FILE_NOT_FOUND_EXCEPTION "java/io/FileNotFoundException"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
#define CLASS_IO_EXCEPTION "java/io/IOException"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
#define CLASS_C_INITIALIZE_ARGS "sun/security/pkcs11/wrapper/CK_C_INITIALIZE_ARGS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
#define CLASS_CREATEMUTEX "sun/security/pkcs11/wrapper/CK_CREATEMUTEX"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
#define CLASS_DESTROYMUTEX "sun/security/pkcs11/wrapper/CK_DESTROYMUTEX"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
#define CLASS_LOCKMUTEX "sun/security/pkcs11/wrapper/CK_LOCKMUTEX"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
#define CLASS_UNLOCKMUTEX "sun/security/pkcs11/wrapper/CK_UNLOCKMUTEX"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
#define CLASS_NOTIFY "sun/security/pkcs11/wrapper/CK_NOTIFY"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
/* mechanism parameter classes */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
#define CLASS_RSA_PKCS_OAEP_PARAMS "sun/security/pkcs11/wrapper/CK_RSA_PKCS_OAEP_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
#define CLASS_MAC_GENERAL_PARAMS "sun/security/pkcs11/wrapper/CK_MAC_GENERAL_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
#define CLASS_PBE_PARAMS "sun/security/pkcs11/wrapper/CK_PBE_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
#define PBE_INIT_VECTOR_SIZE 8
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
#define CLASS_PKCS5_PBKD2_PARAMS "sun/security/pkcs11/wrapper/CK_PKCS5_PBKD2_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
#define CLASS_EXTRACT_PARAMS "sun/security/pkcs11/wrapper/CK_EXTRACT_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
#define CLASS_RSA_PKCS_PSS_PARAMS "sun/security/pkcs11/wrapper/CK_RSA_PKCS_PSS_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
#define CLASS_ECDH1_DERIVE_PARAMS "sun/security/pkcs11/wrapper/CK_ECDH1_DERIVE_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
#define CLASS_ECDH2_DERIVE_PARAMS "sun/security/pkcs11/wrapper/CK_ECDH2_DERIVE_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
#define CLASS_X9_42_DH1_DERIVE_PARAMS "sun/security/pkcs11/wrapper/CK_X9_42_DH1_DERIVE_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
#define CLASS_X9_42_DH2_DERIVE_PARAMS "sun/security/pkcs11/wrapper/CK_X9_42_DH2_DERIVE_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
#define CLASS_KEA_DERIVE_PARAMS "sun/security/pkcs11/wrapper/CK_KEA_DERIVE_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
#define CLASS_RC2_PARAMS "sun/security/pkcs11/wrapper/CK_RC2_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
#define CLASS_RC2_CBC_PARAMS "sun/security/pkcs11/wrapper/CK_RC2_CBC_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
#define CLASS_RC2_MAC_GENERAL_PARAMS "sun/security/pkcs11/wrapper/CK_RC2_MAC_GENERAL_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
#define CLASS_RC5_PARAMS "sun/security/pkcs11/wrapper/CK_RC5_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
#define CLASS_RC5_CBC_PARAMS "sun/security/pkcs11/wrapper/CK_RC5_CBC_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
#define CLASS_RC5_MAC_GENERAL_PARAMS "sun/security/pkcs11/wrapper/CK_RC5_MAC_GENERAL_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
#define CLASS_SKIPJACK_PRIVATE_WRAP_PARAMS "sun/security/pkcs11/wrapper/CK_SKIPJACK_PRIVATE_WRAP_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
#define CLASS_SKIPJACK_RELAYX_PARAMS "sun/security/pkcs11/wrapper/CK_SKIPJACK_RELAYX_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
#define CLASS_KEY_WRAP_SET_OAEP_PARAMS "sun/security/pkcs11/wrapper/CK_KEY_WRAP_SET_OAEP_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
#define CLASS_KEY_DERIVATION_STRING_DATA "sun/security/pkcs11/wrapper/CK_KEY_DERIVATION_STRING_DATA"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
#define CLASS_SSL3_RANDOM_DATA "sun/security/pkcs11/wrapper/CK_SSL3_RANDOM_DATA"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
// CLASS_SSL3_RANDOM_DATA is used by CLASS_SSL3_MASTER_KEY_DERIVE_PARAMS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
#define CLASS_SSL3_KEY_MAT_OUT "sun/security/pkcs11/wrapper/CK_SSL3_KEY_MAT_OUT"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
// CLASS_SSL3_KEY_MAT_OUT is used by CLASS_SSL3_KEY_MAT_PARAMS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
#define CLASS_SSL3_MASTER_KEY_DERIVE_PARAMS "sun/security/pkcs11/wrapper/CK_SSL3_MASTER_KEY_DERIVE_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
#define CLASS_SSL3_KEY_MAT_PARAMS "sun/security/pkcs11/wrapper/CK_SSL3_KEY_MAT_PARAMS"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
#define CLASS_TLS_PRF_PARAMS "sun/security/pkcs11/wrapper/CK_TLS_PRF_PARAMS"
8542
62c7b10ce177 6604496: Support for CKM_AES_CTR (counter mode)
valeriep
parents: 5506
diff changeset
   276
#define CLASS_AES_CTR_PARAMS "sun/security/pkcs11/wrapper/CK_AES_CTR_PARAMS"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
/* function to convert a PKCS#11 return value other than CK_OK into a Java Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
 * or to throw a PKCS11RuntimeException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
jlong ckAssertReturnValueOK(JNIEnv *env, CK_RV returnValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
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
   284
void throwPKCS11RuntimeException(JNIEnv *env, const char *message);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
void throwDisconnectedRuntimeException(JNIEnv *env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
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
   287
/* function to free CK_ATTRIBUTE array
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
   288
 */
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
   289
void freeCKAttributeArray(CK_ATTRIBUTE_PTR attrPtr, int len);
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
   290
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
/* funktions to convert Java arrays to a CK-type array and the array length */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
void jBooleanArrayToCKBBoolArray(JNIEnv *env, const jbooleanArray jArray, CK_BBOOL **ckpArray, CK_ULONG_PTR ckLength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
void jByteArrayToCKByteArray(JNIEnv *env, const jbyteArray jArray, CK_BYTE_PTR *ckpArray, CK_ULONG_PTR ckLength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
void jLongArrayToCKULongArray(JNIEnv *env, const jlongArray jArray, CK_ULONG_PTR *ckpArray, CK_ULONG_PTR ckLength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
void jCharArrayToCKCharArray(JNIEnv *env, const jcharArray jArray, CK_CHAR_PTR *ckpArray, CK_ULONG_PTR ckLength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
void jCharArrayToCKUTF8CharArray(JNIEnv *env, const jcharArray jArray, CK_UTF8CHAR_PTR *ckpArray, CK_ULONG_PTR ckLength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
void jStringToCKUTF8CharArray(JNIEnv *env, const jstring jArray, CK_UTF8CHAR_PTR *ckpArray, CK_ULONG_PTR ckpLength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
void jAttributeArrayToCKAttributeArray(JNIEnv *env, jobjectArray jAArray, CK_ATTRIBUTE_PTR *ckpArray, CK_ULONG_PTR ckpLength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
/*void jObjectArrayToCKVoidPtrArray(JNIEnv *env, const jobjectArray jArray, CK_VOID_PTR_PTR ckpArray, CK_ULONG_PTR ckpLength); */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
/* funktions to convert a CK-type array and the array length to a Java array */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
3321
fed33393bc52 6823905: crash in sun.security.pkcs11.wrapper.PKCS11.C_Sign during stress-test
valeriep
parents: 2180
diff changeset
   305
jbyteArray ckByteArrayToJByteArray(JNIEnv *env, const CK_BYTE_PTR ckpArray, CK_ULONG ckLength);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
jlongArray ckULongArrayToJLongArray(JNIEnv *env, const CK_ULONG_PTR ckpArray, CK_ULONG ckLength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
jcharArray ckCharArrayToJCharArray(JNIEnv *env, const CK_CHAR_PTR ckpArray, CK_ULONG length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
jcharArray ckUTF8CharArrayToJCharArray(JNIEnv *env, const CK_UTF8CHAR_PTR ckpArray, CK_ULONG ckLength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
/* funktions to convert a CK-type structure or a pointer to a CK-value to a Java object */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
jobject ckBBoolPtrToJBooleanObject(JNIEnv *env, const CK_BBOOL* ckpValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
jobject ckULongPtrToJLongObject(JNIEnv *env, const CK_ULONG_PTR ckpValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
jobject ckDatePtrToJDateObject(JNIEnv *env, const CK_DATE *ckpValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
jobject ckVersionPtrToJVersion(JNIEnv *env, const CK_VERSION_PTR ckpVersion);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
jobject ckSessionInfoPtrToJSessionInfo(JNIEnv *env, const CK_SESSION_INFO_PTR ckpSessionInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
jobject ckAttributePtrToJAttribute(JNIEnv *env, const CK_ATTRIBUTE_PTR ckpAttribute);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
/* funktion to convert the CK-value used by the CK_ATTRIBUTE structure to a Java object */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
jobject ckAttributeValueToJObject(JNIEnv *env, const CK_ATTRIBUTE_PTR ckpAttribute);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
/* funktions to convert a Java object to a CK-type structure or a pointer to a CK-value */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
CK_BBOOL* jBooleanObjectToCKBBoolPtr(JNIEnv *env, jobject jObject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
CK_BYTE_PTR jByteObjectToCKBytePtr(JNIEnv *env, jobject jObject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
CK_ULONG* jIntegerObjectToCKULongPtr(JNIEnv *env, jobject jObject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
CK_ULONG* jLongObjectToCKULongPtr(JNIEnv *env, jobject jObject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
CK_CHAR_PTR jCharObjectToCKCharPtr(JNIEnv *env, jobject jObject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
CK_VERSION_PTR jVersionToCKVersionPtr(JNIEnv *env, jobject jVersion);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
CK_DATE * jDateObjectPtrToCKDatePtr(JNIEnv *env, jobject jDate);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
CK_ATTRIBUTE jAttributeToCKAttribute(JNIEnv *env, jobject jAttribute);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
/*CK_MECHANISM jMechanismToCKMechanism(JNIEnv *env, jobject jMechanism);*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
void jMechanismToCKMechanism(JNIEnv *env, jobject jMechanism, CK_MECHANISM_PTR ckMechanismPtr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
/* funktions to convert Java objects used by the Mechanism and Attribute class to a CK-type structure */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
void jObjectToPrimitiveCKObjectPtrPtr(JNIEnv *env, jobject jObject, CK_VOID_PTR *ckpObjectPtr, CK_ULONG *pLength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
void jMechanismParameterToCKMechanismParameter(JNIEnv *env, jobject jParam, CK_VOID_PTR *ckpParamPtr, CK_ULONG *ckpLength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
/* functions to convert a specific Java mechanism parameter object to a CK-mechanism parameter structure */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
CK_RSA_PKCS_OAEP_PARAMS jRsaPkcsOaepParamToCKRsaPkcsOaepParam(JNIEnv *env, jobject jParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
CK_KEA_DERIVE_PARAMS jKeaDeriveParamToCKKeaDeriveParam(JNIEnv *env, jobject jParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
CK_RC2_CBC_PARAMS jRc2CbcParamToCKRc2CbcParam(JNIEnv *env, jobject jParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
CK_RC2_MAC_GENERAL_PARAMS jRc2MacGeneralParamToCKRc2MacGeneralParam(JNIEnv *env, jobject jParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
CK_RC5_PARAMS jRc5ParamToCKRc5Param(JNIEnv *env, jobject jParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
CK_RC5_CBC_PARAMS jRc5CbcParamToCKRc5CbcParam(JNIEnv *env, jobject jParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
CK_RC5_MAC_GENERAL_PARAMS jRc5MacGeneralParamToCKRc5MacGeneralParam(JNIEnv *env, jobject jParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
CK_SKIPJACK_PRIVATE_WRAP_PARAMS jSkipjackPrivateWrapParamToCKSkipjackPrivateWrapParam(JNIEnv *env, jobject jParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
CK_SKIPJACK_RELAYX_PARAMS jSkipjackRelayxParamToCKSkipjackRelayxParam(JNIEnv *env, jobject jParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
CK_PBE_PARAMS jPbeParamToCKPbeParam(JNIEnv *env, jobject jParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
void copyBackPBEInitializationVector(JNIEnv *env, CK_MECHANISM *ckMechanism, jobject jMechanism);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
CK_PKCS5_PBKD2_PARAMS jPkcs5Pbkd2ParamToCKPkcs5Pbkd2Param(JNIEnv *env, jobject jParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
CK_KEY_WRAP_SET_OAEP_PARAMS jKeyWrapSetOaepParamToCKKeyWrapSetOaepParam(JNIEnv *env, jobject jParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
void copyBackSetUnwrappedKey(JNIEnv *env, CK_MECHANISM *ckMechanism, jobject jMechanism);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
CK_SSL3_MASTER_KEY_DERIVE_PARAMS jSsl3MasterKeyDeriveParamToCKSsl3MasterKeyDeriveParam(JNIEnv *env, jobject jParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
void copyBackClientVersion(JNIEnv *env, CK_MECHANISM *ckMechanism, jobject jMechanism);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
CK_SSL3_KEY_MAT_PARAMS jSsl3KeyMatParamToCKSsl3KeyMatParam(JNIEnv *env, jobject jParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
void copyBackSSLKeyMatParams(JNIEnv *env, CK_MECHANISM *ckMechanism, jobject jMechanism);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
CK_KEY_DERIVATION_STRING_DATA jKeyDerivationStringDataToCKKeyDerivationStringData(JNIEnv *env, jobject jParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
CK_RSA_PKCS_PSS_PARAMS jRsaPkcsPssParamToCKRsaPkcsPssParam(JNIEnv *env, jobject jParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
CK_ECDH1_DERIVE_PARAMS jEcdh1DeriveParamToCKEcdh1DeriveParam(JNIEnv *env, jobject jParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
CK_ECDH2_DERIVE_PARAMS jEcdh2DeriveParamToCKEcdh2DeriveParam(JNIEnv *env, jobject jParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
CK_X9_42_DH1_DERIVE_PARAMS jX942Dh1DeriveParamToCKX942Dh1DeriveParam(JNIEnv *env, jobject jParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
CK_X9_42_DH2_DERIVE_PARAMS jX942Dh2DeriveParamToCKX942Dh2DeriveParam(JNIEnv *env, jobject jParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
/* functions to convert the InitArgs object for calling the right Java mutex functions */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
CK_C_INITIALIZE_ARGS_PTR makeCKInitArgsAdapter(JNIEnv *env, jobject pInitArgs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
#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
   379
CK_RV callJCreateMutex(CK_VOID_PTR_PTR ppMutex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
CK_RV callJDestroyMutex(CK_VOID_PTR pMutex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
CK_RV callJLockMutex(CK_VOID_PTR pMutex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
CK_RV callJUnlockMutex(CK_VOID_PTR pMutex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
#endif /* NO_CALLBACKS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
void putModuleEntry(JNIEnv *env, jobject pkcs11Implementation, ModuleData *moduleData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
ModuleData * removeModuleEntry(JNIEnv *env, jobject pkcs11Implementation);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
CK_FUNCTION_LIST_PTR getFunctionList(JNIEnv *env, jobject pkcs11Implementation);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
/* A structure to encapsulate the required data for a Notify callback */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
struct NotifyEncapsulation {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    /* The object that implements the CK_NOTIFY interface and which should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * notified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    jobject jNotifyObject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    /* The data object to pass back to the Notify object upon callback. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    jobject jApplicationData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
typedef struct NotifyEncapsulation NotifyEncapsulation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
/* The function for handling notify callbacks. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
CK_RV notifyCallback(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    CK_SESSION_HANDLE hSession,     /* the session's handle */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    CK_NOTIFICATION   event,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    CK_VOID_PTR       pApplication  /* passed to C_OpenSession */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
/* A node of the list of notify callbacks. To be able to free the resources after use. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
struct NotifyListNode {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    /* The handle of the session this notify object is attached to*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    CK_SESSION_HANDLE hSession;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    /* Reference to the Notify encapsulation object that was passed to C_OpenSession. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    NotifyEncapsulation *notifyEncapsulation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    /* Pointer to the next node in the list. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    struct NotifyListNode *next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
typedef struct NotifyListNode NotifyListNode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
void putNotifyEntry(JNIEnv *env, CK_SESSION_HANDLE hSession, NotifyEncapsulation *notifyEncapsulation);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
NotifyEncapsulation * removeNotifyEntry(JNIEnv *env, CK_SESSION_HANDLE hSession);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
NotifyEncapsulation * removeFirstNotifyEntry(JNIEnv *env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
jobject createLockObject(JNIEnv *env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
void destroyLockObject(JNIEnv *env, jobject jLockObject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
extern jfieldID pNativeDataID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
extern jfieldID mech_mechanismID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
extern jfieldID mech_pParameterID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
extern jclass jByteArrayClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
extern jclass jLongClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
#ifndef NO_CALLBACKS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
extern NotifyListNode *notifyListHead;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
extern jobject notifyListLock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
extern jobject jInitArgsObject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
extern CK_C_INITIALIZE_ARGS_PTR ckpGlobalInitArgs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
#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
   446
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
   447
#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
   448
#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
   449
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
   450
/* 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
   451
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
   452
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
   453
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
   454
#define malloc(c)       (p11malloc((c), __FILE__, __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
   455
#define free(c)         (p11free((c), __FILE__, __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
   456
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
   457
#endif