Skip to content

Commit a1b7057

Browse files
committed
digest: rename GetDigestPtr() to ossl_evp_get_digestbyname()
Similar to the previous one for GetCipherPtr(), GetDigest() and GetDigestPtr() have been completely different. Let's disambiguate them.
1 parent 679b6f4 commit a1b7057

File tree

12 files changed

+22
-21
lines changed

12 files changed

+22
-21
lines changed

ext/openssl/ossl_cipher.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ ossl_cipher_pkcs5_keyivgen(int argc, VALUE *argv, VALUE self)
317317
salt = (unsigned char *)RSTRING_PTR(vsalt);
318318
}
319319
iter = NIL_P(viter) ? 2048 : NUM2INT(viter);
320-
digest = NIL_P(vdigest) ? EVP_md5() : GetDigestPtr(vdigest);
320+
digest = NIL_P(vdigest) ? EVP_md5() : ossl_evp_get_digestbyname(vdigest);
321321
GetCipher(self, ctx);
322322
EVP_BytesToKey(EVP_CIPHER_CTX_cipher(ctx), digest, salt,
323323
(unsigned char *)RSTRING_PTR(vpass), RSTRING_LENINT(vpass), iter, key, iv);

ext/openssl/ossl_digest.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static const rb_data_type_t ossl_digest_type = {
4242
* Public
4343
*/
4444
const EVP_MD *
45-
GetDigestPtr(VALUE obj)
45+
ossl_evp_get_digestbyname(VALUE obj)
4646
{
4747
const EVP_MD *md;
4848
ASN1_OBJECT *oid = NULL;
@@ -123,7 +123,7 @@ ossl_digest_initialize(int argc, VALUE *argv, VALUE self)
123123
VALUE type, data;
124124

125125
rb_scan_args(argc, argv, "11", &type, &data);
126-
md = GetDigestPtr(type);
126+
md = ossl_evp_get_digestbyname(type);
127127
if (!NIL_P(data)) StringValue(data);
128128

129129
TypedData_Get_Struct(self, EVP_MD_CTX, &ossl_digest_type, ctx);

ext/openssl/ossl_digest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
extern VALUE cDigest;
1414
extern VALUE eDigestError;
1515

16-
const EVP_MD *GetDigestPtr(VALUE);
16+
const EVP_MD *ossl_evp_get_digestbyname(VALUE);
1717
VALUE ossl_digest_new(const EVP_MD *);
1818
void Init_ossl_digest(void);
1919

ext/openssl/ossl_hmac.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ ossl_hmac_initialize(VALUE self, VALUE key, VALUE digest)
106106
StringValue(key);
107107
GetHMAC(self, ctx);
108108
HMAC_Init_ex(ctx, RSTRING_PTR(key), RSTRING_LENINT(key),
109-
GetDigestPtr(digest), NULL);
109+
ossl_evp_get_digestbyname(digest), NULL);
110110

111111
return self;
112112
}
@@ -281,8 +281,9 @@ ossl_hmac_s_digest(VALUE klass, VALUE digest, VALUE key, VALUE data)
281281

282282
StringValue(key);
283283
StringValue(data);
284-
buf = HMAC(GetDigestPtr(digest), RSTRING_PTR(key), RSTRING_LENINT(key),
285-
(unsigned char *)RSTRING_PTR(data), RSTRING_LEN(data), NULL, &buf_len);
284+
buf = HMAC(ossl_evp_get_digestbyname(digest), RSTRING_PTR(key),
285+
RSTRING_LENINT(key), (unsigned char *)RSTRING_PTR(data),
286+
RSTRING_LEN(data), NULL, &buf_len);
286287

287288
return rb_str_new((const char *)buf, buf_len);
288289
}
@@ -314,9 +315,9 @@ ossl_hmac_s_hexdigest(VALUE klass, VALUE digest, VALUE key, VALUE data)
314315
StringValue(key);
315316
StringValue(data);
316317

317-
if (!HMAC(GetDigestPtr(digest), RSTRING_PTR(key), RSTRING_LENINT(key),
318-
(unsigned char *)RSTRING_PTR(data), RSTRING_LEN(data),
319-
buf, &buf_len))
318+
if (!HMAC(ossl_evp_get_digestbyname(digest), RSTRING_PTR(key),
319+
RSTRING_LENINT(key), (unsigned char *)RSTRING_PTR(data),
320+
RSTRING_LEN(data), buf, &buf_len))
320321
ossl_raise(eHMACError, "HMAC");
321322

322323
ret = rb_str_new(NULL, buf_len * 2);

ext/openssl/ossl_kdf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ kdf_pbkdf2_hmac(int argc, VALUE *argv, VALUE self)
5252
salt = StringValue(kwargs[0]);
5353
iters = NUM2INT(kwargs[1]);
5454
len = NUM2INT(kwargs[2]);
55-
md = GetDigestPtr(kwargs[3]);
55+
md = ossl_evp_get_digestbyname(kwargs[3]);
5656

5757
str = rb_str_new(0, len);
5858
if (!PKCS5_PBKDF2_HMAC(RSTRING_PTR(pass), RSTRING_LENINT(pass),

ext/openssl/ossl_ns_spki.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ ossl_spki_sign(VALUE self, VALUE key, VALUE digest)
284284
const EVP_MD *md;
285285

286286
pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
287-
md = GetDigestPtr(digest);
287+
md = ossl_evp_get_digestbyname(digest);
288288
GetSPKI(self, spki);
289289
if (!NETSCAPE_SPKI_sign(spki, pkey, md)) {
290290
ossl_raise(eSPKIError, NULL);

ext/openssl/ossl_ocsp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ ossl_ocspreq_sign(int argc, VALUE *argv, VALUE self)
384384
if (NIL_P(digest))
385385
md = EVP_sha1();
386386
else
387-
md = GetDigestPtr(digest);
387+
md = ossl_evp_get_digestbyname(digest);
388388
if (NIL_P(certs))
389389
flg |= OCSP_NOCERTS;
390390
else
@@ -1016,7 +1016,7 @@ ossl_ocspbres_sign(int argc, VALUE *argv, VALUE self)
10161016
if (NIL_P(digest))
10171017
md = EVP_sha1();
10181018
else
1019-
md = GetDigestPtr(digest);
1019+
md = ossl_evp_get_digestbyname(digest);
10201020
if (NIL_P(certs))
10211021
flg |= OCSP_NOCERTS;
10221022
else
@@ -1496,7 +1496,7 @@ ossl_ocspcid_initialize(int argc, VALUE *argv, VALUE self)
14961496

14971497
x509s = GetX509CertPtr(subject); /* NO NEED TO DUP */
14981498
x509i = GetX509CertPtr(issuer); /* NO NEED TO DUP */
1499-
md = !NIL_P(digest) ? GetDigestPtr(digest) : NULL;
1499+
md = !NIL_P(digest) ? ossl_evp_get_digestbyname(digest) : NULL;
15001500

15011501
newid = OCSP_cert_to_id(md, x509s, x509i);
15021502
if (!newid)

ext/openssl/ossl_pkcs7.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ ossl_pkcs7si_initialize(VALUE self, VALUE cert, VALUE key, VALUE digest)
921921

922922
pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
923923
x509 = GetX509CertPtr(cert); /* NO NEED TO DUP */
924-
md = GetDigestPtr(digest);
924+
md = ossl_evp_get_digestbyname(digest);
925925
GetPKCS7si(self, p7si);
926926
if (!(PKCS7_SIGNER_INFO_set(p7si, x509, pkey, (EVP_MD*)md))) {
927927
ossl_raise(ePKCS7Error, NULL);

ext/openssl/ossl_pkey.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ ossl_pkey_sign(VALUE self, VALUE digest, VALUE data)
298298
int result;
299299

300300
pkey = GetPrivPKeyPtr(self);
301-
md = GetDigestPtr(digest);
301+
md = ossl_evp_get_digestbyname(digest);
302302
StringValue(data);
303303
str = rb_str_new(0, EVP_PKEY_size(pkey));
304304

@@ -353,7 +353,7 @@ ossl_pkey_verify(VALUE self, VALUE digest, VALUE sig, VALUE data)
353353

354354
GetPKey(self, pkey);
355355
pkey_check_public_key(pkey);
356-
md = GetDigestPtr(digest);
356+
md = ossl_evp_get_digestbyname(digest);
357357
StringValue(sig);
358358
siglen = RSTRING_LENINT(sig);
359359
StringValue(data);

ext/openssl/ossl_x509cert.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ ossl_x509_sign(VALUE self, VALUE key, VALUE digest)
569569
const EVP_MD *md;
570570

571571
pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
572-
md = GetDigestPtr(digest);
572+
md = ossl_evp_get_digestbyname(digest);
573573
GetX509(self, x509);
574574
if (!X509_sign(x509, pkey, md)) {
575575
ossl_raise(eX509CertError, NULL);

0 commit comments

Comments
 (0)