mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-10 03:50:38 +03:00
Backported from xs.
This commit is contained in:
parent
acb4bcd80f
commit
7255086401
@ -185,7 +185,6 @@ d_char *xs_evp_sign(char *secret, char *mem, int size)
|
|||||||
unsigned char *sig;
|
unsigned char *sig;
|
||||||
unsigned int sig_len;
|
unsigned int sig_len;
|
||||||
EVP_PKEY *pkey;
|
EVP_PKEY *pkey;
|
||||||
|
|
||||||
EVP_MD_CTX *mdctx;
|
EVP_MD_CTX *mdctx;
|
||||||
const EVP_MD *md;
|
const EVP_MD *md;
|
||||||
|
|
||||||
@ -193,6 +192,10 @@ d_char *xs_evp_sign(char *secret, char *mem, int size)
|
|||||||
b = BIO_new_mem_buf(secret, strlen(secret));
|
b = BIO_new_mem_buf(secret, strlen(secret));
|
||||||
pkey = PEM_read_bio_PrivateKey(b, NULL, NULL, NULL);
|
pkey = PEM_read_bio_PrivateKey(b, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
/* I've learnt all these magical incantations by watching
|
||||||
|
the Python module code and the OpenSSL manual pages */
|
||||||
|
/* Well, "learnt" may be an exaggeration */
|
||||||
|
|
||||||
md = EVP_get_digestbyname("sha256");
|
md = EVP_get_digestbyname("sha256");
|
||||||
|
|
||||||
mdctx = EVP_MD_CTX_new();
|
mdctx = EVP_MD_CTX_new();
|
||||||
@ -207,7 +210,6 @@ d_char *xs_evp_sign(char *secret, char *mem, int size)
|
|||||||
signature = xs_base64_enc((char *)sig, sig_len);
|
signature = xs_base64_enc((char *)sig, sig_len);
|
||||||
|
|
||||||
EVP_MD_CTX_free(mdctx);
|
EVP_MD_CTX_free(mdctx);
|
||||||
|
|
||||||
BIO_free(b);
|
BIO_free(b);
|
||||||
free(sig);
|
free(sig);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user