mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-06-25 03:27:12 +02:00
Add MariaDB Connector/C as a built-in alternative (v3.2.3).
This commit is contained in:
36
vendor/MDBC/plugins/auth/ref10/open.c
vendored
Normal file
36
vendor/MDBC/plugins/auth/ref10/open.c
vendored
Normal file
@ -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;
|
||||
}
|
Reference in New Issue
Block a user