author | herrick |
Wed, 14 Aug 2019 08:08:39 -0400 | |
branch | JDK-8200758-branch |
changeset 57743 | 8d6f0aff03fc |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
27182 | 1 |
/* |
37909 | 2 |
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. |
27182 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
#ifndef SPARCT4_NATIVE_FUNC_H |
|
27 |
#define SPARCT4_NATIVE_FUNC_H |
|
28 |
#include <md5.h> |
|
29 |
#include <sha1.h> |
|
30 |
#include <sha2.h> |
|
38878
7213c4599103
8157627: Ucrypto prov need to workaround the renaming of CK_AES_GCM_PARAMS starting S11.3
valeriep
parents:
37909
diff
changeset
|
31 |
#include <libsoftcrypto.h> // redirects to libucrypto.h starting 11.3 |
27182 | 32 |
|
33 |
jboolean* loadNative(); |
|
34 |
||
35 |
/* function pointer definitions */ |
|
36 |
||
37 |
typedef void (*MD5INIT_FN_PTR)(MD5_CTX *context); |
|
38 |
||
39 |
typedef void (*MD5UPDATE_FN_PTR) |
|
40 |
(MD5_CTX *context, unsigned char *input, |
|
41 |
unsigned int inlen); |
|
42 |
||
43 |
typedef void (*MD5FINAL_FN_PTR) |
|
44 |
(unsigned char *output, MD5_CTX *context); |
|
45 |
||
46 |
typedef void (*SHA1INIT_FN_PTR)(SHA1_CTX *context); |
|
47 |
||
48 |
typedef void (*SHA1UPDATE_FN_PTR) |
|
49 |
(SHA1_CTX *context, unsigned char *input, |
|
50 |
unsigned int inlen); |
|
51 |
||
52 |
typedef void (*SHA1FINAL_FN_PTR) |
|
53 |
(unsigned char *output, SHA1_CTX *context); |
|
54 |
||
55 |
typedef void (*SHA2INIT_FN_PTR)(uint64_t mech, SHA2_CTX *context); |
|
56 |
||
57 |
typedef void (*SHA2UPDATE_FN_PTR) |
|
58 |
(SHA2_CTX *context, unsigned char *input, |
|
59 |
unsigned int inlen); |
|
60 |
||
61 |
typedef void (*SHA2FINAL_FN_PTR) |
|
62 |
(unsigned char *output, SHA2_CTX *context); |
|
63 |
||
64 |
typedef int (*UCRYPTO_VERSION_FN_PTR)(); |
|
65 |
||
66 |
typedef int (*UCRYPTO_GET_MECHLIST_FN_PTR)(char *str); |
|
67 |
||
68 |
typedef int (*UCRYPTO_ENCRYPT_INIT_FN_PTR) |
|
69 |
(crypto_ctx_t *context, ucrypto_mech_t mech_type, |
|
70 |
uchar_t *key_str, size_t key_len, |
|
71 |
void *iv, size_t iv_len); |
|
72 |
typedef int (*UCRYPTO_ENCRYPT_UPDATE_FN_PTR) |
|
73 |
(crypto_ctx_t *context, uchar_t *in, |
|
74 |
size_t in_len, uchar_t *out, size_t *out_len); |
|
75 |
typedef int (*UCRYPTO_ENCRYPT_FINAL_FN_PTR) |
|
76 |
(crypto_ctx_t *context, uchar_t *out, |
|
77 |
size_t *out_len); |
|
78 |
typedef int (*UCRYPTO_ENCRYPT_FN_PTR) |
|
79 |
(ucrypto_mech_t mech_type, uchar_t *key_str, |
|
80 |
size_t key_len, void *iv, size_t iv_len, uchar_t *in, |
|
81 |
size_t in_len, uchar_t *out, size_t *out_len); |
|
82 |
||
83 |
typedef int (*UCRYPTO_DECRYPT_INIT_FN_PTR) |
|
84 |
(crypto_ctx_t *context, |
|
85 |
ucrypto_mech_t mech_type, uchar_t *key_str, size_t key_len, |
|
86 |
void *iv, size_t iv_len); |
|
87 |
typedef int (*UCRYPTO_DECRYPT_UPDATE_FN_PTR) |
|
88 |
(crypto_ctx_t *context, uchar_t *in, |
|
89 |
size_t in_len, uchar_t *out, size_t *out_len); |
|
90 |
typedef int (*UCRYPTO_DECRYPT_FINAL_FN_PTR) |
|
91 |
(crypto_ctx_t *context, uchar_t *out, |
|
92 |
size_t *out_len); |
|
93 |
typedef int (*UCRYPTO_DECRYPT_FN_PTR) |
|
94 |
(ucrypto_mech_t mech_type, uchar_t *key_str, |
|
95 |
size_t key_len, void *iv, size_t iv_len, uchar_t *in, |
|
96 |
size_t in_len, uchar_t *out, size_t *out_len); |
|
97 |
||
98 |
typedef int (*UCRYPTO_SIGN_INIT_FN_PTR) |
|
99 |
(crypto_ctx_t *context, ucrypto_mech_t mech_type, |
|
100 |
uchar_t *key_str, size_t key_len, |
|
101 |
void *iv, size_t iv_len); |
|
102 |
typedef int (*UCRYPTO_SIGN_UPDATE_FN_PTR) |
|
103 |
(crypto_ctx_t *context, uchar_t *data_str, size_t data_len); |
|
104 |
typedef int (*UCRYPTO_SIGN_FINAL_FN_PTR) |
|
105 |
(crypto_ctx_t *context, uchar_t *sig_str, size_t *sig_len); |
|
106 |
||
107 |
typedef int (*UCRYPTO_VERIFY_INIT_FN_PTR) |
|
108 |
(crypto_ctx_t *context, ucrypto_mech_t mech_type, |
|
109 |
uchar_t *key_str, size_t key_len, |
|
110 |
void *iv, size_t iv_len); |
|
111 |
typedef int (*UCRYPTO_VERIFY_UPDATE_FN_PTR) |
|
112 |
(crypto_ctx_t *context, uchar_t *data_str, size_t data_len); |
|
113 |
typedef int (*UCRYPTO_VERIFY_FINAL_FN_PTR) |
|
114 |
(crypto_ctx_t *context, uchar_t *sig_str, size_t *sig_len); |
|
115 |
||
37909 | 116 |
typedef int (*UCRYPTO_DIGEST_INIT_FN_PTR) |
117 |
(crypto_ctx_t *context, ucrypto_mech_t mech_type, |
|
118 |
void *param, size_t param_len); |
|
119 |
typedef int (*UCRYPTO_DIGEST_UPDATE_FN_PTR) |
|
120 |
(crypto_ctx_t *context, const uchar_t *data, size_t data_len); |
|
121 |
typedef int (*UCRYPTO_DIGEST_FINAL_FN_PTR) |
|
122 |
(crypto_ctx_t *context, uchar_t *digest, size_t *digest_len); |
|
123 |
||
124 |
typedef void (*UCRYPTO_FREE_CONTEXT_FN_PTR) |
|
125 |
(crypto_ctx_t *context); |
|
126 |
||
127 |
typedef char* (*UCRYPTO_STRERROR_FN_PTR)(int rv); |
|
128 |
||
27182 | 129 |
|
130 |
||
131 |
/* dynamically resolved functions from libmd, and libsoftcrypto |
|
132 |
libraries */ |
|
133 |
typedef struct T4CRYPTO_FUNCTION_TABLE { |
|
134 |
MD5INIT_FN_PTR md5Init; |
|
135 |
MD5UPDATE_FN_PTR md5Update; |
|
136 |
MD5FINAL_FN_PTR md5Final; |
|
137 |
SHA1INIT_FN_PTR sha1Init; |
|
138 |
SHA1UPDATE_FN_PTR sha1Update; |
|
139 |
SHA1FINAL_FN_PTR sha1Final; |
|
140 |
SHA2INIT_FN_PTR sha2Init; |
|
141 |
SHA2UPDATE_FN_PTR sha2Update; |
|
142 |
SHA2FINAL_FN_PTR sha2Final; |
|
143 |
UCRYPTO_VERSION_FN_PTR ucryptoVersion; |
|
144 |
UCRYPTO_GET_MECHLIST_FN_PTR ucryptoGetMechList; |
|
145 |
UCRYPTO_ENCRYPT_INIT_FN_PTR ucryptoEncryptInit; |
|
146 |
UCRYPTO_ENCRYPT_UPDATE_FN_PTR ucryptoEncryptUpdate; |
|
147 |
UCRYPTO_ENCRYPT_FINAL_FN_PTR ucryptoEncryptFinal; |
|
148 |
UCRYPTO_ENCRYPT_FN_PTR ucryptoEncrypt; |
|
149 |
UCRYPTO_DECRYPT_INIT_FN_PTR ucryptoDecryptInit; |
|
150 |
UCRYPTO_DECRYPT_UPDATE_FN_PTR ucryptoDecryptUpdate; |
|
151 |
UCRYPTO_DECRYPT_FINAL_FN_PTR ucryptoDecryptFinal; |
|
152 |
UCRYPTO_DECRYPT_FN_PTR ucryptoDecrypt; |
|
153 |
UCRYPTO_SIGN_INIT_FN_PTR ucryptoSignInit; |
|
154 |
UCRYPTO_SIGN_UPDATE_FN_PTR ucryptoSignUpdate; |
|
155 |
UCRYPTO_SIGN_FINAL_FN_PTR ucryptoSignFinal; |
|
156 |
UCRYPTO_VERIFY_INIT_FN_PTR ucryptoVerifyInit; |
|
157 |
UCRYPTO_VERIFY_UPDATE_FN_PTR ucryptoVerifyUpdate; |
|
158 |
UCRYPTO_VERIFY_FINAL_FN_PTR ucryptoVerifyFinal; |
|
37909 | 159 |
UCRYPTO_DIGEST_INIT_FN_PTR ucryptoDigestInit; |
160 |
UCRYPTO_DIGEST_UPDATE_FN_PTR ucryptoDigestUpdate; |
|
161 |
UCRYPTO_DIGEST_FINAL_FN_PTR ucryptoDigestFinal; |
|
162 |
UCRYPTO_FREE_CONTEXT_FN_PTR ucryptoFreeContext; |
|
163 |
UCRYPTO_STRERROR_FN_PTR ucryptoStrerror; |
|
27182 | 164 |
} T4CRYPTO_FUNCTION_TABLE; |
165 |
||
166 |
typedef T4CRYPTO_FUNCTION_TABLE *T4CRYPTO_FUNCTION_TABLE_PTR; |
|
167 |
||
168 |
/* global function table */ |
|
169 |
T4CRYPTO_FUNCTION_TABLE_PTR ftab; |
|
170 |
||
171 |
#endif |