Skip to content
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
merged 16 commits into from Jul 25, 2017

Commits on Jun 30, 2017

  1. asn1: infinite length -> indefinite length

    Replace all occurrences of 'infinite' with 'inDEfinite'. Accessor
    methods OpenSSL::ASN1::ASN1Data#infinite_length and #infinite_length=
    are kept as alias for backwards compatibility.
    rhenium committed Jun 30, 2017
    Configuration menu
    Copy the full SHA
    570f43e View commit details
    Browse the repository at this point in the history
  2. asn1: rearrange tests

    Improve test coverage of OpenSSL::ASN1. Add more BER encode/decode
    tests, while reducing redundant assertions.
    rhenium committed Jun 30, 2017
    Configuration menu
    Copy the full SHA
    ba33960 View commit details
    Browse the repository at this point in the history

Commits on Jul 23, 2017

  1. Configuration menu
    Copy the full SHA
    8a80e34 View commit details
    Browse the repository at this point in the history
  2. asn1: require tag information when instantiating generic type

    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).
    rhenium committed Jul 23, 2017
    Configuration menu
    Copy the full SHA
    e696490 View commit details
    Browse the repository at this point in the history
  3. asn1: initialize 'unused_bits' attribute of BitString with 0

    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.
    rhenium committed Jul 23, 2017
    Configuration menu
    Copy the full SHA
    7df19c3 View commit details
    Browse the repository at this point in the history
  4. asn1: check for illegal 'unused_bits' value of BitString

    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.
    rhenium committed Jul 23, 2017
    Configuration menu
    Copy the full SHA
    e61502f View commit details
    Browse the repository at this point in the history
  5. asn1: disallow NULL to be passed to asn1time_to_time()

    Let the callers check the validity of the ASN1_TIME.
    rhenium committed Jul 23, 2017
    Configuration menu
    Copy the full SHA
    f61af66 View commit details
    Browse the repository at this point in the history
  6. asn1: avoid truncating OID in OpenSSL::ASN1::ObjectId#oid

    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.
    rhenium committed Jul 23, 2017
    Configuration menu
    Copy the full SHA
    af895bc View commit details
    Browse the repository at this point in the history
  7. asn1: allow constructed encoding with definite length form

    Constructed encoding can use the definite length form as well as the
    indefinite length form, regardless of the tag number.
    rhenium committed Jul 23, 2017
    Configuration menu
    Copy the full SHA
    400d9ca View commit details
    Browse the repository at this point in the history
  8. asn1: prohibit indefinite length form for primitive encoding

    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.
    rhenium committed Jul 23, 2017
    Configuration menu
    Copy the full SHA
    a2b32a4 View commit details
    Browse the repository at this point in the history
  9. asn1: allow tag number to be >= 32 for universal tag class

    There are actually high-tag universal types such as the time-of-day
    type.
    rhenium committed Jul 23, 2017
    Configuration menu
    Copy the full SHA
    22a944f View commit details
    Browse the repository at this point in the history
  10. asn1: use ossl_asn1_tag()

    Use ossl_asn1_tag() instead of the combination of ossl_asn1_get_tag()
    and NUM2INT().
    rhenium committed Jul 23, 2017
    Configuration menu
    Copy the full SHA
    3effe62 View commit details
    Browse the repository at this point in the history
  11. asn1: clean up OpenSSL::ASN1::Constructive#to_der

    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.
    rhenium committed Jul 23, 2017
    Configuration menu
    Copy the full SHA
    3fde14b View commit details
    Browse the repository at this point in the history
  12. asn1: harmonize OpenSSL::ASN1::*#to_der

    Extract the common paths for code reduction.
    rhenium committed Jul 23, 2017
    Configuration menu
    Copy the full SHA
    27e4bad View commit details
    Browse the repository at this point in the history
  13. asn1: prevent EOC octets from being in the middle of the content

    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.
    rhenium committed Jul 23, 2017
    Configuration menu
    Copy the full SHA
    1d202b0 View commit details
    Browse the repository at this point in the history
  14. asn1: do not treat EOC octets as part of content octets

    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 committed Jul 23, 2017
    Configuration menu
    Copy the full SHA
    6b67c6d View commit details
    Browse the repository at this point in the history