Changes for gcs2

This commit is contained in:
Baroukh Ovadia 2021-08-06 04:10:57 +00:00
parent 81f41b28c7
commit bed779239b
1 changed files with 5 additions and 2 deletions

View File

@ -70,15 +70,18 @@ void signtoken(char *token, int tokenlen,char *pkey, char *out) {
BIO *b = NULL; BIO *b = NULL;
RSA *r = NULL; RSA *r = NULL;
unsigned int sig_len; unsigned int sig_len;
unsigned char *digest = SHA256((const unsigned char *) token, tokenlen, NULL); unsigned char *md = malloc(SHA256_DIGEST_LENGTH * sizeof(char));
unsigned char *digest = SHA256((const unsigned char *) token, tokenlen, md);
b = BIO_new_mem_buf(pkey, -1); b = BIO_new_mem_buf(pkey, -1);
r = PEM_read_bio_RSAPrivateKey(b, NULL, NULL, NULL); r = PEM_read_bio_RSAPrivateKey(b, NULL, NULL, NULL);
BIO_set_close(b, BIO_CLOSE); BIO_set_close(b, BIO_CLOSE);
BIO_free(b); BIO_free(b);
sig = malloc(RSA_size(r)); sig = malloc(RSA_size(r));
RSA_sign(NID_sha256, digest, SHA256_DIGEST_LENGTH, sig, &sig_len, r); RSA_sign(NID_sha256, digest, sizeof(char) * SHA256_DIGEST_LENGTH, sig, &sig_len, r);
switch_b64_encode(sig,(switch_size_t) sizeof(char) * sig_len,(unsigned char *) out, 343 * sizeof(char)); switch_b64_encode(sig,(switch_size_t) sizeof(char) * sig_len,(unsigned char *) out, 343 * sizeof(char));
free(sig); free(sig);
free(md);
RSA_free(r);
} }
char *gcs_auth_request(char *content, char *url); char *gcs_auth_request(char *content, char *url);