1 | #ifndef MYSQL_SERVICE_SHA2_INCLUDED |
2 | /* Copyright (c) 2017, MariaDB |
3 | |
4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by |
6 | the Free Software Foundation; version 2 of the License. |
7 | |
8 | This program is distributed in the hope that it will be useful, |
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | GNU General Public License for more details. |
12 | |
13 | You should have received a copy of the GNU General Public License |
14 | along with this program; if not, write to the Free Software |
15 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ |
16 | |
17 | /** |
18 | @file |
19 | my sha2 service |
20 | |
21 | Functions to calculate SHA2 hash from a memory buffer |
22 | */ |
23 | |
24 | #ifdef __cplusplus |
25 | extern "C" { |
26 | #endif |
27 | |
28 | #ifndef MYSQL_ABI_CHECK |
29 | #include <stdlib.h> |
30 | #endif |
31 | |
32 | extern struct my_sha2_service_st { |
33 | void (*my_sha224_type)(unsigned char*, const char*, size_t); |
34 | void (*my_sha224_multi_type)(unsigned char*, ...); |
35 | size_t (*my_sha224_context_size_type)(); |
36 | void (*my_sha224_init_type)(void *); |
37 | void (*my_sha224_input_type)(void *, const unsigned char *, size_t); |
38 | void (*my_sha224_result_type)(void *, unsigned char *); |
39 | |
40 | void (*my_sha256_type)(unsigned char*, const char*, size_t); |
41 | void (*my_sha256_multi_type)(unsigned char*, ...); |
42 | size_t (*my_sha256_context_size_type)(); |
43 | void (*my_sha256_init_type)(void *); |
44 | void (*my_sha256_input_type)(void *, const unsigned char *, size_t); |
45 | void (*my_sha256_result_type)(void *, unsigned char *); |
46 | |
47 | void (*my_sha384_type)(unsigned char*, const char*, size_t); |
48 | void (*my_sha384_multi_type)(unsigned char*, ...); |
49 | size_t (*my_sha384_context_size_type)(); |
50 | void (*my_sha384_init_type)(void *); |
51 | void (*my_sha384_input_type)(void *, const unsigned char *, size_t); |
52 | void (*my_sha384_result_type)(void *, unsigned char *); |
53 | |
54 | void (*my_sha512_type)(unsigned char*, const char*, size_t); |
55 | void (*my_sha512_multi_type)(unsigned char*, ...); |
56 | size_t (*my_sha512_context_size_type)(); |
57 | void (*my_sha512_init_type)(void *); |
58 | void (*my_sha512_input_type)(void *, const unsigned char *, size_t); |
59 | void (*my_sha512_result_type)(void *, unsigned char *); |
60 | } *my_sha2_service; |
61 | |
62 | #ifdef MYSQL_DYNAMIC_PLUGIN |
63 | |
64 | #define my_sha224(A,B,C) my_sha2_service->my_sha224_type(A,B,C) |
65 | #define my_sha224_multi my_sha2_service->my_sha224_multi_type |
66 | #define my_sha224_context_size() my_sha2_service->my_sha224_context_size_type() |
67 | #define my_sha224_init(A) my_sha2_service->my_sha224_init_type(A) |
68 | #define my_sha224_input(A,B,C) my_sha2_service->my_sha224_input_type(A,B,C) |
69 | #define my_sha224_result(A,B) my_sha2_service->my_sha224_result_type(A,B) |
70 | |
71 | #define my_sha256(A,B,C) my_sha2_service->my_sha256_type(A,B,C) |
72 | #define my_sha256_multi my_sha2_service->my_sha256_multi_type |
73 | #define my_sha256_context_size() my_sha2_service->my_sha256_context_size_type() |
74 | #define my_sha256_init(A) my_sha2_service->my_sha256_init_type(A) |
75 | #define my_sha256_input(A,B,C) my_sha2_service->my_sha256_input_type(A,B,C) |
76 | #define my_sha256_result(A,B) my_sha2_service->my_sha256_result_type(A,B) |
77 | |
78 | #define my_sha384(A,B,C) my_sha2_service->my_sha384_type(A,B,C) |
79 | #define my_sha384_multi my_sha2_service->my_sha384_multi_type |
80 | #define my_sha384_context_size() my_sha2_service->my_sha384_context_size_type() |
81 | #define my_sha384_init(A) my_sha2_service->my_sha384_init_type(A) |
82 | #define my_sha384_input(A,B,C) my_sha2_service->my_sha384_input_type(A,B,C) |
83 | #define my_sha384_result(A,B) my_sha2_service->my_sha384_result_type(A,B) |
84 | |
85 | #define my_sha512(A,B,C) my_sha2_service->my_sha512_type(A,B,C) |
86 | #define my_sha512_multi my_sha2_service->my_sha512_multi_type |
87 | #define my_sha512_context_size() my_sha2_service->my_sha512_context_size_type() |
88 | #define my_sha512_init(A) my_sha2_service->my_sha512_init_type(A) |
89 | #define my_sha512_input(A,B,C) my_sha2_service->my_sha512_input_type(A,B,C) |
90 | #define my_sha512_result(A,B) my_sha2_service->my_sha512_result_type(A,B) |
91 | |
92 | #else |
93 | |
94 | void my_sha224(unsigned char*, const char*, size_t); |
95 | void my_sha224_multi(unsigned char*, ...); |
96 | size_t my_sha224_context_size(); |
97 | void my_sha224_init(void *context); |
98 | void my_sha224_input(void *context, const unsigned char *buf, size_t len); |
99 | void my_sha224_result(void *context, unsigned char *digest); |
100 | |
101 | void my_sha256(unsigned char*, const char*, size_t); |
102 | void my_sha256_multi(unsigned char*, ...); |
103 | size_t my_sha256_context_size(); |
104 | void my_sha256_init(void *context); |
105 | void my_sha256_input(void *context, const unsigned char *buf, size_t len); |
106 | void my_sha256_result(void *context, unsigned char *digest); |
107 | |
108 | void my_sha384(unsigned char*, const char*, size_t); |
109 | void my_sha384_multi(unsigned char*, ...); |
110 | size_t my_sha384_context_size(); |
111 | void my_sha384_init(void *context); |
112 | void my_sha384_input(void *context, const unsigned char *buf, size_t len); |
113 | void my_sha384_result(void *context, unsigned char *digest); |
114 | |
115 | void my_sha512(unsigned char*, const char*, size_t); |
116 | void my_sha512_multi(unsigned char*, ...); |
117 | size_t my_sha512_context_size(); |
118 | void my_sha512_init(void *context); |
119 | void my_sha512_input(void *context, const unsigned char *buf, size_t len); |
120 | void my_sha512_result(void *context, unsigned char *digest); |
121 | |
122 | #endif |
123 | |
124 | #ifdef __cplusplus |
125 | } |
126 | #endif |
127 | |
128 | #define MYSQL_SERVICE_SHA2_INCLUDED |
129 | #endif |
130 | |
131 | |