* ext/openssl/ossl_asn1.c (ossl_asn1_cons_to_der): Add an additional
EOC for infinite length Constructives that are supposed to be encoded with explicit tagging. Also tabify method correctly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31698 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9253bd7797
commit
efd99b781b
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
Mon May 23 04:03:46 2011 Martin Bosslet <Martin.Bosslet@googlemail.com>
|
||||||
|
|
||||||
|
* ext/openssl/ossl_asn1.c (ossl_asn1_cons_to_der): Add an additional
|
||||||
|
EOC for infinite length Constructives that are supposed to be encoded
|
||||||
|
with explicit tagging. Also tabify method correctly.
|
||||||
|
|
||||||
|
Mon May 23 03:44:39 2011 Martin Bosslet <Martin.Bosslet@googlemail.com>
|
||||||
|
|
||||||
|
* ext/openssl/ossl_asn1.c (ossl_asn1data_to_der): Remove redundant
|
||||||
|
flag tmp_cons.
|
||||||
|
|
||||||
Mon May 23 00:35:00 2001 Kenta Murata <mrkn@mrkn.jp>
|
Mon May 23 00:35:00 2001 Kenta Murata <mrkn@mrkn.jp>
|
||||||
|
|
||||||
* bignum.c (dump_bignum, bigmul1_balance, big_split, biglsh_bang,
|
* bignum.c (dump_bignum, bigmul1_balance, big_split, biglsh_bang,
|
||||||
|
@ -1137,36 +1137,36 @@ ossl_asn1cons_to_der(VALUE self)
|
|||||||
tc = ossl_asn1_tag_class(self);
|
tc = ossl_asn1_tag_class(self);
|
||||||
inf_length = ossl_asn1_get_infinite_length(self);
|
inf_length = ossl_asn1_get_infinite_length(self);
|
||||||
if (inf_length == Qtrue) {
|
if (inf_length == Qtrue) {
|
||||||
constructed = 2;
|
constructed = 2;
|
||||||
if (CLASS_OF(self) == cASN1Sequence ||
|
if (CLASS_OF(self) == cASN1Sequence ||
|
||||||
CLASS_OF(self) == cASN1Set) {
|
CLASS_OF(self) == cASN1Set) {
|
||||||
tag = ossl_asn1_default_tag(self);
|
tag = ossl_asn1_default_tag(self);
|
||||||
}
|
}
|
||||||
else { /*BIT_STRING OR OCTET_STRING*/
|
else { /*BIT_STRING OR OCTET_STRING*/
|
||||||
ary = ossl_asn1_get_value(self);
|
ary = ossl_asn1_get_value(self);
|
||||||
/* Recursively descend until a primitive value is found.
|
/* Recursively descend until a primitive value is found.
|
||||||
The overall value of the entire constructed encoding
|
The overall value of the entire constructed encoding
|
||||||
is of the type of the first primitive encoding to be
|
is of the type of the first primitive encoding to be
|
||||||
found. */
|
found. */
|
||||||
while (!found_prim){
|
while (!found_prim){
|
||||||
example = rb_ary_entry(ary, 0);
|
example = rb_ary_entry(ary, 0);
|
||||||
if (rb_obj_is_kind_of(example, cASN1Primitive)){
|
if (rb_obj_is_kind_of(example, cASN1Primitive)){
|
||||||
found_prim = 1;
|
found_prim = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* example is another ASN1Constructive */
|
/* example is another ASN1Constructive */
|
||||||
if (!rb_obj_is_kind_of(example, cASN1Constructive)){
|
if (!rb_obj_is_kind_of(example, cASN1Constructive)){
|
||||||
ossl_raise(eASN1Error, "invalid constructed encoding");
|
ossl_raise(eASN1Error, "invalid constructed encoding");
|
||||||
return Qnil; /* dummy */
|
return Qnil; /* dummy */
|
||||||
}
|
}
|
||||||
ary = ossl_asn1_get_value(example);
|
ary = ossl_asn1_get_value(example);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tag = ossl_asn1_default_tag(example);
|
tag = ossl_asn1_default_tag(example);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tag = ossl_asn1_default_tag(self);
|
tag = ossl_asn1_default_tag(self);
|
||||||
}
|
}
|
||||||
explicit = ossl_asn1_is_explicit(self);
|
explicit = ossl_asn1_is_explicit(self);
|
||||||
value = join_der(ossl_asn1_get_value(self));
|
value = join_der(ossl_asn1_get_value(self));
|
||||||
@ -1182,12 +1182,21 @@ ossl_asn1cons_to_der(VALUE self)
|
|||||||
ASN1_put_object(&p, constructed, seq_len, tn, tc);
|
ASN1_put_object(&p, constructed, seq_len, tn, tc);
|
||||||
ASN1_put_object(&p, constructed, RSTRING_LENINT(value), tag, V_ASN1_UNIVERSAL);
|
ASN1_put_object(&p, constructed, RSTRING_LENINT(value), tag, V_ASN1_UNIVERSAL);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
ASN1_put_object(&p, constructed, RSTRING_LENINT(value), tn, tc);
|
ASN1_put_object(&p, constructed, RSTRING_LENINT(value), tn, tc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memcpy(p, RSTRING_PTR(value), RSTRING_LEN(value));
|
memcpy(p, RSTRING_PTR(value), RSTRING_LEN(value));
|
||||||
p += RSTRING_LEN(value);
|
p += RSTRING_LEN(value);
|
||||||
|
|
||||||
|
/* In this case we need an additional EOC (one for the explicit part and
|
||||||
|
* one for the Constructive itself. The EOC for the Constructive is
|
||||||
|
* supplied by the user, but that for the "explicit wrapper" must be
|
||||||
|
* added here.
|
||||||
|
*/
|
||||||
|
if (explicit && inf_length == Qtrue) {
|
||||||
|
ASN1_put_eoc(&p);
|
||||||
|
}
|
||||||
ossl_str_adjust(str, p);
|
ossl_str_adjust(str, p);
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user