From e35205a0c4f8d80dc9e878049a0fb0eb18f61dbf Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 23 Jun 2017 01:04:56 +0200 Subject: vtls: move md5sum into the Curl_ssl struct The MD5 summing is also an SSL backend-specific function. So let's include it, offering the previous fall-back code as a separate function now: Curl_none_md5sum(). To allow for that, the signature had to be changed so that an error could be returned from the implementation (Curl_none_md5sum() can run out of memory). Signed-off-by: Johannes Schindelin --- lib/vtls/nss.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'lib/vtls/nss.c') diff --git a/lib/vtls/nss.c b/lib/vtls/nss.c index 17109b48d..9490549a9 100644 --- a/lib/vtls/nss.c +++ b/lib/vtls/nss.c @@ -2278,10 +2278,10 @@ CURLcode Curl_nss_random(struct Curl_easy *data, return CURLE_OK; } -void Curl_nss_md5sum(unsigned char *tmp, /* input */ - size_t tmplen, - unsigned char *md5sum, /* output */ - size_t md5len) +static CURLcode Curl_nss_md5sum(unsigned char *tmp, /* input */ + size_t tmplen, + unsigned char *md5sum, /* output */ + size_t md5len) { PK11Context *MD5pw = PK11_CreateDigestContext(SEC_OID_MD5); unsigned int MD5out; @@ -2289,6 +2289,8 @@ void Curl_nss_md5sum(unsigned char *tmp, /* input */ PK11_DigestOp(MD5pw, tmp, curlx_uztoui(tmplen)); PK11_DigestFinal(MD5pw, md5sum, &MD5out, curlx_uztoui(md5len)); PK11_DestroyContext(MD5pw, PR_TRUE); + + return CURLE_OK; } void Curl_nss_sha256sum(const unsigned char *tmp, /* input */ @@ -2343,7 +2345,8 @@ const struct Curl_ssl Curl_ssl_nss = { Curl_none_set_engine, /* set_engine */ Curl_none_set_engine_default, /* set_engine_default */ Curl_none_engines_list, /* engines_list */ - Curl_nss_false_start /* false_start */ + Curl_nss_false_start, /* false_start */ + Curl_nss_md5sum /* md5sum */ }; const struct Curl_ssl *Curl_ssl = &Curl_ssl_nss; -- cgit v1.2.3