-
Notifications
You must be signed in to change notification settings - Fork 1
/
sha2_impl.h
120 lines (88 loc) · 3.37 KB
/
sha2_impl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
* Copyright (c) 2022 Tino Reichardt <[email protected]>
*/
#ifndef _SHA2_IMPL_H
#define _SHA2_IMPL_H
#include <sys/types.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
#define SHA256_DIGEST_LENGTH 32
#define SHA256_BLOCK_SIZE 64
#define SHA512_DIGEST_LENGTH 64
#define SHA512_BLOCK_SIZE 128
#define SHA512_256_DIGEST_LENGTH 32
typedef int (*sha2_init_f)(void **ctx);
typedef int (*sha2_update_f)(void *ctx, const void *data, size_t len);
typedef int (*sha2_final_f)(void *ctx, unsigned char *md);
typedef int (*sha2_is_supported_f)(void);
typedef struct sha2_impl_ops {
/* must have */
sha2_init_f init;
sha2_update_f update;
sha2_final_f final;
int digest_len;
const char *name;
/* optional */
sha2_is_supported_f is_supported;
} sha2_impl_ops_t;
#if defined(__aarch64__)
extern const sha2_impl_ops_t sha256_noloder_armv8_impl;
extern const sha2_impl_ops_t sha256_ossl_data_order_impl;
extern const sha2_impl_ops_t sha256_ossl_neon_impl;
extern const sha2_impl_ops_t sha256_ossl_armv8_impl;
extern const sha2_impl_ops_t sha512_ossl_data_order_impl;
extern const sha2_impl_ops_t sha512_ossl_armv8_impl;
#endif
#if defined(__arm__)
extern const sha2_impl_ops_t sha256_ossl_data_order_impl;
extern const sha2_impl_ops_t sha256_ossl_neon_impl;
extern const sha2_impl_ops_t sha256_ossl_armv8_impl;
extern const sha2_impl_ops_t sha512_ossl_data_order_impl;
extern const sha2_impl_ops_t sha512_ossl_neon_impl;
#endif
#if defined(__PPC64__)
extern const sha2_impl_ops_t sha256_ossl_ppc64_impl;
extern const sha2_impl_ops_t sha256_ossl_ppc64p8_impl;
extern const sha2_impl_ops_t sha256_noloader_ppc64_impl;
extern const sha2_impl_ops_t sha512_ossl_ppc64_impl;
extern const sha2_impl_ops_t sha512_ossl_ppc64p8_impl;
extern const sha2_impl_ops_t sha512_noloader_ppc64_impl;
#endif
extern const sha2_impl_ops_t sha256_cifra_impl;
extern const sha2_impl_ops_t sha512_cifra_impl;
extern const sha2_impl_ops_t sha256_openssl_impl;
extern const sha2_impl_ops_t sha512_openssl_impl;
extern const sha2_impl_ops_t sha256_lzma_impl;
extern const sha2_impl_ops_t sha256_ltc_impl;
extern const sha2_impl_ops_t sha256_sbase_impl;
extern const sha2_impl_ops_t sha512_sbase_impl;
extern const sha2_impl_ops_t sha512_256_sbase_impl;
extern const sha2_impl_ops_t sha256_bsd_impl;
extern const sha2_impl_ops_t sha512_bsd_impl;
extern const sha2_impl_ops_t sha512_256_bsd_impl;
extern const sha2_impl_ops_t sha256_cppcrypto_impl;
#if defined(__x86_64)
extern const sha2_impl_ops_t sha256_intel_ssse3_impl;
extern const sha2_impl_ops_t sha256_intel_avx_impl;
extern const sha2_impl_ops_t sha256_intel_ni_impl;
extern const sha2_impl_ops_t sha256_ossl_x64_impl;
extern const sha2_impl_ops_t sha256_ossl_ssse3_impl;
extern const sha2_impl_ops_t sha256_ossl_avx_impl;
extern const sha2_impl_ops_t sha256_ossl_avx2_impl;
extern const sha2_impl_ops_t sha256_ossl_ni_impl;
extern const sha2_impl_ops_t sha512t_ossl_avx2_impl;
extern const sha2_impl_ops_t sha512_intel_ssse3_impl;
extern const sha2_impl_ops_t sha512_intel_avx_impl;
extern const sha2_impl_ops_t sha512_intel_avx2_impl;
extern const sha2_impl_ops_t sha512_ossl_x64_impl;
extern const sha2_impl_ops_t sha512_ossl_avx_impl;
extern const sha2_impl_ops_t sha512_ossl_avx2_impl;
#endif
extern const sha2_impl_ops_t sha512_cppcrypto_impl;
extern const sha2_impl_ops_t sha512_256_cppcrypto_impl;
#ifdef __cplusplus
}
#endif
#endif /* _SHA2_IMPL_H */