@@ -680,30 +680,6 @@ to_der_internal(VALUE self, int constructed, int indef_len, VALUE body)
680
680
}
681
681
682
682
static VALUE ossl_asn1prim_to_der (VALUE );
683
- static VALUE ossl_asn1cons_to_der (VALUE );
684
- /*
685
- * call-seq:
686
- * asn1.to_der => DER-encoded String
687
- *
688
- * Encodes this ASN1Data into a DER-encoded String value. The result is
689
- * DER-encoded except for the possibility of indefinite length forms.
690
- * Indefinite length forms are not allowed in strict DER, so strictly speaking
691
- * the result of such an encoding would be a BER-encoding.
692
- */
693
- static VALUE
694
- ossl_asn1data_to_der (VALUE self )
695
- {
696
- VALUE value = ossl_asn1_get_value (self );
697
-
698
- if (rb_obj_is_kind_of (value , rb_cArray ))
699
- return ossl_asn1cons_to_der (self );
700
- else {
701
- if (RTEST (ossl_asn1_get_indefinite_length (self )))
702
- ossl_raise (eASN1Error , "indefinite length form cannot be used " \
703
- "with primitive encoding" );
704
- return ossl_asn1prim_to_der (self );
705
- }
706
- }
707
683
708
684
static VALUE
709
685
int_ossl_asn1_decode0_prim (unsigned char * * pp , long length , long hlen , int tag ,
@@ -1012,11 +988,6 @@ ossl_asn1_decode_all(VALUE self, VALUE obj)
1012
988
return ary ;
1013
989
}
1014
990
1015
- static VALUE
1016
- ossl_asn1eoc_to_der (VALUE self )
1017
- {
1018
- return rb_str_new ("\0\0" , 2 );
1019
- }
1020
991
1021
992
/*
1022
993
* call-seq:
@@ -1065,44 +1036,6 @@ ossl_asn1prim_to_der(VALUE self)
1065
1036
return to_der_internal (self , 0 , 0 , rb_str_drop_bytes (str , alllen - bodylen ));
1066
1037
}
1067
1038
1068
- /*
1069
- * call-seq:
1070
- * asn1.to_der => DER-encoded String
1071
- *
1072
- * See ASN1Data#to_der for details.
1073
- */
1074
- static VALUE
1075
- ossl_asn1cons_to_der (VALUE self )
1076
- {
1077
- VALUE ary , str ;
1078
- long i ;
1079
- int indef_len ;
1080
-
1081
- indef_len = RTEST (ossl_asn1_get_indefinite_length (self ));
1082
- ary = rb_convert_type (ossl_asn1_get_value (self ), T_ARRAY , "Array" , "to_a" );
1083
- str = rb_str_new (NULL , 0 );
1084
- for (i = 0 ; i < RARRAY_LEN (ary ); i ++ ) {
1085
- VALUE item = RARRAY_AREF (ary , i );
1086
-
1087
- if (indef_len && rb_obj_is_kind_of (item , cASN1EndOfContent )) {
1088
- if (i != RARRAY_LEN (ary ) - 1 )
1089
- ossl_raise (eASN1Error , "illegal EOC octets in value" );
1090
-
1091
- /*
1092
- * EOC is not really part of the content, but we required to add one
1093
- * at the end in the past.
1094
- */
1095
- break ;
1096
- }
1097
-
1098
- item = ossl_to_der_if_possible (item );
1099
- StringValue (item );
1100
- rb_str_append (str , item );
1101
- }
1102
-
1103
- return to_der_internal (self , 1 , indef_len , str );
1104
- }
1105
-
1106
1039
/*
1107
1040
* call-seq:
1108
1041
* OpenSSL::ASN1::ObjectId.register(object_id, short_name, long_name)
@@ -1523,7 +1456,6 @@ Init_ossl_asn1(void)
1523
1456
* puts int2.value # => 1
1524
1457
*/
1525
1458
cASN1Data = rb_define_class_under (mASN1 , "ASN1Data" , rb_cObject );
1526
- rb_define_method (cASN1Data , "to_der" , ossl_asn1data_to_der , 0 );
1527
1459
1528
1460
/* Document-class: OpenSSL::ASN1::Primitive
1529
1461
*
@@ -1590,7 +1522,7 @@ Init_ossl_asn1(void)
1590
1522
* prim_zero_tagged_explicit = <class>.new(value, 0, :EXPLICIT)
1591
1523
*/
1592
1524
cASN1Primitive = rb_define_class_under (mASN1 , "Primitive" , cASN1Data );
1593
- rb_define_method (cASN1Primitive , "to_der" , ossl_asn1prim_to_der , 0 );
1525
+ // rb_define_method(cASN1Primitive, "to_der", ossl_asn1prim_to_der, 0);
1594
1526
1595
1527
/* Document-class: OpenSSL::ASN1::Constructive
1596
1528
*
@@ -1620,7 +1552,6 @@ Init_ossl_asn1(void)
1620
1552
* set = OpenSSL::ASN1::Set.new( [ int, str ] )
1621
1553
*/
1622
1554
cASN1Constructive = rb_define_class_under (mASN1 ,"Constructive" , cASN1Data );
1623
- rb_define_method (cASN1Constructive , "to_der" , ossl_asn1cons_to_der , 0 );
1624
1555
1625
1556
#define OSSL_ASN1_DEFINE_CLASS (name , super ) \
1626
1557
do{\
@@ -1670,7 +1601,9 @@ do{\
1670
1601
rb_define_alias (cASN1ObjectId , "long_name" , "ln" );
1671
1602
rb_define_method (cASN1ObjectId , "==" , ossl_asn1obj_eq , 1 );
1672
1603
1673
- rb_define_method (cASN1EndOfContent , "to_der" , ossl_asn1eoc_to_der , 0 );
1604
+ // rb_define_method(cASN1ObjectId, "to_der", ossl_asn1prim_to_der, 0);
1605
+ rb_define_method (cASN1UTCTime , "to_der" , ossl_asn1prim_to_der , 0 );
1606
+ rb_define_method (cASN1GeneralizedTime , "to_der" , ossl_asn1prim_to_der , 0 );
1674
1607
1675
1608
class_tag_map = rb_hash_new ();
1676
1609
rb_hash_aset (class_tag_map , cASN1EndOfContent , INT2NUM (V_ASN1_EOC ));
0 commit comments