-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
asn1: a bunch of bugfixes and test improvements #98
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rhenium
force-pushed
the
topic/asn1-overhaul
branch
2 times, most recently
from
January 24, 2017 04:52
a5317e8
to
738b520
Compare
rhenium
force-pushed
the
topic/asn1-overhaul
branch
from
February 23, 2017 14:53
738b520
to
759d5fe
Compare
rhenium
force-pushed
the
topic/asn1-overhaul
branch
2 times, most recently
from
April 20, 2017 04:54
471caf8
to
12dd5ef
Compare
rhenium
force-pushed
the
topic/asn1-overhaul
branch
from
May 2, 2017 05:45
12dd5ef
to
cc985a2
Compare
rhenium
force-pushed
the
topic/asn1-overhaul
branch
2 times, most recently
from
May 26, 2017 05:29
34e0c07
to
bafe23a
Compare
Replace all occurrences of 'infinite' with 'inDEfinite'. Accessor methods OpenSSL::ASN1::ASN1Data#infinite_length and #infinite_length= are kept as alias for backwards compatibility.
Improve test coverage of OpenSSL::ASN1. Add more BER encode/decode tests, while reducing redundant assertions.
rhenium
force-pushed
the
topic/asn1-overhaul
branch
from
July 21, 2017 04:31
bafe23a
to
23887b7
Compare
Improve the error message of the exception raised when OpenSSL::ASN1::Primitive.new or OpenSSL::ASN1::Constructive.new is called with one argument (which is wrong).
Fix the initial value of 'unused_bits' attribute of OpenSSL::ASN1::BitString. The attribute must always contain an Integer in the range 0 to 7.
Invalid values such as nil or values not in the range 0 to 7 are silently coerced into the valid range. This behavior is confusing and hides user bugs. Raise an exception instead if an illegal value is specified.
Let the callers check the validity of the ASN1_TIME.
OpenSSL::ASN1::ObjectId#oid, which returns the dotted representation of the OID, is silently truncating the result if it overflows the 128-bytes buffer. Although it normally won't be more than 127-characters, it'd be better to avoid. This can be done by checking the return value of OBJ_obj2txt(). Previous releases of LibreSSL (< 2.5.1) have a bug in OBJ_obj2txt() and it does not work if the resulting string would be larger than the buffer. A workaround is added to the test. It should be removed when we deprecate support for LibreSSL 2.4.
Constructed encoding can use the definite length form as well as the indefinite length form, regardless of the tag number.
The setter method #indefinite_length= for OpenSSL::ASN1::Primitive is undef-ed, but we can still set 'indefinite_length' to true illegally when constructing an object with the raw OpenSSL::ASN1::ASN1Data. Indefinite length form is not possible in primitive encoding. Raise an exception in OpenSSL::ASN1::ASN1Data#to_der if specified.
There are actually high-tag universal types such as the time-of-day type.
Use ossl_asn1_tag() instead of the combination of ossl_asn1_get_tag() and NUM2INT().
Remove a mysterious behavior in Constructive#to_der: if the 'tagging' attribute is set to :EXPLICIT and it is not an instance of universal tag class classes, it "searches" the original tag from the first value whose encoding is primitive. ary = [ OpenSSL::ASN1.Sequence([ OpenSSL::ASN1.OctetString("abc") ]) ] cons = OpenSSL::ASN1::Constructive.new(ary, 1, :EXPLICIT) cons.to_der #=> "\xA1\x09\x24\x07\x30\x05\x04\x03\x61\x62\x63" # ^ # This 4 comes from the OctetString This is really confusing and nobody seems to be using this behavior. Let's make it raise error instead.
Extract the common paths for code reduction.
Encoding with indefinite length form produces an invalid encoding if the contents array contains an EOC object in the middle. Raise an exception in that case.
We currently treat end-of-contents octets as a BER encoding of a value whose tag is universal class and the number is zero, and require users to put one in the end of 'value' array when encoding using indefinite length form. However, the end-of-contents are just a marker indicating the end of the contents and not really part of the contents. Do not require users to put an EOC object in the content when encoding, and don't produce an EOC object when decoding an encoding that uses indefinite length form.
rhenium
force-pushed
the
topic/asn1-overhaul
branch
from
July 23, 2017 06:18
49c8746
to
6b67c6d
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.