aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/test
AgeCommit message (Collapse)Author
2015-01-12Modernize error handling for BOOLEANDan Gudmundsson
2015-01-12Modernize error handling for named valuesDan Gudmundsson
2015-01-12Rewrite checking of ENUMERATEDBjörn Gustavsson
Clean up the checking of ENUMERATED and modernize the error reporting. Also eliminate the unused constraints argument for check_enumerated().
2015-01-12BER: Fix ENUMERATED with negative valuesBjörn Gustavsson
The ASN.1 compiler would go into an infinite loop if a value in an ENUMERATED was negative.
2015-01-12Modernize error handling for illicit tagsBjörn Gustavsson
2015-01-12Modernize error handling for instatiation of parameterized typesBjörn Gustavsson
2015-01-12Clean up get_unique_fieldname/2Dan Gudmundsson
get_unique_fieldname/2 would throw an exception that *all* callers would catch and handle. Since all callers catch the exception, it is much easier to return a special return value. Also use the new error reporting style. While we are at it, remove all catches of {asn1,Error} which are no longer thrown.
2015-01-12Clean up error reporting for duplicate tagsDan Gudmundsson
Split the test case duplicate_tags/1 into two parts. Do the error checking test in error_SUITE. Keep the SeqOptional2 specification and compile it from the per/1 and ber_other/1 test cases (for coverage).
2015-01-12asn1: Rewrite error handling for EXPORT to new styleDan Gudmundsson
2015-01-12asn1: Fix error reporting for the EXTERNAL typeDan Gudmundsson
Change to new error handling system and cover with tests.
2015-01-12asn1: Fix import checking codeDan Gudmundsson
All errors were not reported. Furthermore, get_referenced_type/2 will report errors if any module is missing, so the attempt to report additional errors in chained_import/4 would not find any errors.
2015-01-12Rewrite constraint handlingBjörn Gustavsson
The internal representation for constraints (and object sets) as produced by the parser was awkward, making further processing convoluted. Here follows some examples of the old representation for INTEGER constraints. The constraint 1..2 is represented as: {'ValueRange',{1,2}} If we extend the constraint like this: 1..2, ..., or like this: 1..2, ..., 3 the representation would be: {{'ValueRange',{1,2}},[]} and {{'ValueRange',{1,2}},{'SingleValue',3}} respectively. Note that the pattern {A,B} will match all these constraints. When combining constraints using set operators: 1..2 | 3..4 ^ 5..6 the representation will no longer be a tuple but a list: [{'ValueRange',{1..2}} union {'ValueRange',{3..4}} intersection {'ValueRange',{5..6}}] The parse has full knowledge of the operator precedence; unfortunately, the following pass (asn1ct_check) must also have the same knowledge in order to correctly evaluate the constraints. If we would change the order of the evaulation with round brackets: (1..2 | 3..4) ^ 5..6 there would be a nested listed in the representation: [[{'ValueRange',{1..2}} union {'ValueRange',{3..4}}] intersection {'ValueRange',{5..6}}] We will change the representation to make it more explicit. At the outer level, a constraint is always represented as {element_set,Root,Extension} Extension will be 'none' if there is no extension, and 'empty' if there is an empty extension. Root may also be 'empty' in an object set if there are no objects in the root. Thus the constraints: 1..2 1..2, ... 1..2, ..., 3 will be represented as: {element_set,{'ValueRange',{1,2}},none} {element_set,{'ValueRange',{1,2}},empty} {element_set,{'ValueRange',{1,2}},{'SingleValue',3}} We will change the set operators too. This constraint: 1..2 | 3..4 ^ 5..6 will be represented as: {element_set, {union, {'ValueRange',{1,2}}, {intersection, {'ValueRange',{3,4}}, {'ValueRange',{5,6}}}, none}} which is trivial to understand and evaluate. Similarly: (1..2 | 3..4) ^ 5..6 will be represented as: {element_set, {intersection, {union,{'ValueRange',{1,2}},{'ValueRange',{3,4}}}, {'ValueRange',{5,6}}}, none}
2015-01-12Strengthen the constraint_equivalence test caseBjörn Gustavsson
Instead of only compiling to the abstract format using 'abs', also compile to each of the back-ends.
2015-01-12Get rid of the test case for warnings_as_errorsBjörn Gustavsson
The warnings in the ASN.1 are being eliminated one by one and replaced with errors. Therefore, it is no longer possible to test warnings_as_errors. We will reimplement this test case in the future if we will introduce some new sensible warnings.
2015-01-12Add the other PKCS files to the rfcs test caseDan Gudmundsson
Changed the following from the original copies: PKCS-5 (renamed from PKCS-v21) PKCS-9 Import from CryptographicMessageSyntax-2009 instead of CryptographicMessageSyntax Since most of the files from the x420 directory are needed, copy all of them into the rfcs directory and remove the x420 directory and test case. Copy the test of OTP-7759 to the testRfcs test case.
2015-01-12Clean up checking of object setsBjörn Gustavsson
2015-01-12Fix several levels of inlined definitionsBjörn Gustavsson
2015-01-12Rewrite handling of ObjectSetFromObjectsBjörn Gustavsson
The ObjectSetFromObjects construct is implemented using the object_set_from_objects() function, which is similar to get_fieldname_element(). Rewrite the ObjectSetFromObjects handling to use get_fieldname_element() to share more code.
2015-01-12Clean up and correct table constraint handlingBjörn Gustavsson
2015-01-12Correct another bug with instantiated typesBjörn Gustavsson
a1260b2ffa60581ce3af0728320b593cca3fd7b0 fixed a problem with expansion of parameterized types, but it didn't go all the way. The compiler would still crash if we attempted to define a value using the instantiated type.
2015-01-12Fix instantiation of an inlined type in a value definitionBjörn Gustavsson
2015-01-12Clean up constraint checkingBjörn Gustavsson
2015-01-12Use recursive get_referenced_type to get classdef directlyDan Gudmundsson
To be sure that indirect references to classes are solved.
2015-01-12Fix recursive get_referenced_typeDan Gudmundsson
2015-01-12Remove special case in parserBjörn Gustavsson
The parser handled the builtin ABSTRACT-SYNTAX and TYPE-IDENTIFIER classes specially, which caused problems. It turns out that there is no longer any need to handle those classes specially.
2015-01-12Improve handling of BIT STRING valuesBjörn Gustavsson
2015-01-12Check more errors in the simplified syntaxBjörn Gustavsson
An optional group must not contain mandatory class fields. All mandatory fields must be included in the simplified syntax.
2015-01-12Add the rfcs test caseBjörn Gustavsson
Add the ASN.1 specs from RFC-5911 and RFC-5912.
2015-01-12Handle CLASS.&field when checking valuesBjörn Gustavsson
2015-01-12Clean up and correct validation of OBJECT IDENTIFIER/RELATIVE-OIDDan Gudmundsson
Besides simplifying the code and doing better error checking and error reporting, fix the following bugs: Support retrieving an OBJECT IDENTIFIER/RELATIVE-OID from an object. Example: oid OBJECT IDENTIFIER ::= some-object.&some-field Allow an integer constant first in an OBJECT IDENTIFIER: integer INTEGER ::= 0 oid OBJECT IDENTIFIER ::= {integer 1}
2015-01-12Fix object set duplication testBjörn Gustavsson
Wrong fields in the record where checked when sorting, which caused duplicate objects to exist in constructed object sets and later caused an error.
2015-01-12per/uper: Fix code generation for nested types in objectsBjörn Gustavsson
2015-01-12Correct recursion in OCTET STRING value definitionsBjörn Gustavsson
2015-01-12Fix BER code generationDan Gudmundsson
PKIX1Explicit-2009 did not compile.
2015-01-12Clean up get_fieldname_element/3Björn Gustavsson
Also add proper error handling.
2015-01-12asn1: Fix BER generation for non optional and extended object setsDan Gudmundsson
Object sets with extension mark and without optional fields was not generated properly. It needs the default [enc|dec]_xxx function clause for the open type but no other clauses.
2015-01-12Rewrite matching of object definitions using the simplified syntaxBjörn Gustavsson
Rewrite the confusing and buggy matching of an object definition against the simplified syntax. While we are at it, we will also add proper error handling.
2015-01-12Simplify handling of an empty object definitionBjörn Gustavsson
When the parser sees: something SOMETHING ::= {} it has no way of knowing whether 'something' is an value or an object. It depends on how SOMETHING is defined. For example: SOMETHING ::= SEQUENCE {} or SOMETHING ::= CLASS { &id OPTIONAL } Because of that ambiguity, there is no way to avoid a special case when we check an object definition. However, there is no need to invent an entire new checking function for this special case. It is much easier to just pretend that the parser gave us {object,defaultsyntax,[]} and let check_objectdefn/3 check it in the usual way.
2015-01-12Refactor code involving calls to get_fieldname_element/3Björn Gustavsson
Refactor and clean up code. While at it, add error handling and test cases. (Also add test cases for the existing values in ValueTest.asn while we are it.) Add support for defining INTEGER constants by extracting fields from objects. Example: int-from-object INTEGER ::= object.&id When extracting values from objects in constraints, only one level of extraction would work. That is, the following would work: SomeName ::= INTEGER (object.&int) but not: SomeName ::= INTEGER (object.&obj.&int)
2015-01-12Check INTEGER values betterBjörn Gustavsson
There is duplicated effort in that validate_integer() checks whether the integer value is valid, and then normalize_integer() does mostly the same work in order to convert the value to an integer. Eliminate the validate_integer() function and incorporate its checks into normalize_integer(). Also produce proper error messages.
2015-01-12Check CLASS names for validityBjörn Gustavsson
Class names must start with an uppercase letter and only contain uppercase letters, digits, or hyphens. The parser will not allow class names that don't start with an uppercase letter, so we don't have to check that.
2015-01-12Add a new test case to test values in ValueTest.asn1Björn Gustavsson
We only tested that ValueTest.asn1 would compile, no that the values were correct.
2014-11-27Merge branch 'dgud/asn1/fix-seqtag/OTP-12326' into maintDan Gudmundsson
* dgud/asn1/fix-seqtag/OTP-12326: asn1: Fix EXTERNAL (1994 variant) type conversion
2014-11-26asn1: Fix EXTERNAL (1994 variant) type conversionDan Gudmundsson
Missed to add seqtag handling for EXTERNAL type conversion, bug introduced in c266196c016fc1156c7a18cfeec4920ee4075519
2014-11-18Add test for IMPLICIT tagging when TagDefault is AUTOMATICSimon Cornish
2014-09-29BER decoding: Don't allow primitives with indefinite lengthsBjörn Gustavsson
According to the BER encoding rules, only constructed values may have indefinite lengths. A primitive value must be encoded with a definite length. Reported-by: Simon Cornish
2014-09-08Merge branch 'bjorn/asn1/misc-bug-fixes/OTP-12125' into maintBjörn Gustavsson
* bjorn/asn1/misc-bug-fixes/OTP-12125: Workaround for combining two object sets separated by extension Clean up and correct handling of parameters for parameterized types Check the formal parameter for parameterized type definitions Report errors also for unused parameterized types Remove unused code for ABSTRACT-SYNTAX and TYPE-IDENTIFIER Correct expansion of parameterized types Add the module name to the #classdef{} record Eliminate the use of #identifier{} outside the tokeniser and parser Fix problem with object identifiers in external modules Rewrite get_referenced_type/2 Teach the ASN.1 compiler to handle objects in field names Teach the ASN.1 compiler to understand "EXPORTS ALL" Teach the ASN.1 compiler the parse option
2014-09-01Workaround for combining two object sets separated by extensionBjörn Gustavsson
The following type of code would crash the compiler: OSET SOME-CLASS ::= {OSET1, ..., OSET2}
2014-09-01Check the formal parameter for parameterized type definitionsBjörn Gustavsson
Check the formal parameters for a parameterized type definition. If the governor for a formal parameter is absent, the formal parameter must be in upper case.
2014-09-01Correct expansion of parameterized typesBjörn Gustavsson
Attempting to compile: SomeType{SOME-CLASS-NAME, SOME-CLASS-NAME:SomeSet} ::= ... SEQUENCE { something SOME-CLASS-NAME.&id({SomeSet}) } would crash the compiler, because the actual parameter for SOME-CLASS-NAME was not substituted into the governor for the SomeSet parameter. While we are at it, combine the functionality of is_class/2 and get_class_def/2 (eliminating is_class/2). Most callers call both function.