xcrypt 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Rakefile +106 -0
- data/ext/libxcrypt/AUTHORS +38 -0
- data/ext/libxcrypt/COPYING.LIB +502 -0
- data/ext/libxcrypt/ChangeLog +239 -0
- data/ext/libxcrypt/INSTALL +380 -0
- data/ext/libxcrypt/LICENSING +152 -0
- data/ext/libxcrypt/Makefile.am +704 -0
- data/ext/libxcrypt/Makefile.in +4110 -0
- data/ext/libxcrypt/NEWS +630 -0
- data/ext/libxcrypt/README +1 -0
- data/ext/libxcrypt/README.md +179 -0
- data/ext/libxcrypt/THANKS +13 -0
- data/ext/libxcrypt/TODO +1 -0
- data/ext/libxcrypt/TODO.md +100 -0
- data/ext/libxcrypt/aclocal.m4 +2617 -0
- data/ext/libxcrypt/autogen.sh +33 -0
- data/ext/libxcrypt/autom4te.cache/output.0 +19884 -0
- data/ext/libxcrypt/autom4te.cache/output.1 +19884 -0
- data/ext/libxcrypt/autom4te.cache/output.2 +19884 -0
- data/ext/libxcrypt/autom4te.cache/output.3 +19885 -0
- data/ext/libxcrypt/autom4te.cache/requests +714 -0
- data/ext/libxcrypt/autom4te.cache/traces.0 +4088 -0
- data/ext/libxcrypt/autom4te.cache/traces.1 +1060 -0
- data/ext/libxcrypt/autom4te.cache/traces.2 +4088 -0
- data/ext/libxcrypt/autom4te.cache/traces.3 +1060 -0
- data/ext/libxcrypt/build-aux/ci/ci-log-dependency-versions +79 -0
- data/ext/libxcrypt/build-aux/ci/ci-log-logfiles +22 -0
- data/ext/libxcrypt/build-aux/ci/clang-gcov-wrapper +2 -0
- data/ext/libxcrypt/build-aux/ci/configure-wrapper +10 -0
- data/ext/libxcrypt/build-aux/ci/summarize-coverage +24 -0
- data/ext/libxcrypt/build-aux/m4/ax_append_compile_flags.m4 +46 -0
- data/ext/libxcrypt/build-aux/m4/ax_append_flag.m4 +50 -0
- data/ext/libxcrypt/build-aux/m4/ax_check_compile_flag.m4 +53 -0
- data/ext/libxcrypt/build-aux/m4/ax_check_vscript.m4 +142 -0
- data/ext/libxcrypt/build-aux/m4/ax_gcc_func_attribute.m4 +246 -0
- data/ext/libxcrypt/build-aux/m4/ax_require_defined.m4 +37 -0
- data/ext/libxcrypt/build-aux/m4/ax_valgrind_check.m4 +239 -0
- data/ext/libxcrypt/build-aux/m4/libtool.m4 +8488 -0
- data/ext/libxcrypt/build-aux/m4/ltoptions.m4 +467 -0
- data/ext/libxcrypt/build-aux/m4/ltsugar.m4 +124 -0
- data/ext/libxcrypt/build-aux/m4/ltversion.m4 +24 -0
- data/ext/libxcrypt/build-aux/m4/lt~obsolete.m4 +99 -0
- data/ext/libxcrypt/build-aux/m4/pkg_compat.m4 +88 -0
- data/ext/libxcrypt/build-aux/m4/zw_alignment.m4 +90 -0
- data/ext/libxcrypt/build-aux/m4/zw_automodern.m4 +307 -0
- data/ext/libxcrypt/build-aux/m4/zw_detect_asan.m4 +24 -0
- data/ext/libxcrypt/build-aux/m4/zw_endianness.m4 +152 -0
- data/ext/libxcrypt/build-aux/m4/zw_ld_wrap.m4 +47 -0
- data/ext/libxcrypt/build-aux/m4/zw_prog_perl.m4 +40 -0
- data/ext/libxcrypt/build-aux/m4/zw_simple_warnings.m4 +150 -0
- data/ext/libxcrypt/build-aux/m4/zw_static_assert.m4 +68 -0
- data/ext/libxcrypt/build-aux/m4-autogen/compile +364 -0
- data/ext/libxcrypt/build-aux/m4-autogen/config.guess +1815 -0
- data/ext/libxcrypt/build-aux/m4-autogen/config.sub +2354 -0
- data/ext/libxcrypt/build-aux/m4-autogen/depcomp +792 -0
- data/ext/libxcrypt/build-aux/m4-autogen/install-sh +541 -0
- data/ext/libxcrypt/build-aux/m4-autogen/ltmain.sh +11524 -0
- data/ext/libxcrypt/build-aux/m4-autogen/missing +236 -0
- data/ext/libxcrypt/build-aux/m4-autogen/test-driver +160 -0
- data/ext/libxcrypt/build-aux/scripts/BuildCommon.pm +712 -0
- data/ext/libxcrypt/build-aux/scripts/check-perlcritic-config +76 -0
- data/ext/libxcrypt/build-aux/scripts/compute-symver-floor +116 -0
- data/ext/libxcrypt/build-aux/scripts/expand-selected-hashes +80 -0
- data/ext/libxcrypt/build-aux/scripts/gen-crypt-h +131 -0
- data/ext/libxcrypt/build-aux/scripts/gen-crypt-hashes-h +141 -0
- data/ext/libxcrypt/build-aux/scripts/gen-crypt-symbol-vers-h +150 -0
- data/ext/libxcrypt/build-aux/scripts/gen-libcrypt-map +67 -0
- data/ext/libxcrypt/build-aux/scripts/move-if-change +84 -0
- data/ext/libxcrypt/build-aux/scripts/skip-if-exec-format-error +78 -0
- data/ext/libxcrypt/codecov.yml +4 -0
- data/ext/libxcrypt/config.h.in +303 -0
- data/ext/libxcrypt/configure +19885 -0
- data/ext/libxcrypt/configure.ac +549 -0
- data/ext/libxcrypt/doc/crypt.3 +512 -0
- data/ext/libxcrypt/doc/crypt.5 +343 -0
- data/ext/libxcrypt/doc/crypt_checksalt.3 +106 -0
- data/ext/libxcrypt/doc/crypt_gensalt.3 +285 -0
- data/ext/libxcrypt/doc/crypt_gensalt_ra.3 +1 -0
- data/ext/libxcrypt/doc/crypt_gensalt_rn.3 +1 -0
- data/ext/libxcrypt/doc/crypt_preferred_method.3 +68 -0
- data/ext/libxcrypt/doc/crypt_r.3 +1 -0
- data/ext/libxcrypt/doc/crypt_ra.3 +1 -0
- data/ext/libxcrypt/doc/crypt_rn.3 +1 -0
- data/ext/libxcrypt/lib/alg-des-tables.c +3858 -0
- data/ext/libxcrypt/lib/alg-des.c +269 -0
- data/ext/libxcrypt/lib/alg-des.h +74 -0
- data/ext/libxcrypt/lib/alg-gost3411-2012-const.h +313 -0
- data/ext/libxcrypt/lib/alg-gost3411-2012-core.c +238 -0
- data/ext/libxcrypt/lib/alg-gost3411-2012-core.h +51 -0
- data/ext/libxcrypt/lib/alg-gost3411-2012-hmac.c +78 -0
- data/ext/libxcrypt/lib/alg-gost3411-2012-hmac.h +46 -0
- data/ext/libxcrypt/lib/alg-gost3411-2012-precalc.h +1426 -0
- data/ext/libxcrypt/lib/alg-gost3411-2012-ref.h +67 -0
- data/ext/libxcrypt/lib/alg-hmac-sha1.c +140 -0
- data/ext/libxcrypt/lib/alg-hmac-sha1.h +35 -0
- data/ext/libxcrypt/lib/alg-md4.c +270 -0
- data/ext/libxcrypt/lib/alg-md4.h +43 -0
- data/ext/libxcrypt/lib/alg-md5.c +291 -0
- data/ext/libxcrypt/lib/alg-md5.h +43 -0
- data/ext/libxcrypt/lib/alg-sha1.c +288 -0
- data/ext/libxcrypt/lib/alg-sha1.h +34 -0
- data/ext/libxcrypt/lib/alg-sha256.c +630 -0
- data/ext/libxcrypt/lib/alg-sha256.h +123 -0
- data/ext/libxcrypt/lib/alg-sha512.c +311 -0
- data/ext/libxcrypt/lib/alg-sha512.h +81 -0
- data/ext/libxcrypt/lib/alg-sm3-hmac.c +113 -0
- data/ext/libxcrypt/lib/alg-sm3-hmac.h +42 -0
- data/ext/libxcrypt/lib/alg-sm3.c +449 -0
- data/ext/libxcrypt/lib/alg-sm3.h +63 -0
- data/ext/libxcrypt/lib/alg-yescrypt-common.c +713 -0
- data/ext/libxcrypt/lib/alg-yescrypt-opt.c +1568 -0
- data/ext/libxcrypt/lib/alg-yescrypt-platform.c +106 -0
- data/ext/libxcrypt/lib/alg-yescrypt.h +360 -0
- data/ext/libxcrypt/lib/byteorder.h +164 -0
- data/ext/libxcrypt/lib/crypt-bcrypt.c +1061 -0
- data/ext/libxcrypt/lib/crypt-des-obsolete.c +215 -0
- data/ext/libxcrypt/lib/crypt-des.c +491 -0
- data/ext/libxcrypt/lib/crypt-gensalt-static.c +40 -0
- data/ext/libxcrypt/lib/crypt-gost-yescrypt.c +182 -0
- data/ext/libxcrypt/lib/crypt-md5.c +232 -0
- data/ext/libxcrypt/lib/crypt-nthash.c +134 -0
- data/ext/libxcrypt/lib/crypt-obsolete.h +40 -0
- data/ext/libxcrypt/lib/crypt-pbkdf1-sha1.c +260 -0
- data/ext/libxcrypt/lib/crypt-port.h +514 -0
- data/ext/libxcrypt/lib/crypt-scrypt.c +247 -0
- data/ext/libxcrypt/lib/crypt-sha256.c +308 -0
- data/ext/libxcrypt/lib/crypt-sha512.c +323 -0
- data/ext/libxcrypt/lib/crypt-sm3-yescrypt.c +189 -0
- data/ext/libxcrypt/lib/crypt-sm3.c +308 -0
- data/ext/libxcrypt/lib/crypt-static.c +44 -0
- data/ext/libxcrypt/lib/crypt-sunmd5.c +314 -0
- data/ext/libxcrypt/lib/crypt-yescrypt.c +177 -0
- data/ext/libxcrypt/lib/crypt.c +421 -0
- data/ext/libxcrypt/lib/crypt.h.in +249 -0
- data/ext/libxcrypt/lib/gen-des-tables.c +363 -0
- data/ext/libxcrypt/lib/hashes.conf +59 -0
- data/ext/libxcrypt/lib/libcrypt.map.in +48 -0
- data/ext/libxcrypt/lib/libcrypt.minver +97 -0
- data/ext/libxcrypt/lib/libxcrypt.pc.in +15 -0
- data/ext/libxcrypt/lib/util-base64.c +26 -0
- data/ext/libxcrypt/lib/util-gensalt-sha.c +88 -0
- data/ext/libxcrypt/lib/util-get-random-bytes.c +154 -0
- data/ext/libxcrypt/lib/util-make-failure-token.c +48 -0
- data/ext/libxcrypt/lib/util-xbzero.c +43 -0
- data/ext/libxcrypt/lib/util-xstrcpy.c +42 -0
- data/ext/libxcrypt/lib/xcrypt.h.in +58 -0
- data/ext/libxcrypt/libxcrypt.spec.rpkg +481 -0
- data/ext/libxcrypt/rpkg.conf +2 -0
- data/ext/libxcrypt/rpkg.macros +86 -0
- data/ext/libxcrypt/test/TestCommon.pm +326 -0
- data/ext/libxcrypt/test/alg-des.c +80 -0
- data/ext/libxcrypt/test/alg-gost3411-2012-hmac.c +90 -0
- data/ext/libxcrypt/test/alg-gost3411-2012.c +191 -0
- data/ext/libxcrypt/test/alg-hmac-sha1.c +187 -0
- data/ext/libxcrypt/test/alg-md4.c +111 -0
- data/ext/libxcrypt/test/alg-md5.c +134 -0
- data/ext/libxcrypt/test/alg-pbkdf-hmac-sha256.c +269 -0
- data/ext/libxcrypt/test/alg-sha1.c +111 -0
- data/ext/libxcrypt/test/alg-sha256.c +141 -0
- data/ext/libxcrypt/test/alg-sha512.c +170 -0
- data/ext/libxcrypt/test/alg-sm3-hmac.c +149 -0
- data/ext/libxcrypt/test/alg-sm3.c +168 -0
- data/ext/libxcrypt/test/alg-yescrypt.c +466 -0
- data/ext/libxcrypt/test/badsalt.c +726 -0
- data/ext/libxcrypt/test/badsetting.c +350 -0
- data/ext/libxcrypt/test/byteorder.c +254 -0
- data/ext/libxcrypt/test/checksalt.c +265 -0
- data/ext/libxcrypt/test/compile-strong-alias.c +43 -0
- data/ext/libxcrypt/test/crypt-badargs.c +392 -0
- data/ext/libxcrypt/test/crypt-gost-yescrypt.c +149 -0
- data/ext/libxcrypt/test/crypt-nested-call.c +180 -0
- data/ext/libxcrypt/test/crypt-sm3-yescrypt.c +149 -0
- data/ext/libxcrypt/test/crypt-too-long-phrase.c +157 -0
- data/ext/libxcrypt/test/des-cases.h +196 -0
- data/ext/libxcrypt/test/des-obsolete.c +206 -0
- data/ext/libxcrypt/test/des-obsolete_r.c +207 -0
- data/ext/libxcrypt/test/explicit-bzero.c +334 -0
- data/ext/libxcrypt/test/gensalt-bcrypt_x.c +54 -0
- data/ext/libxcrypt/test/gensalt-extradata.c +246 -0
- data/ext/libxcrypt/test/gensalt-nested-call.c +126 -0
- data/ext/libxcrypt/test/gensalt-nthash.c +65 -0
- data/ext/libxcrypt/test/gensalt.c +599 -0
- data/ext/libxcrypt/test/getrandom-fallbacks.c +295 -0
- data/ext/libxcrypt/test/getrandom-interface.c +211 -0
- data/ext/libxcrypt/test/ka-table-gen.py +945 -0
- data/ext/libxcrypt/test/ka-table.inc +5849 -0
- data/ext/libxcrypt/test/ka-tester.c +240 -0
- data/ext/libxcrypt/test/preferred-method.c +133 -0
- data/ext/libxcrypt/test/short-outbuf.c +119 -0
- data/ext/libxcrypt/test/special-char-salt.c +1160 -0
- data/ext/libxcrypt/test/symbols-compat.pl +137 -0
- data/ext/libxcrypt/test/symbols-renames.pl +107 -0
- data/ext/libxcrypt/test/symbols-static.pl +87 -0
- data/ext/xcrypt/xcrypt.c +9 -0
- data/lib/xcrypt/ffi.rb +76 -0
- data/lib/xcrypt/version.rb +5 -0
- data/lib/xcrypt.rb +89 -0
- metadata +267 -0
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Björn Esser <besser82 at fedoraproject.org>
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
* purpose with or without fee is hereby granted.
|
|
7
|
+
*
|
|
8
|
+
* THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
9
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
10
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
11
|
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
12
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
13
|
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
14
|
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
#include "crypt-port.h"
|
|
18
|
+
|
|
19
|
+
#if INCLUDE_sm3crypt || INCLUDE_sm3_yescrypt
|
|
20
|
+
|
|
21
|
+
#include "alg-sm3.h"
|
|
22
|
+
#include "byteorder.h"
|
|
23
|
+
|
|
24
|
+
#define ROTATE(a,n) (((a)<<(n))|(((a)&0xffffffff)>>(32-(n))))
|
|
25
|
+
|
|
26
|
+
#define P0(X) (X ^ ROTATE(X, 9) ^ ROTATE(X, 17))
|
|
27
|
+
#define P1(X) (X ^ ROTATE(X, 15) ^ ROTATE(X, 23))
|
|
28
|
+
|
|
29
|
+
#define FF0(X,Y,Z) (X ^ Y ^ Z)
|
|
30
|
+
#define GG0(X,Y,Z) (X ^ Y ^ Z)
|
|
31
|
+
|
|
32
|
+
#define FF1(X,Y,Z) ((X & Y) | ((X | Y) & Z))
|
|
33
|
+
#define GG1(X,Y,Z) ((Z ^ (X & (Y ^ Z))))
|
|
34
|
+
|
|
35
|
+
#define EXPAND(W0,W7,W13,W3,W10) \
|
|
36
|
+
(P1(W0 ^ W7 ^ ROTATE(W13, 15)) ^ ROTATE(W3, 7) ^ W10)
|
|
37
|
+
|
|
38
|
+
#define RND(A, B, C, D, E, F, G, H, TJ, Wi, Wj, FF, GG) \
|
|
39
|
+
do \
|
|
40
|
+
{ \
|
|
41
|
+
const uint32_t A12 = ROTATE(A, 12); \
|
|
42
|
+
const uint32_t A12_SM = A12 + E + TJ; \
|
|
43
|
+
const uint32_t SS1 = ROTATE(A12_SM, 7); \
|
|
44
|
+
const uint32_t TT1 = FF(A, B, C) + D + (SS1 ^ A12) + (Wj); \
|
|
45
|
+
const uint32_t TT2 = GG(E, F, G) + H + SS1 + Wi; \
|
|
46
|
+
B = ROTATE(B, 9); \
|
|
47
|
+
D = TT1; \
|
|
48
|
+
F = ROTATE(F, 19); \
|
|
49
|
+
H = P0(TT2); \
|
|
50
|
+
} \
|
|
51
|
+
while(0)
|
|
52
|
+
|
|
53
|
+
#define R1(A,B,C,D,E,F,G,H,TJ,Wi,Wj) \
|
|
54
|
+
RND(A,B,C,D,E,F,G,H,TJ,Wi,Wj,FF0,GG0)
|
|
55
|
+
|
|
56
|
+
#define R2(A,B,C,D,E,F,G,H,TJ,Wi,Wj) \
|
|
57
|
+
RND(A,B,C,D,E,F,G,H,TJ,Wi,Wj,FF1,GG1)
|
|
58
|
+
|
|
59
|
+
/*
|
|
60
|
+
* Encode a length len*2 vector of (uint32_t) into a length len*8 vector of
|
|
61
|
+
* (uint8_t) in big-endian form.
|
|
62
|
+
*/
|
|
63
|
+
static void
|
|
64
|
+
sm3_be32enc_vect(uint8_t * dst, const uint32_t * src, size_t len)
|
|
65
|
+
{
|
|
66
|
+
|
|
67
|
+
/* Encode vector, two words at a time. */
|
|
68
|
+
do
|
|
69
|
+
{
|
|
70
|
+
be32enc(&dst[0], src[0]);
|
|
71
|
+
be32enc(&dst[4], src[1]);
|
|
72
|
+
src += 2;
|
|
73
|
+
dst += 8;
|
|
74
|
+
}
|
|
75
|
+
while (--len);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/*
|
|
79
|
+
* Decode a big-endian length len*8 vector of (uint8_t) into a length
|
|
80
|
+
* len*2 vector of (uint32_t).
|
|
81
|
+
*/
|
|
82
|
+
static void
|
|
83
|
+
sm3_be32dec_vect(uint32_t * dst, const uint8_t * src, size_t len)
|
|
84
|
+
{
|
|
85
|
+
|
|
86
|
+
/* Decode vector, two words at a time. */
|
|
87
|
+
do
|
|
88
|
+
{
|
|
89
|
+
dst[0] = be32dec(&src[0]);
|
|
90
|
+
dst[1] = be32dec(&src[4]);
|
|
91
|
+
src += 8;
|
|
92
|
+
dst += 2;
|
|
93
|
+
}
|
|
94
|
+
while (--len);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
static void
|
|
98
|
+
sm3_transform(uint32_t state[static restrict 8],
|
|
99
|
+
const uint8_t block[static restrict 64],
|
|
100
|
+
uint32_t W[static restrict 64])
|
|
101
|
+
{
|
|
102
|
+
register uint32_t A, B, C, D, E, F, G, H;
|
|
103
|
+
uint32_t W00, W01, W02, W03, W04, W05, W06, W07,
|
|
104
|
+
W08, W09, W10, W11, W12, W13, W14, W15;
|
|
105
|
+
|
|
106
|
+
/* 1. Prepare the first part of the message schedule W. */
|
|
107
|
+
sm3_be32dec_vect(W, block, 8);
|
|
108
|
+
|
|
109
|
+
A = state[0];
|
|
110
|
+
B = state[1];
|
|
111
|
+
C = state[2];
|
|
112
|
+
D = state[3];
|
|
113
|
+
E = state[4];
|
|
114
|
+
F = state[5];
|
|
115
|
+
G = state[6];
|
|
116
|
+
H = state[7];
|
|
117
|
+
|
|
118
|
+
W00 = W[0];
|
|
119
|
+
W01 = W[1];
|
|
120
|
+
W02 = W[2];
|
|
121
|
+
W03 = W[3];
|
|
122
|
+
W04 = W[4];
|
|
123
|
+
W05 = W[5];
|
|
124
|
+
W06 = W[6];
|
|
125
|
+
W07 = W[7];
|
|
126
|
+
W08 = W[8];
|
|
127
|
+
W09 = W[9];
|
|
128
|
+
W10 = W[10];
|
|
129
|
+
W11 = W[11];
|
|
130
|
+
W12 = W[12];
|
|
131
|
+
W13 = W[13];
|
|
132
|
+
W14 = W[14];
|
|
133
|
+
W15 = W[15];
|
|
134
|
+
|
|
135
|
+
R1(A, B, C, D, E, F, G, H, 0x79CC4519, W00, W00 ^ W04);
|
|
136
|
+
W00 = EXPAND(W00, W07, W13, W03, W10);
|
|
137
|
+
R1(D, A, B, C, H, E, F, G, 0xF3988A32, W01, W01 ^ W05);
|
|
138
|
+
W01 = EXPAND(W01, W08, W14, W04, W11);
|
|
139
|
+
R1(C, D, A, B, G, H, E, F, 0xE7311465, W02, W02 ^ W06);
|
|
140
|
+
W02 = EXPAND(W02, W09, W15, W05, W12);
|
|
141
|
+
R1(B, C, D, A, F, G, H, E, 0xCE6228CB, W03, W03 ^ W07);
|
|
142
|
+
W03 = EXPAND(W03, W10, W00, W06, W13);
|
|
143
|
+
R1(A, B, C, D, E, F, G, H, 0x9CC45197, W04, W04 ^ W08);
|
|
144
|
+
W04 = EXPAND(W04, W11, W01, W07, W14);
|
|
145
|
+
R1(D, A, B, C, H, E, F, G, 0x3988A32F, W05, W05 ^ W09);
|
|
146
|
+
W05 = EXPAND(W05, W12, W02, W08, W15);
|
|
147
|
+
R1(C, D, A, B, G, H, E, F, 0x7311465E, W06, W06 ^ W10);
|
|
148
|
+
W06 = EXPAND(W06, W13, W03, W09, W00);
|
|
149
|
+
R1(B, C, D, A, F, G, H, E, 0xE6228CBC, W07, W07 ^ W11);
|
|
150
|
+
W07 = EXPAND(W07, W14, W04, W10, W01);
|
|
151
|
+
R1(A, B, C, D, E, F, G, H, 0xCC451979, W08, W08 ^ W12);
|
|
152
|
+
W08 = EXPAND(W08, W15, W05, W11, W02);
|
|
153
|
+
R1(D, A, B, C, H, E, F, G, 0x988A32F3, W09, W09 ^ W13);
|
|
154
|
+
W09 = EXPAND(W09, W00, W06, W12, W03);
|
|
155
|
+
R1(C, D, A, B, G, H, E, F, 0x311465E7, W10, W10 ^ W14);
|
|
156
|
+
W10 = EXPAND(W10, W01, W07, W13, W04);
|
|
157
|
+
R1(B, C, D, A, F, G, H, E, 0x6228CBCE, W11, W11 ^ W15);
|
|
158
|
+
W11 = EXPAND(W11, W02, W08, W14, W05);
|
|
159
|
+
R1(A, B, C, D, E, F, G, H, 0xC451979C, W12, W12 ^ W00);
|
|
160
|
+
W12 = EXPAND(W12, W03, W09, W15, W06);
|
|
161
|
+
R1(D, A, B, C, H, E, F, G, 0x88A32F39, W13, W13 ^ W01);
|
|
162
|
+
W13 = EXPAND(W13, W04, W10, W00, W07);
|
|
163
|
+
R1(C, D, A, B, G, H, E, F, 0x11465E73, W14, W14 ^ W02);
|
|
164
|
+
W14 = EXPAND(W14, W05, W11, W01, W08);
|
|
165
|
+
R1(B, C, D, A, F, G, H, E, 0x228CBCE6, W15, W15 ^ W03);
|
|
166
|
+
W15 = EXPAND(W15, W06, W12, W02, W09);
|
|
167
|
+
R2(A, B, C, D, E, F, G, H, 0x9D8A7A87, W00, W00 ^ W04);
|
|
168
|
+
W00 = EXPAND(W00, W07, W13, W03, W10);
|
|
169
|
+
R2(D, A, B, C, H, E, F, G, 0x3B14F50F, W01, W01 ^ W05);
|
|
170
|
+
W01 = EXPAND(W01, W08, W14, W04, W11);
|
|
171
|
+
R2(C, D, A, B, G, H, E, F, 0x7629EA1E, W02, W02 ^ W06);
|
|
172
|
+
W02 = EXPAND(W02, W09, W15, W05, W12);
|
|
173
|
+
R2(B, C, D, A, F, G, H, E, 0xEC53D43C, W03, W03 ^ W07);
|
|
174
|
+
W03 = EXPAND(W03, W10, W00, W06, W13);
|
|
175
|
+
R2(A, B, C, D, E, F, G, H, 0xD8A7A879, W04, W04 ^ W08);
|
|
176
|
+
W04 = EXPAND(W04, W11, W01, W07, W14);
|
|
177
|
+
R2(D, A, B, C, H, E, F, G, 0xB14F50F3, W05, W05 ^ W09);
|
|
178
|
+
W05 = EXPAND(W05, W12, W02, W08, W15);
|
|
179
|
+
R2(C, D, A, B, G, H, E, F, 0x629EA1E7, W06, W06 ^ W10);
|
|
180
|
+
W06 = EXPAND(W06, W13, W03, W09, W00);
|
|
181
|
+
R2(B, C, D, A, F, G, H, E, 0xC53D43CE, W07, W07 ^ W11);
|
|
182
|
+
W07 = EXPAND(W07, W14, W04, W10, W01);
|
|
183
|
+
R2(A, B, C, D, E, F, G, H, 0x8A7A879D, W08, W08 ^ W12);
|
|
184
|
+
W08 = EXPAND(W08, W15, W05, W11, W02);
|
|
185
|
+
R2(D, A, B, C, H, E, F, G, 0x14F50F3B, W09, W09 ^ W13);
|
|
186
|
+
W09 = EXPAND(W09, W00, W06, W12, W03);
|
|
187
|
+
R2(C, D, A, B, G, H, E, F, 0x29EA1E76, W10, W10 ^ W14);
|
|
188
|
+
W10 = EXPAND(W10, W01, W07, W13, W04);
|
|
189
|
+
R2(B, C, D, A, F, G, H, E, 0x53D43CEC, W11, W11 ^ W15);
|
|
190
|
+
W11 = EXPAND(W11, W02, W08, W14, W05);
|
|
191
|
+
R2(A, B, C, D, E, F, G, H, 0xA7A879D8, W12, W12 ^ W00);
|
|
192
|
+
W12 = EXPAND(W12, W03, W09, W15, W06);
|
|
193
|
+
R2(D, A, B, C, H, E, F, G, 0x4F50F3B1, W13, W13 ^ W01);
|
|
194
|
+
W13 = EXPAND(W13, W04, W10, W00, W07);
|
|
195
|
+
R2(C, D, A, B, G, H, E, F, 0x9EA1E762, W14, W14 ^ W02);
|
|
196
|
+
W14 = EXPAND(W14, W05, W11, W01, W08);
|
|
197
|
+
R2(B, C, D, A, F, G, H, E, 0x3D43CEC5, W15, W15 ^ W03);
|
|
198
|
+
W15 = EXPAND(W15, W06, W12, W02, W09);
|
|
199
|
+
R2(A, B, C, D, E, F, G, H, 0x7A879D8A, W00, W00 ^ W04);
|
|
200
|
+
W00 = EXPAND(W00, W07, W13, W03, W10);
|
|
201
|
+
R2(D, A, B, C, H, E, F, G, 0xF50F3B14, W01, W01 ^ W05);
|
|
202
|
+
W01 = EXPAND(W01, W08, W14, W04, W11);
|
|
203
|
+
R2(C, D, A, B, G, H, E, F, 0xEA1E7629, W02, W02 ^ W06);
|
|
204
|
+
W02 = EXPAND(W02, W09, W15, W05, W12);
|
|
205
|
+
R2(B, C, D, A, F, G, H, E, 0xD43CEC53, W03, W03 ^ W07);
|
|
206
|
+
W03 = EXPAND(W03, W10, W00, W06, W13);
|
|
207
|
+
R2(A, B, C, D, E, F, G, H, 0xA879D8A7, W04, W04 ^ W08);
|
|
208
|
+
W04 = EXPAND(W04, W11, W01, W07, W14);
|
|
209
|
+
R2(D, A, B, C, H, E, F, G, 0x50F3B14F, W05, W05 ^ W09);
|
|
210
|
+
W05 = EXPAND(W05, W12, W02, W08, W15);
|
|
211
|
+
R2(C, D, A, B, G, H, E, F, 0xA1E7629E, W06, W06 ^ W10);
|
|
212
|
+
W06 = EXPAND(W06, W13, W03, W09, W00);
|
|
213
|
+
R2(B, C, D, A, F, G, H, E, 0x43CEC53D, W07, W07 ^ W11);
|
|
214
|
+
W07 = EXPAND(W07, W14, W04, W10, W01);
|
|
215
|
+
R2(A, B, C, D, E, F, G, H, 0x879D8A7A, W08, W08 ^ W12);
|
|
216
|
+
W08 = EXPAND(W08, W15, W05, W11, W02);
|
|
217
|
+
R2(D, A, B, C, H, E, F, G, 0x0F3B14F5, W09, W09 ^ W13);
|
|
218
|
+
W09 = EXPAND(W09, W00, W06, W12, W03);
|
|
219
|
+
R2(C, D, A, B, G, H, E, F, 0x1E7629EA, W10, W10 ^ W14);
|
|
220
|
+
W10 = EXPAND(W10, W01, W07, W13, W04);
|
|
221
|
+
R2(B, C, D, A, F, G, H, E, 0x3CEC53D4, W11, W11 ^ W15);
|
|
222
|
+
W11 = EXPAND(W11, W02, W08, W14, W05);
|
|
223
|
+
R2(A, B, C, D, E, F, G, H, 0x79D8A7A8, W12, W12 ^ W00);
|
|
224
|
+
W12 = EXPAND(W12, W03, W09, W15, W06);
|
|
225
|
+
R2(D, A, B, C, H, E, F, G, 0xF3B14F50, W13, W13 ^ W01);
|
|
226
|
+
W13 = EXPAND(W13, W04, W10, W00, W07);
|
|
227
|
+
R2(C, D, A, B, G, H, E, F, 0xE7629EA1, W14, W14 ^ W02);
|
|
228
|
+
W14 = EXPAND(W14, W05, W11, W01, W08);
|
|
229
|
+
R2(B, C, D, A, F, G, H, E, 0xCEC53D43, W15, W15 ^ W03);
|
|
230
|
+
W15 = EXPAND(W15, W06, W12, W02, W09);
|
|
231
|
+
R2(A, B, C, D, E, F, G, H, 0x9D8A7A87, W00, W00 ^ W04);
|
|
232
|
+
W00 = EXPAND(W00, W07, W13, W03, W10);
|
|
233
|
+
R2(D, A, B, C, H, E, F, G, 0x3B14F50F, W01, W01 ^ W05);
|
|
234
|
+
W01 = EXPAND(W01, W08, W14, W04, W11);
|
|
235
|
+
R2(C, D, A, B, G, H, E, F, 0x7629EA1E, W02, W02 ^ W06);
|
|
236
|
+
W02 = EXPAND(W02, W09, W15, W05, W12);
|
|
237
|
+
R2(B, C, D, A, F, G, H, E, 0xEC53D43C, W03, W03 ^ W07);
|
|
238
|
+
W03 = EXPAND(W03, W10, W00, W06, W13);
|
|
239
|
+
R2(A, B, C, D, E, F, G, H, 0xD8A7A879, W04, W04 ^ W08);
|
|
240
|
+
R2(D, A, B, C, H, E, F, G, 0xB14F50F3, W05, W05 ^ W09);
|
|
241
|
+
R2(C, D, A, B, G, H, E, F, 0x629EA1E7, W06, W06 ^ W10);
|
|
242
|
+
R2(B, C, D, A, F, G, H, E, 0xC53D43CE, W07, W07 ^ W11);
|
|
243
|
+
R2(A, B, C, D, E, F, G, H, 0x8A7A879D, W08, W08 ^ W12);
|
|
244
|
+
R2(D, A, B, C, H, E, F, G, 0x14F50F3B, W09, W09 ^ W13);
|
|
245
|
+
R2(C, D, A, B, G, H, E, F, 0x29EA1E76, W10, W10 ^ W14);
|
|
246
|
+
R2(B, C, D, A, F, G, H, E, 0x53D43CEC, W11, W11 ^ W15);
|
|
247
|
+
R2(A, B, C, D, E, F, G, H, 0xA7A879D8, W12, W12 ^ W00);
|
|
248
|
+
R2(D, A, B, C, H, E, F, G, 0x4F50F3B1, W13, W13 ^ W01);
|
|
249
|
+
R2(C, D, A, B, G, H, E, F, 0x9EA1E762, W14, W14 ^ W02);
|
|
250
|
+
R2(B, C, D, A, F, G, H, E, 0x3D43CEC5, W15, W15 ^ W03);
|
|
251
|
+
|
|
252
|
+
state[0] ^= A;
|
|
253
|
+
state[1] ^= B;
|
|
254
|
+
state[2] ^= C;
|
|
255
|
+
state[3] ^= D;
|
|
256
|
+
state[4] ^= E;
|
|
257
|
+
state[5] ^= F;
|
|
258
|
+
state[6] ^= G;
|
|
259
|
+
state[7] ^= H;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/* Magic initialization constants. */
|
|
263
|
+
static const uint32_t initial_state[8] =
|
|
264
|
+
{
|
|
265
|
+
0x7380166f, 0x4914b2b9, 0x172442d7, 0xda8a0600,
|
|
266
|
+
0xa96f30bc, 0x163138aa, 0xe38dee4d, 0xb0fb0e4e
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* sm3_init(ctx):
|
|
271
|
+
* Initialize the SM3 context ${ctx}.
|
|
272
|
+
*/
|
|
273
|
+
void
|
|
274
|
+
sm3_init(sm3_ctx * ctx)
|
|
275
|
+
{
|
|
276
|
+
|
|
277
|
+
/* Zero bits processed so far. */
|
|
278
|
+
ctx->count = 0;
|
|
279
|
+
|
|
280
|
+
/* Initialize state. */
|
|
281
|
+
memcpy(ctx->state, initial_state, sizeof(initial_state));
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* sm3_update(ctx, in, len):
|
|
287
|
+
* Input ${len} bytes from ${in} into the SM3 context ${ctx}.
|
|
288
|
+
*/
|
|
289
|
+
static void
|
|
290
|
+
_sm3_update(sm3_ctx * ctx, const void * in, size_t len,
|
|
291
|
+
uint32_t tmp32[static restrict 72])
|
|
292
|
+
{
|
|
293
|
+
uint32_t r;
|
|
294
|
+
const uint8_t * src = in;
|
|
295
|
+
|
|
296
|
+
/* Return immediately if we have nothing to do. */
|
|
297
|
+
if (len == 0)
|
|
298
|
+
return;
|
|
299
|
+
|
|
300
|
+
/* Number of bytes left in the buffer from previous updates. */
|
|
301
|
+
r = (ctx->count >> 3) & 0x3f;
|
|
302
|
+
|
|
303
|
+
/* Update number of bits. */
|
|
304
|
+
ctx->count += (uint64_t)(len) << 3;
|
|
305
|
+
|
|
306
|
+
/* Handle the case where we don't need to perform any transforms. */
|
|
307
|
+
if (len < 64 - r)
|
|
308
|
+
{
|
|
309
|
+
memcpy(&ctx->buf[r], src, len);
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/* Finish the current block. */
|
|
314
|
+
memcpy(&ctx->buf[r], src, 64 - r);
|
|
315
|
+
sm3_transform(ctx->state, ctx->buf, &tmp32[0]);
|
|
316
|
+
src += 64 - r;
|
|
317
|
+
len -= 64 - r;
|
|
318
|
+
|
|
319
|
+
/* Perform complete blocks. */
|
|
320
|
+
while (len >= 64)
|
|
321
|
+
{
|
|
322
|
+
sm3_transform(ctx->state, src, &tmp32[0]);
|
|
323
|
+
src += 64;
|
|
324
|
+
len -= 64;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/* Copy left over data into buffer. */
|
|
328
|
+
memcpy(ctx->buf, src, len);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/* Wrapper function for intermediate-values sanitization. */
|
|
332
|
+
void
|
|
333
|
+
sm3_update(sm3_ctx * ctx, const void * in, size_t len)
|
|
334
|
+
{
|
|
335
|
+
uint32_t tmp32[72];
|
|
336
|
+
|
|
337
|
+
/* Call the real function. */
|
|
338
|
+
_sm3_update(ctx, in, len, tmp32);
|
|
339
|
+
|
|
340
|
+
/* Clean the stack. */
|
|
341
|
+
explicit_bzero(tmp32, 288);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
static const uint8_t PAD[64] =
|
|
345
|
+
{
|
|
346
|
+
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
347
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
348
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
349
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
/* Add padding and terminating bit-count. */
|
|
353
|
+
static void
|
|
354
|
+
sm3_pad(sm3_ctx * ctx, uint32_t tmp32[static restrict 72])
|
|
355
|
+
{
|
|
356
|
+
size_t r;
|
|
357
|
+
|
|
358
|
+
/* Figure out how many bytes we have buffered. */
|
|
359
|
+
r = (ctx->count >> 3) & 0x3f;
|
|
360
|
+
|
|
361
|
+
/* Pad to 56 mod 64, transforming if we finish a block en route. */
|
|
362
|
+
if (r < 56)
|
|
363
|
+
{
|
|
364
|
+
/* Pad to 56 mod 64. */
|
|
365
|
+
memcpy(&ctx->buf[r], PAD, 56 - r);
|
|
366
|
+
}
|
|
367
|
+
else
|
|
368
|
+
{
|
|
369
|
+
/* Finish the current block and mix. */
|
|
370
|
+
memcpy(&ctx->buf[r], PAD, 64 - r);
|
|
371
|
+
sm3_transform(ctx->state, ctx->buf, &tmp32[0]);
|
|
372
|
+
|
|
373
|
+
/* The start of the final block is all zeroes. */
|
|
374
|
+
memset(&ctx->buf[0], 0, 56);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/* Add the terminating bit-count. */
|
|
378
|
+
be64enc(&ctx->buf[56], ctx->count);
|
|
379
|
+
|
|
380
|
+
/* Mix in the final block. */
|
|
381
|
+
sm3_transform(ctx->state, ctx->buf, &tmp32[0]);
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* sm3_final(digest, ctx):
|
|
385
|
+
* Output the SM3 hash of the data input to the context ${ctx} into the
|
|
386
|
+
* buffer ${digest}.
|
|
387
|
+
*/
|
|
388
|
+
static void
|
|
389
|
+
_sm3_final(uint8_t digest[32], sm3_ctx * ctx,
|
|
390
|
+
uint32_t tmp32[static restrict 72])
|
|
391
|
+
{
|
|
392
|
+
|
|
393
|
+
/* Add padding. */
|
|
394
|
+
sm3_pad(ctx, tmp32);
|
|
395
|
+
|
|
396
|
+
/* Write the hash. */
|
|
397
|
+
sm3_be32enc_vect(digest, ctx->state, 4);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/* Wrapper function for intermediate-values sanitization. */
|
|
401
|
+
void
|
|
402
|
+
sm3_final(uint8_t digest[32], sm3_ctx * ctx)
|
|
403
|
+
{
|
|
404
|
+
uint32_t tmp32[72];
|
|
405
|
+
|
|
406
|
+
/* Call the real function. */
|
|
407
|
+
_sm3_final(digest, ctx, tmp32);
|
|
408
|
+
|
|
409
|
+
/* Clear the context state. */
|
|
410
|
+
explicit_bzero(ctx, sizeof(sm3_ctx));
|
|
411
|
+
|
|
412
|
+
/* Clean the stack. */
|
|
413
|
+
explicit_bzero(tmp32, 288);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* sm3_hash(in, len, digest, ctx):
|
|
418
|
+
* Compute the SM3 hash of ${len} bytes from ${in} and write it to ${digest},
|
|
419
|
+
* using the prepared context ${ctx}.
|
|
420
|
+
*/
|
|
421
|
+
void
|
|
422
|
+
sm3_hash(const void * in, size_t len, uint8_t digest[32], sm3_ctx * ctx)
|
|
423
|
+
{
|
|
424
|
+
uint32_t tmp32[72];
|
|
425
|
+
|
|
426
|
+
sm3_init(ctx);
|
|
427
|
+
_sm3_update(ctx, in, len, tmp32);
|
|
428
|
+
_sm3_final(digest, ctx, tmp32);
|
|
429
|
+
|
|
430
|
+
/* Clean the stack. */
|
|
431
|
+
explicit_bzero(tmp32, 288);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* sm3_buf(in, len, digest):
|
|
436
|
+
* Compute the SM3 hash of ${len} bytes from ${in} and write it to ${digest}.
|
|
437
|
+
*/
|
|
438
|
+
void
|
|
439
|
+
sm3_buf(const void * in, size_t len, uint8_t digest[32])
|
|
440
|
+
{
|
|
441
|
+
sm3_ctx ctx;
|
|
442
|
+
|
|
443
|
+
sm3_hash(in, len, digest, &ctx);
|
|
444
|
+
|
|
445
|
+
/* Clean the stack. */
|
|
446
|
+
explicit_bzero(&ctx, sizeof(sm3_ctx));
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
#endif /* INCLUDE_sm3crypt || INCLUDE_sm3_yescrypt */
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Björn Esser <besser82 at fedoraproject.org>
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
* purpose with or without fee is hereby granted.
|
|
7
|
+
*
|
|
8
|
+
* THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
9
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
10
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
11
|
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
12
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
13
|
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
14
|
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
#ifndef _CRYPT_ALG_SM3_H
|
|
18
|
+
#define _CRYPT_ALG_SM3_H
|
|
19
|
+
|
|
20
|
+
#include "crypt-port.h"
|
|
21
|
+
|
|
22
|
+
#include <stdint.h>
|
|
23
|
+
|
|
24
|
+
/* Context structure for SM3 operations. */
|
|
25
|
+
typedef struct
|
|
26
|
+
{
|
|
27
|
+
uint32_t state[8];
|
|
28
|
+
uint64_t count;
|
|
29
|
+
uint8_t buf[64];
|
|
30
|
+
} sm3_ctx;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* sm3_init(ctx):
|
|
34
|
+
* Initialize the SM3 context ${ctx}.
|
|
35
|
+
*/
|
|
36
|
+
extern void sm3_init(sm3_ctx *);
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* sm3_update(ctx, in, len):
|
|
40
|
+
* Input ${len} bytes from ${in} into the SM3 context ${ctx}.
|
|
41
|
+
*/
|
|
42
|
+
extern void sm3_update(sm3_ctx *, const void *, size_t);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* sm3_final(digest, ctx):
|
|
46
|
+
* Output the SM3 hash of the data input to the context ${ctx} into the
|
|
47
|
+
* buffer ${digest}.
|
|
48
|
+
*/
|
|
49
|
+
extern void sm3_final(uint8_t[32], sm3_ctx *);
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* sm3_hash(in, len, digest, ctx):
|
|
53
|
+
* Compute the SM3 hash of ${len} bytes from ${in} and write it to ${digest},
|
|
54
|
+
* using the prepared context ${ctx}.
|
|
55
|
+
*/
|
|
56
|
+
extern void sm3_hash(const void *, size_t, uint8_t[32], sm3_ctx *);
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* sm3_buf(in, len, digest):
|
|
60
|
+
* Compute the SM3 hash of ${len} bytes from ${in} and write it to ${digest}.
|
|
61
|
+
*/
|
|
62
|
+
extern void sm3_buf(const void *, size_t, uint8_t[32]);
|
|
63
|
+
#endif /* _CRYPT_ALG_SM3_H */
|