|
1 /* |
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
|
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> |
|
31 #include <libsoftcrypto.h> |
|
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 |
|
73 typedef int (*UCRYPTO_ENCRYPT_UPDATE_FN_PTR) |
|
74 (crypto_ctx_t *context, uchar_t *in, |
|
75 size_t in_len, uchar_t *out, size_t *out_len); |
|
76 |
|
77 typedef int (*UCRYPTO_ENCRYPT_FINAL_FN_PTR) |
|
78 (crypto_ctx_t *context, uchar_t *out, |
|
79 size_t *out_len); |
|
80 |
|
81 typedef int (*UCRYPTO_ENCRYPT_FN_PTR) |
|
82 (ucrypto_mech_t mech_type, uchar_t *key_str, |
|
83 size_t key_len, void *iv, size_t iv_len, uchar_t *in, |
|
84 size_t in_len, uchar_t *out, size_t *out_len); |
|
85 |
|
86 typedef int (*UCRYPTO_DECRYPT_INIT_FN_PTR) |
|
87 (crypto_ctx_t *context, |
|
88 ucrypto_mech_t mech_type, uchar_t *key_str, size_t key_len, |
|
89 void *iv, size_t iv_len); |
|
90 |
|
91 typedef int (*UCRYPTO_DECRYPT_UPDATE_FN_PTR) |
|
92 (crypto_ctx_t *context, uchar_t *in, |
|
93 size_t in_len, uchar_t *out, size_t *out_len); |
|
94 |
|
95 typedef int (*UCRYPTO_DECRYPT_FINAL_FN_PTR) |
|
96 (crypto_ctx_t *context, uchar_t *out, |
|
97 size_t *out_len); |
|
98 |
|
99 typedef int (*UCRYPTO_DECRYPT_FN_PTR) |
|
100 (ucrypto_mech_t mech_type, uchar_t *key_str, |
|
101 size_t key_len, void *iv, size_t iv_len, uchar_t *in, |
|
102 size_t in_len, uchar_t *out, size_t *out_len); |
|
103 |
|
104 typedef int (*UCRYPTO_SIGN_INIT_FN_PTR) |
|
105 (crypto_ctx_t *context, ucrypto_mech_t mech_type, |
|
106 uchar_t *key_str, size_t key_len, |
|
107 void *iv, size_t iv_len); |
|
108 |
|
109 typedef int (*UCRYPTO_SIGN_UPDATE_FN_PTR) |
|
110 (crypto_ctx_t *context, uchar_t *data_str, size_t data_len); |
|
111 |
|
112 typedef int (*UCRYPTO_SIGN_FINAL_FN_PTR) |
|
113 (crypto_ctx_t *context, uchar_t *sig_str, size_t *sig_len); |
|
114 |
|
115 typedef int (*UCRYPTO_VERIFY_INIT_FN_PTR) |
|
116 (crypto_ctx_t *context, ucrypto_mech_t mech_type, |
|
117 uchar_t *key_str, size_t key_len, |
|
118 void *iv, size_t iv_len); |
|
119 |
|
120 typedef int (*UCRYPTO_VERIFY_UPDATE_FN_PTR) |
|
121 (crypto_ctx_t *context, uchar_t *data_str, size_t data_len); |
|
122 |
|
123 typedef int (*UCRYPTO_VERIFY_FINAL_FN_PTR) |
|
124 (crypto_ctx_t *context, uchar_t *sig_str, size_t *sig_len); |
|
125 |
|
126 |
|
127 |
|
128 /* dynamically resolved functions from libmd, and libsoftcrypto |
|
129 libraries */ |
|
130 typedef struct T4CRYPTO_FUNCTION_TABLE { |
|
131 MD5INIT_FN_PTR md5Init; |
|
132 MD5UPDATE_FN_PTR md5Update; |
|
133 MD5FINAL_FN_PTR md5Final; |
|
134 SHA1INIT_FN_PTR sha1Init; |
|
135 SHA1UPDATE_FN_PTR sha1Update; |
|
136 SHA1FINAL_FN_PTR sha1Final; |
|
137 SHA2INIT_FN_PTR sha2Init; |
|
138 SHA2UPDATE_FN_PTR sha2Update; |
|
139 SHA2FINAL_FN_PTR sha2Final; |
|
140 UCRYPTO_VERSION_FN_PTR ucryptoVersion; |
|
141 UCRYPTO_GET_MECHLIST_FN_PTR ucryptoGetMechList; |
|
142 UCRYPTO_ENCRYPT_INIT_FN_PTR ucryptoEncryptInit; |
|
143 UCRYPTO_ENCRYPT_UPDATE_FN_PTR ucryptoEncryptUpdate; |
|
144 UCRYPTO_ENCRYPT_FINAL_FN_PTR ucryptoEncryptFinal; |
|
145 UCRYPTO_ENCRYPT_FN_PTR ucryptoEncrypt; |
|
146 UCRYPTO_DECRYPT_INIT_FN_PTR ucryptoDecryptInit; |
|
147 UCRYPTO_DECRYPT_UPDATE_FN_PTR ucryptoDecryptUpdate; |
|
148 UCRYPTO_DECRYPT_FINAL_FN_PTR ucryptoDecryptFinal; |
|
149 UCRYPTO_DECRYPT_FN_PTR ucryptoDecrypt; |
|
150 UCRYPTO_SIGN_INIT_FN_PTR ucryptoSignInit; |
|
151 UCRYPTO_SIGN_UPDATE_FN_PTR ucryptoSignUpdate; |
|
152 UCRYPTO_SIGN_FINAL_FN_PTR ucryptoSignFinal; |
|
153 UCRYPTO_VERIFY_INIT_FN_PTR ucryptoVerifyInit; |
|
154 UCRYPTO_VERIFY_UPDATE_FN_PTR ucryptoVerifyUpdate; |
|
155 UCRYPTO_VERIFY_FINAL_FN_PTR ucryptoVerifyFinal; |
|
156 } T4CRYPTO_FUNCTION_TABLE; |
|
157 |
|
158 typedef T4CRYPTO_FUNCTION_TABLE *T4CRYPTO_FUNCTION_TABLE_PTR; |
|
159 |
|
160 /* global function table */ |
|
161 T4CRYPTO_FUNCTION_TABLE_PTR ftab; |
|
162 |
|
163 #endif |