From 803bc4e494c68776fdc3a6ce0fb3f3ce53f7257f Mon Sep 17 00:00:00 2001 From: Kazuki Yamaguchi Date: Thu, 8 Sep 2016 19:36:54 +0900 Subject: asn1: remove dead code Remove code relating DO_IT_VIA_RUBY. If DO_IT_VIA_RUBY is set to 1, OpenSSL::ASN1.decode will decode ASN.1 INTEGER values into a Ruby's Integer instead of OpenSSL::BN. However it would be too late to change now. Anyway, if we change out mind, we will rewrite it to avoid unnecessary conversions between BIGNUM. --- ext/openssl/ossl_asn1.c | 37 ------------------------------------- 1 file changed, 37 deletions(-) (limited to 'ext') diff --git a/ext/openssl/ossl_asn1.c b/ext/openssl/ossl_asn1.c index c6cd71f4..2b8a85f0 100644 --- a/ext/openssl/ossl_asn1.c +++ b/ext/openssl/ossl_asn1.c @@ -110,16 +110,11 @@ asn1str_to_str(const ASN1_STRING *str) /* * ASN1_INTEGER conversions - * TODO: Make a decision what's the right way to do this. */ -#define DO_IT_VIA_RUBY 0 VALUE asn1integer_to_num(const ASN1_INTEGER *ai) { BIGNUM *bn; -#if DO_IT_VIA_RUBY - char *txt; -#endif VALUE num; if (!ai) { @@ -133,43 +128,12 @@ asn1integer_to_num(const ASN1_INTEGER *ai) if (!bn) ossl_raise(eOSSLError, NULL); -#if DO_IT_VIA_RUBY - if (!(txt = BN_bn2dec(bn))) { - BN_free(bn); - ossl_raise(eOSSLError, NULL); - } - num = rb_cstr_to_inum(txt, 10, Qtrue); - OPENSSL_free(txt); -#else num = ossl_bn_new(bn); -#endif BN_free(bn); return num; } -#if DO_IT_VIA_RUBY -ASN1_INTEGER * -num_to_asn1integer(VALUE obj, ASN1_INTEGER *ai) -{ - BIGNUM *bn = NULL; - - if (RTEST(rb_obj_is_kind_of(obj, cBN))) { - bn = GetBNPtr(obj); - } else { - obj = rb_String(obj); - if (!BN_dec2bn(&bn, StringValueCStr(obj))) { - ossl_raise(eOSSLError, NULL); - } - } - if (!(ai = BN_to_ASN1_INTEGER(bn, ai))) { - BN_free(bn); - ossl_raise(eOSSLError, NULL); - } - BN_free(bn); - return ai; -} -#else ASN1_INTEGER * num_to_asn1integer(VALUE obj, ASN1_INTEGER *ai) { @@ -185,7 +149,6 @@ num_to_asn1integer(VALUE obj, ASN1_INTEGER *ai) return ai; } -#endif /********/ /* -- cgit v1.2.3