Mirror of BoringSSL (grpc依赖) https://boringssl.googlesource.com/boringssl
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
2.7 KiB

ASN1,100,ASN1_LENGTH_MISMATCH
ASN1,101,AUX_ERROR
ASN1,102,BAD_GET_ASN1_OBJECT_CALL
ASN1,103,BAD_OBJECT_HEADER
ASN1,193,BAD_TEMPLATE
ASN1,104,BMPSTRING_IS_WRONG_LENGTH
ASN1,105,BN_LIB
ASN1,106,BOOLEAN_IS_WRONG_LENGTH
ASN1,107,BUFFER_TOO_SMALL
ASN1,108,CONTEXT_NOT_INITIALISED
ASN1,109,DECODE_ERROR
ASN1,110,DEPTH_EXCEEDED
ASN1,111,DIGEST_AND_KEY_TYPE_NOT_SUPPORTED
ASN1,112,ENCODE_ERROR
ASN1,113,ERROR_GETTING_TIME
ASN1,114,EXPECTING_AN_ASN1_SEQUENCE
ASN1,115,EXPECTING_AN_INTEGER
ASN1,116,EXPECTING_AN_OBJECT
ASN1,117,EXPECTING_A_BOOLEAN
ASN1,118,EXPECTING_A_TIME
ASN1,119,EXPLICIT_LENGTH_MISMATCH
ASN1,120,EXPLICIT_TAG_NOT_CONSTRUCTED
ASN1,121,FIELD_MISSING
ASN1,122,FIRST_NUM_TOO_LARGE
ASN1,123,HEADER_TOO_LONG
ASN1,124,ILLEGAL_BITSTRING_FORMAT
ASN1,125,ILLEGAL_BOOLEAN
ASN1,126,ILLEGAL_CHARACTERS
ASN1,127,ILLEGAL_FORMAT
ASN1,128,ILLEGAL_HEX
ASN1,129,ILLEGAL_IMPLICIT_TAG
ASN1,130,ILLEGAL_INTEGER
ASN1,131,ILLEGAL_NESTED_TAGGING
ASN1,132,ILLEGAL_NULL
ASN1,133,ILLEGAL_NULL_VALUE
ASN1,134,ILLEGAL_OBJECT
ASN1,135,ILLEGAL_OPTIONAL_ANY
ASN1,136,ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE
ASN1,137,ILLEGAL_TAGGED_ANY
ASN1,138,ILLEGAL_TIME_VALUE
ASN1,139,INTEGER_NOT_ASCII_FORMAT
ASN1,140,INTEGER_TOO_LARGE_FOR_LONG
ASN1,141,INVALID_BIT_STRING_BITS_LEFT
ASN1,194,INVALID_BIT_STRING_PADDING
ASN1,142,INVALID_BMPSTRING
ASN1,143,INVALID_DIGIT
Rewrite and tighten ASN1_INTEGER encoding and decoding. This fixes several issues around ASN1_INTEGER handling. First, invalid INTEGERs (not allowed in BER or DER) will no longer be accepted by d2i_ASN1_INTEGER. This aligns with upstream OpenSSL, which became strict in 6c5b6cb035666d46495ccbe4a4f3d5e3a659cd40, part of OpenSSL 1.1.0. In addition to matching the standard, this is needed to avoid round-tripping issues: ASN1_INTEGER uses a sign-and-magnitude representation, different from the DER two's complement representation. That means we cannot represent invalid DER INTEGERs. Attempting to do so messes up some invariants and causes values to not round-trip correctly when re-encoded. Thanks to Tavis Ormandy for catching this. Next, this CL tidies the story around invalid ASN1_INTEGERs (non-minimal and negative zero). Although we will never produce them in parsing, it is still possible to manually construct them with ASN1_STRING APIs. Historically (CVE-2016-2108), it was possible to get them out of the parser, due to a different bug, *and* i2d_ASN1_INTEGER had a memory error in doing so. That different bug has since been fixed, but we should still handle them correctly and test this. (To that end, this CL adds a test we ought to have added importing upstream's 3661bb4e7934668bd99ca777ea8b30eedfafa871 back in c4eec0c16b02c97a62a95b6a08656c3a9ddb6baa.) As the two's complement invariants are subtle as it is, I've opted to just fix the invalid values before encoding. However, invalid ASN1_INTEGERs still do not quite work right because ASN1_INTEGER_get, ASN1_INTEGER_cmp, and ASN1_STRING_cmp will all return surprising values with them. I've left those alone. Finally, that leads to the zero value. Almost every function believes the representation of 0 is a "\0" rather than "". However, a default-constructed INTEGER, like any other string type, is "". Those do not compare as equal. crypto/asn1 treats ASN1_INTEGER generically as ASN1_STRING enough that I think changing the other functions to match is cleaner than changing default-constructed ASN1_INTEGERs. Thus this CL removes all the special cases around zero. Update-Note: Invalid INTEGERs will no longer parse, but they already would not have parsed in OpenSSL. Additionally, zero is now internally represented as "" rather than "\0". Bug: 354 Change-Id: Id4d51a18f32afe90fd4df7455b21e0c8bdbc5389 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/51632 Reviewed-by: Adam Langley <agl@google.com> Commit-Queue: David Benjamin <davidben@google.com>
3 years ago
ASN1,196,INVALID_INTEGER
ASN1,144,INVALID_MODIFIER
ASN1,145,INVALID_NUMBER
ASN1,146,INVALID_OBJECT_ENCODING
ASN1,147,INVALID_SEPARATOR
ASN1,148,INVALID_TIME_FORMAT
ASN1,149,INVALID_UNIVERSALSTRING
ASN1,150,INVALID_UTF8STRING
ASN1,151,LIST_ERROR
ASN1,152,MISSING_ASN1_EOS
ASN1,153,MISSING_EOC
ASN1,154,MISSING_SECOND_NUMBER
ASN1,155,MISSING_VALUE
ASN1,156,MSTRING_NOT_UNIVERSAL
ASN1,157,MSTRING_WRONG_TAG
ASN1,158,NESTED_ASN1_ERROR
ASN1,159,NESTED_ASN1_STRING
ASN1,192,NESTED_TOO_DEEP
ASN1,160,NON_HEX_CHARACTERS
ASN1,161,NOT_ASCII_FORMAT
ASN1,162,NOT_ENOUGH_DATA
ASN1,163,NO_MATCHING_CHOICE_TYPE
ASN1,164,NULL_IS_WRONG_LENGTH
ASN1,165,OBJECT_NOT_ASCII_FORMAT
ASN1,166,ODD_NUMBER_OF_CHARS
ASN1,167,SECOND_NUMBER_TOO_LARGE
ASN1,168,SEQUENCE_LENGTH_MISMATCH
ASN1,169,SEQUENCE_NOT_CONSTRUCTED
ASN1,170,SEQUENCE_OR_SET_NEEDS_CONFIG
ASN1,171,SHORT_LINE
ASN1,172,STREAMING_NOT_SUPPORTED
ASN1,173,STRING_TOO_LONG
ASN1,174,STRING_TOO_SHORT
ASN1,175,TAG_VALUE_TOO_HIGH
ASN1,176,TIME_NOT_ASCII_FORMAT
ASN1,177,TOO_LONG
ASN1,178,TYPE_NOT_CONSTRUCTED
ASN1,179,TYPE_NOT_PRIMITIVE
ASN1,180,UNEXPECTED_EOC
ASN1,181,UNIVERSALSTRING_IS_WRONG_LENGTH
ASN1,182,UNKNOWN_FORMAT
ASN1,183,UNKNOWN_MESSAGE_DIGEST_ALGORITHM
ASN1,184,UNKNOWN_SIGNATURE_ALGORITHM
ASN1,185,UNKNOWN_TAG
ASN1,186,UNSUPPORTED_ANY_DEFINED_BY_TYPE
ASN1,187,UNSUPPORTED_PUBLIC_KEY_TYPE
ASN1,188,UNSUPPORTED_TYPE
ASN1,195,WRONG_INTEGER_TYPE
ASN1,189,WRONG_PUBLIC_KEY_TYPE
ASN1,190,WRONG_TAG
ASN1,191,WRONG_TYPE