diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:07:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:07:14 +0000 |
commit | a175314c3e5827eb193872241446f2f8f5c9d33c (patch) | |
tree | cd3d60ca99ae00829c52a6ca79150a5b6e62528b /libmariadb/plugins/auth/ref10/open.c | |
parent | Initial commit. (diff) | |
download | mariadb-10.5-upstream.tar.xz mariadb-10.5-upstream.zip |
Adding upstream version 1:10.5.12.upstream/1%10.5.12upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libmariadb/plugins/auth/ref10/open.c')
-rw-r--r-- | libmariadb/plugins/auth/ref10/open.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/libmariadb/plugins/auth/ref10/open.c b/libmariadb/plugins/auth/ref10/open.c new file mode 100644 index 00000000..7362b681 --- /dev/null +++ b/libmariadb/plugins/auth/ref10/open.c @@ -0,0 +1,36 @@ +#include <string.h> +#include "crypto_sign.h" +#include "crypto_hash_sha512.h" +#include "crypto_verify_32.h" +#include "ge.h" +#include "sc.h" + +int crypto_sign_open( + unsigned char *sm, unsigned long long smlen, + const unsigned char *pk +) +{ + unsigned char scopy[32]; + unsigned char h[64]; + unsigned char rcheck[32]; + ge_p3 A; + ge_p2 R; + + if (smlen < 64) goto badsig; + if (sm[63] & 224) goto badsig; + if (ge_frombytes_negate_vartime(&A,pk) != 0) goto badsig; + + memmove(scopy,sm + 32,32); + + memmove(sm + 32,pk,32); + crypto_hash_sha512(h,sm,smlen); + sc_reduce(h); + + ge_double_scalarmult_vartime(&R,h,&A,scopy); + ge_tobytes(rcheck,&R); + if (crypto_verify_32(rcheck,sm) == 0) + return 0; + +badsig: + return -1; +} |