Projects
Eulaceura:Factory
liboauth
_service:obs_scm:backport-Update-OpenSSL-1.1.0-...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:backport-Update-OpenSSL-1.1.0-API.patch of Package liboauth
From acb7538ac1b70029ea1560a4338ae5a0b770c75e Mon Sep 17 00:00:00 2001 From: Robin Gareus <robin@gareus.org> Date: Sun, 27 Jan 2019 09:31:50 +0100 Subject: [PATCH] Update OpenSSL 1.1.0 API --- src/hash.c | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/src/hash.c b/src/hash.c index b7c016b..5e59047 100644 --- a/src/hash.c +++ b/src/hash.c @@ -388,7 +388,7 @@ char *oauth_sign_rsa_sha1 (const char *m, const char *k) { unsigned char *sig = NULL; unsigned char *passphrase = NULL; unsigned int len=0; - EVP_MD_CTX md_ctx; + EVP_MD_CTX* md_ctx = EVP_MD_CTX_create(); EVP_PKEY *pkey; BIO *in; @@ -404,21 +404,23 @@ char *oauth_sign_rsa_sha1 (const char *m, const char *k) { len = EVP_PKEY_size(pkey); sig = (unsigned char*)xmalloc((len+1)*sizeof(char)); - EVP_SignInit(&md_ctx, EVP_sha1()); - EVP_SignUpdate(&md_ctx, m, strlen(m)); - if (EVP_SignFinal (&md_ctx, sig, &len, pkey)) { + EVP_SignInit(md_ctx, EVP_sha1()); + EVP_SignUpdate(md_ctx, m, strlen(m)); + if (EVP_SignFinal (md_ctx, sig, &len, pkey)) { char *tmp; sig[len] = '\0'; tmp = oauth_encode_base64(len,sig); OPENSSL_free(sig); EVP_PKEY_free(pkey); + EVP_MD_CTX_destroy (md_ctx); return tmp; } + EVP_MD_CTX_destroy (md_ctx); return xstrdup("liboauth/OpenSSL: rsa-sha1 signing failed"); } int oauth_verify_rsa_sha1 (const char *m, const char *c, const char *s) { - EVP_MD_CTX md_ctx; + EVP_MD_CTX* md_ctx = EVP_MD_CTX_create(); EVP_PKEY *pkey; BIO *in; X509 *cert = NULL; @@ -442,10 +444,10 @@ int oauth_verify_rsa_sha1 (const char *m, const char *c, const char *s) { b64d= (unsigned char*) xmalloc(sizeof(char)*strlen(s)); slen = oauth_decode_base64(b64d, s); - EVP_VerifyInit(&md_ctx, EVP_sha1()); - EVP_VerifyUpdate(&md_ctx, m, strlen(m)); - err = EVP_VerifyFinal(&md_ctx, b64d, slen, pkey); - EVP_MD_CTX_cleanup(&md_ctx); + EVP_VerifyInit(md_ctx, EVP_sha1()); + EVP_VerifyUpdate(md_ctx, m, strlen(m)); + err = EVP_VerifyFinal(md_ctx, b64d, slen, pkey); + EVP_MD_CTX_destroy(md_ctx); EVP_PKEY_free(pkey); xfree(b64d); return (err); @@ -457,35 +459,35 @@ int oauth_verify_rsa_sha1 (const char *m, const char *c, const char *s) { */ char *oauth_body_hash_file(char *filename) { unsigned char fb[BUFSIZ]; - EVP_MD_CTX ctx; + EVP_MD_CTX* ctx = EVP_MD_CTX_create(); size_t len=0; unsigned char *md; FILE *F= fopen(filename, "r"); if (!F) return NULL; - EVP_MD_CTX_init(&ctx); - EVP_DigestInit(&ctx,EVP_sha1()); + EVP_MD_CTX_init(ctx); + EVP_DigestInit(ctx,EVP_sha1()); while (!feof(F) && (len=fread(fb,sizeof(char),BUFSIZ, F))>0) { - EVP_DigestUpdate(&ctx, fb, len); + EVP_DigestUpdate(ctx, fb, len); } fclose(F); len=0; md=(unsigned char*) xcalloc(EVP_MD_size(EVP_sha1()),sizeof(unsigned char)); - EVP_DigestFinal(&ctx, md,(unsigned int*) &len); - EVP_MD_CTX_cleanup(&ctx); + EVP_DigestFinal(ctx, md,(unsigned int*) &len); + EVP_MD_CTX_destroy(ctx); return oauth_body_hash_encode(len, md); } char *oauth_body_hash_data(size_t length, const char *data) { - EVP_MD_CTX ctx; + EVP_MD_CTX* ctx = EVP_MD_CTX_create(); size_t len=0; unsigned char *md; md=(unsigned char*) xcalloc(EVP_MD_size(EVP_sha1()),sizeof(unsigned char)); - EVP_MD_CTX_init(&ctx); - EVP_DigestInit(&ctx,EVP_sha1()); - EVP_DigestUpdate(&ctx, data, length); - EVP_DigestFinal(&ctx, md,(unsigned int*) &len); - EVP_MD_CTX_cleanup(&ctx); + EVP_MD_CTX_init(ctx); + EVP_DigestInit(ctx,EVP_sha1()); + EVP_DigestUpdate(ctx, data, length); + EVP_DigestFinal(ctx, md,(unsigned int*) &len); + EVP_MD_CTX_destroy(ctx); return oauth_body_hash_encode(len, md); } -- 2.33.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2