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

Added OBJECT IDENTIFIER and RELATIVE-OID value emission #9

Open
wants to merge 76 commits into
base: master
Choose a base branch
from

Conversation

seantek
Copy link

@seantek seantek commented Dec 6, 2010

Hi Lev:

Here's a pull request for OBJECT IDENTIFIER and RELATIVE-OID value emission. Please review the changes carefully and let me know of any feedback.

This is my first time using git, so hopefully it works correctly.

Originally I branched at the October 7 revision, which is the latest on sourceforge. I replayed my svn commits to that branch, which was called "oid-value". The head of that branch is e3f2689. I then tried to merge that branch into seantek:master, which is the result here. Not sure if I did it correctly or not, but at least the code appears to compile.

Feel free to contact me if you have any questions.

…and RELATIVE_OID_* functions.

Decided on standardized terminology:
 ASN.1 notation
 dot notation
 BER encoding
Cleaned up OBJECT_IDENTIFIER.h.
…gth of bytes to use/allocate for a given range of OID dot notation data.

Worked on reverse double dabble algorithm.
…d2ber.

Tested reverse double-dabble algorithm. It just about works! The one issue has to do with improper counting of the number of bytes to allocate initially.
Added asn1c Xcode project. The Xcode project uses the Makefile external build system.
Changed number in asn1p_oid from integer to char* (base 10).
Added a new type, TOK_arcnumber, which is a string, and lexical rules for handling it.
Fixed a coding error in enber.c regarding the tag class.
Improved Xcode project.
After much effort, got Value type to parse ObjectIdentifier data.
Changed ObjectIdentifier token data to TOK_arcnumber, and made asn1p_oid_t contain a string with the base10-encoded number.
Fixed up the asn1print stuff to handle printing Object Identifiers.
…_IDENTIFIER. It works, except for actual BER encoding.
Emitted RELATIVE-OID code.
…ddle code.

Tested the code and got it to output the OBJECT IDENTIFIER and RELATIVE-OID structures correctly! Now the only thing missing is the actual BER encoding data.
…ert the arg into an appropriate array of bytes.

Added code to output the right sequence of uint8_t bytes in C.
Adjusted Makefiles so that asn1c_oid compiles.
Removed the warning "unber.c:395: warning: format not a string literal and no format arguments".
Started work on asn1c_oid_ber_encode.
Added declarations of new functions OBJECT_IDENTIFIER_eq1 and 1eq1.
Fixed output issues with asn1c_print_ber.
Tested the code, and it works great for both OID and R-OID cases! The next step is to handle symbolic references.
Implemented a static function, get_len_of_oid, that encapsulates the recursion. (Careful: a malformed OID value definition may cause infinite recursion!)
Adjusted hexademcial output so that it is capitalized.
…es to other modules.

Changed sizeof DEF_### to sizeof(DEF_###).
Changed TOK_number so that it stores both the int (in a_int/tv_int.a_int) and the ascii representation (tv_int.ascii_int).
Spelunked through the .y code and .l code to figure out what was wrong with parsing.
Determined that ObjectIdentifier: is accepting {}, but that is wrong per X.208 and X.680.
Modified the lexer/parser so that only true (non-empty) ObjectIdentifier values are accepted.
Added ATV_EMPTY value type, so that {} can be parsed correctly.
Noted that {} can only appear for BIT STRING, SEQUENCE [OF], and SET [OF].
Added {} handling for BIT STRING since otherwise the parser/fixer dies on ASN1C-UsefulInformationObjectClasses.asn1.
Removed old {} from ObjectIdentifier.
Added ATV_EMPTY switch cases.
Cleaned up other parts of the code.
@vlm
Copy link
Owner

vlm commented Dec 21, 2010

Yes, I confused the type and value specs in the first paragraph.

Your understanding is correct.

…NTIFIERs and RELATIVE-OIDs into actual parsed values.
… values are left as ATV_UNPARSED.

Added dependencies on OBJECT_IDENTIFIER.h and RELATIVE-OID.h when values of those types are emitted.
Moved the definition of struct RELATIVE_OID from OBJECT_IDENTIFIER.h to RELATIVE-OID.h, because functions in OBJECT_IDENTIFIER.h rely on that definition.
Fixed some warnings encountered during make check with gcc, specifically around pointer sizes:
 Fixed warning: format %d expects type int, but long int in INTEGER.c.
 Fixed warning: cast from pointer to integer of different size in constr_SET_OF.c and per_support.c.
Fixed printf signs in check-03.c.
Fixed initialization of rval, fprintf formatting, missing switches, unused variables, and signs in check-119.-fnative-types.-gen-PER.c.
Fixed signs in check-30.c.
Added intermediate cast to (size_t) in libasn1compiler output for const OID and RELATIVE-OID values to prevent gcc from complaining about const being discarded (after consultation with vlm). It is intentional that the source array is const, because it is an optimization and a check (possibly OS-enforced) to prevent the program from writing to a constant value at runtime.
Noted that when the constraint check is ignored, because the constraint matches the natural range of the variable, gcc complains that the variable is not referenced.
Fixed the above warning by introducing a comma operator and the void operator, so that cv (or whatever variable name) is referenced.
…ismatches, uninitialized variables, and overshadowed global declarations.
…ck-42 (signed, printf sizing), and check-70 (signed, missing ctype.h for isspace).
…ded member is not initialized when the struct is returned.

This appears to be the correct behavior based on INTEGER.c and OCTET_STRING.c's handling of encoding uper.
Added -fmodule-oids flag, which means that module OIDs will only be emitted when this flag is set. By default, module OIDs are not emitted.
Added documentation on -fmodule-oids.
Implemented A1C_MODULE_OIDS to emit module OIDs when the flag is present.
Discovered that changes to keep track of ASN_MODULE_SOURCES= and ASN_MODULE_HEADERS= was lost from asn1c_save.c, so began to rewrite those changes with the "used_modules" technique.
Added attribution and advanced copyright date to 2011.
…n in asn1c_save.c.

Tested the code: it appears to work, for the most part.
…ive from INTEGER), added asn1c_lang_C_value_REFERENCE to handle AMT_VALUE A1TC_REFERENCE data. The code does not actually output the value (as that is "complicated") but it does output the declaration for the value.

Changed () to <> for the asn1c URL.
Added output to ModuleName.h so that it includes the referenced type headers, which is necessary for compiling A1TC_REFERENCE values successfully.
Fixed an off-by-one error.
Used quotation marks all the time, not <>, for referenced types.
Emitted "Including external dependencies" comment.
…values of type references and values of raw INTEGERs.

Updated the asn1c man page.
Moved value reference code into a common, static function, emit_value_reference.
Implemented output for INTEGER values (headers only, no definitions).
Cleaned up commented-out code.
Added stderr output that indicates that the ModuleName.c and ModuleName.h files are compiled.
…dules are standard modules (marked interally as MT_STANDARD_MODULE).

Added more stuff to .gitignore in support of playing nice with Xcode.
Synchronized with vlm master, resolving the asn1c ASN1C_ENVIRONMENT_VERSION to 925 in the process.

Conflicts:
	skeletons/asn_internal.h
@seantek
Copy link
Author

seantek commented Jun 17, 2011

Refreshing the pull request. Please review.

…e proper format for OBJECT_IDENTIFIER_fromDotNotation. No invalid dot notation OIDs allowed.
…y-encoded OID arcs cause a failure to be noted.
…nge (beyond the range of the accumulator) as <INVALID ERANGE>.

Added check in OBJECT_IDENTIFIER__dump_body for <INVALID 0-LENGTH> (0-length OID) and <INVALID & 0x80> (where the last octet is >= 0x80).
Changed output of original <INVALID> to <INVALID 0x80>.
…JECT_IDENTIFIER.c.

Added checks for the three evils: 0-length OID, OID ending in >= 0x80, and first octet in subidentifier series (aka arc) == 0x80.
Added OBJECT_IDENTIFIER__check_valid.
Added support for checking for invalid OID values when encoding uper.
Tested code for invalid OID values when encoding xer. It works.
…of arc (subidentifier) and >= 0x80 at end, since _constraint already checks for size <= 0 (aka size < 1).
brchiu pushed a commit to brchiu/asn1c that referenced this pull request Apr 8, 2017
Fix segmentation fault when [au]per_encode is called with null consume_bytes_cb
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants