Skip to content

Commit

Permalink
cipher: rename GetCipherPtr() to ossl_evp_get_cipherbyname()
Browse files Browse the repository at this point in the history
While GetCipherPtr() function gets a const EVP_CIPHER * from algorithm
name, GetCipher() macro that is locally defined in
ext/openssl/ossl_cipher.c gets the EVP_CIPHER_CTX from an
OpenSSL::Cipher object. They are completely different things. Rename
GetCipherPtr() for disambiguation.
  • Loading branch information
rhenium committed May 2, 2017
1 parent 6a14a59 commit 679b6f4
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ext/openssl/ossl_cipher.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static const rb_data_type_t ossl_cipher_type = {
* PUBLIC
*/
const EVP_CIPHER *
GetCipherPtr(VALUE obj)
ossl_evp_get_cipherbyname(VALUE obj)
{
if (rb_obj_is_kind_of(obj, cCipher)) {
EVP_CIPHER_CTX *ctx;
Expand Down
2 changes: 1 addition & 1 deletion ext/openssl/ossl_cipher.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
extern VALUE cCipher;
extern VALUE eCipherError;

const EVP_CIPHER *GetCipherPtr(VALUE);
const EVP_CIPHER *ossl_evp_get_cipherbyname(VALUE);
VALUE ossl_cipher_new(const EVP_CIPHER *);
void Init_ossl_cipher(void);

Expand Down
4 changes: 2 additions & 2 deletions ext/openssl/ossl_pkcs7.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ ossl_pkcs7_s_encrypt(int argc, VALUE *argv, VALUE klass)
#endif

}
else ciph = GetCipherPtr(cipher); /* NO NEED TO DUP */
else ciph = ossl_evp_get_cipherbyname(cipher);
flg = NIL_P(flags) ? 0 : NUM2INT(flags);
ret = NewPKCS7(cPKCS7);
in = ossl_obj2bio(data);
Expand Down Expand Up @@ -525,7 +525,7 @@ ossl_pkcs7_set_cipher(VALUE self, VALUE cipher)
PKCS7 *pkcs7;

GetPKCS7(self, pkcs7);
if (!PKCS7_set_cipher(pkcs7, GetCipherPtr(cipher))) {
if (!PKCS7_set_cipher(pkcs7, ossl_evp_get_cipherbyname(cipher))) {
ossl_raise(ePKCS7Error, NULL);
}

Expand Down
2 changes: 1 addition & 1 deletion ext/openssl/ossl_pkey_dsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ ossl_dsa_export(int argc, VALUE *argv, VALUE self)
GetDSA(self, dsa);
rb_scan_args(argc, argv, "02", &cipher, &pass);
if (!NIL_P(cipher)) {
ciph = GetCipherPtr(cipher);
ciph = ossl_evp_get_cipherbyname(cipher);
pass = ossl_pem_passwd_value(pass);
}
if (!(out = BIO_new(BIO_s_mem()))) {
Expand Down
2 changes: 1 addition & 1 deletion ext/openssl/ossl_pkey_ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ static VALUE ossl_ec_key_to_string(VALUE self, VALUE ciph, VALUE pass, int forma
private = 1;

if (!NIL_P(ciph)) {
cipher = GetCipherPtr(ciph);
cipher = ossl_evp_get_cipherbyname(ciph);
pass = ossl_pem_passwd_value(pass);
}

Expand Down
2 changes: 1 addition & 1 deletion ext/openssl/ossl_pkey_rsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ ossl_rsa_export(int argc, VALUE *argv, VALUE self)
rb_scan_args(argc, argv, "02", &cipher, &pass);

if (!NIL_P(cipher)) {
ciph = GetCipherPtr(cipher);
ciph = ossl_evp_get_cipherbyname(cipher);
pass = ossl_pem_passwd_value(pass);
}
if (!(out = BIO_new(BIO_s_mem()))) {
Expand Down

0 comments on commit 679b6f4

Please sign in to comment.