diff options
author | Kamil Dudka <kdudka@redhat.com> | 2012-11-13 13:09:43 +0100 |
---|---|---|
committer | Kamil Dudka <kdudka@redhat.com> | 2012-11-13 13:17:45 +0100 |
commit | 1099f3a0715f2bad376915122dba2922c33620a3 (patch) | |
tree | 709addb3298fffa7ca0e9e81a91dcfb58fd415bf /src/tool_metalink.c | |
parent | 6a4bdb027bb7d44ba33dc00ef4c0a19f929c55fd (diff) | |
download | curl-1099f3a0715f2bad376915122dba2922c33620a3.tar.gz |
tool_metalink: fix error detection of hash alg initialization
The {MD5,SHA1,SHA256}_Init functions from OpenSSL are called directly
without any wrappers and they return 1 for success, 0 otherwise. Hence,
we have to use the same approach in all the wrapper functions that are
used for the other crypto libraries.
This commit fixes a regression introduced in commit dca8ae5f.
Diffstat (limited to 'src/tool_metalink.c')
-rw-r--r-- | src/tool_metalink.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/tool_metalink.c b/src/tool_metalink.c index bf4bd107f..42b514ca3 100644 --- a/src/tool_metalink.c +++ b/src/tool_metalink.c @@ -124,7 +124,7 @@ struct win32_crypto_hash { static int MD5_Init(MD5_CTX *ctx) { md5_init(ctx); - return 0; + return 1; } static void MD5_Update(MD5_CTX *ctx, @@ -142,7 +142,7 @@ static void MD5_Final(unsigned char digest[16], MD5_CTX *ctx) static int SHA1_Init(SHA_CTX *ctx) { sha1_init(ctx); - return 0; + return 1; } static void SHA1_Update(SHA_CTX *ctx, @@ -160,7 +160,7 @@ static void SHA1_Final(unsigned char digest[20], SHA_CTX *ctx) static int SHA256_Init(SHA256_CTX *ctx) { sha256_init(ctx); - return 0; + return 1; } static void SHA256_Update(SHA256_CTX *ctx, @@ -180,7 +180,7 @@ static void SHA256_Final(unsigned char digest[32], SHA256_CTX *ctx) static int MD5_Init(MD5_CTX *ctx) { gcry_md_open(ctx, GCRY_MD_MD5, 0); - return 0; + return 1; } static void MD5_Update(MD5_CTX *ctx, @@ -199,7 +199,7 @@ static void MD5_Final(unsigned char digest[16], MD5_CTX *ctx) static int SHA1_Init(SHA_CTX *ctx) { gcry_md_open(ctx, GCRY_MD_SHA1, 0); - return 0; + return 1; } static void SHA1_Update(SHA_CTX *ctx, @@ -218,7 +218,7 @@ static void SHA1_Final(unsigned char digest[20], SHA_CTX *ctx) static int SHA256_Init(SHA256_CTX *ctx) { gcry_md_open(ctx, GCRY_MD_SHA256, 0); - return 0; + return 1; } static void SHA256_Update(SHA256_CTX *ctx, @@ -253,15 +253,15 @@ static int nss_hash_init(void **pctx, SECOidTag hash_alg) ctx = PK11_CreateDigestContext(hash_alg); if(!ctx) - return -1; + return /* failure */ 0; if(PK11_DigestBegin(ctx) != SECSuccess) { PK11_DestroyContext(ctx, PR_TRUE); - return -1; + return /* failure */ 0; } *pctx = ctx; - return 0; + return /* success */ 1; } static void nss_hash_final(void **pctx, unsigned char *out, unsigned int len) @@ -345,7 +345,7 @@ static int MD5_Init(MD5_CTX *ctx) PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) { CryptCreateHash(ctx->hCryptProv, CALG_MD5, 0, 0, &ctx->hHash); } - return 0; + return 1; } static void MD5_Update(MD5_CTX *ctx, @@ -366,7 +366,7 @@ static int SHA1_Init(SHA_CTX *ctx) PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) { CryptCreateHash(ctx->hCryptProv, CALG_SHA1, 0, 0, &ctx->hHash); } - return 0; + return 1; } static void SHA1_Update(SHA_CTX *ctx, @@ -387,7 +387,7 @@ static int SHA256_Init(SHA256_CTX *ctx) PROV_RSA_AES, CRYPT_VERIFYCONTEXT)) { CryptCreateHash(ctx->hCryptProv, CALG_SHA_256, 0, 0, &ctx->hHash); } - return 0; + return 1; } static void SHA256_Update(SHA256_CTX *ctx, @@ -481,7 +481,7 @@ digest_context *Curl_digest_init(const digest_params *dparams) ctxt->digest_hash = dparams; - if(dparams->digest_init(ctxt->digest_hashctx) != 0) { + if(dparams->digest_init(ctxt->digest_hashctx) != 1) { free(ctxt); return NULL; } |