diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2016-05-17 21:48:48 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2016-05-17 21:48:48 +0900 |
commit | 017496151f7e41a17913b267bc9de5ab8318b5e5 (patch) | |
tree | ce28e8e7d75bc0c659011b81fa1ae313ea01545a /ext/openssl/ossl_hmac.c | |
parent | 384e12804a987ce1d0dcf64a009f2dd82a679509 (diff) | |
download | ruby-topic/openssl-doc.tar.gz |
fixup! ext/openssl: small cleanupstopic/openssl-doc
Diffstat (limited to 'ext/openssl/ossl_hmac.c')
-rw-r--r-- | ext/openssl/ossl_hmac.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/ext/openssl/ossl_hmac.c b/ext/openssl/ossl_hmac.c index 5513cb20de..59d60af791 100644 --- a/ext/openssl/ossl_hmac.c +++ b/ext/openssl/ossl_hmac.c @@ -215,20 +215,12 @@ ossl_hmac_hexdigest(VALUE self) { HMAC_CTX *ctx; unsigned char *buf; - char *hexbuf; unsigned int buf_len; - VALUE hexdigest; GetHMAC(self, ctx); hmac_final(ctx, &buf, &buf_len); - if (string2hex(buf, buf_len, &hexbuf, NULL) != 2 * (int)buf_len) { - OPENSSL_free(buf); - ossl_raise(eHMACError, "Memory alloc error"); - } - OPENSSL_free(buf); - hexdigest = ossl_buf2str(hexbuf, 2 * buf_len); - return hexdigest; + return ossl_buf2hexstr(buf, buf_len); } /* @@ -313,13 +305,13 @@ static VALUE ossl_hmac_s_hexdigest(VALUE klass, VALUE digest, VALUE key, VALUE data) { unsigned char *buf; - char *hexbuf; unsigned int buf_len; VALUE hexdigest; StringValue(key); StringValue(data); + /* buf is static buffer */ buf = HMAC(GetDigestPtr(digest), RSTRING_PTR(key), RSTRING_LENINT(key), (unsigned char *)RSTRING_PTR(data), RSTRING_LEN(data), NULL, &buf_len); if (string2hex(buf, buf_len, &hexbuf, NULL) != 2 * (int)buf_len) { |