Commit Graph

41 Commits

Author SHA1 Message Date
Nicolas Williams
db7763ca7b asn1: X.681/682/683 magic handling of open types
Status:

 - And it works!

 - We have an extensive test based on decoding a rich EK certficate.

   This test exercises all of:

    - decoding
    - encoding with and without decoded open types
    - copying of decoded values with decoded open types
    - freeing of decoded values with decoded open types

   Valgrind finds no memory errors.

 - Added a manual page for the compiler.

 - rfc2459.asn1 now has all three primary PKIX types that we care about
   defined as in RFC5912, with IOS constraints and parameterization:

    - `Extension`       (embeds open type in an `OCTET STRING`)
    - `OtherName`       (embeds open type in an        `ANY`-like type)
    - `SingleAttribute` (embeds open type in an        `ANY`-like type)
    - `AttributeSet`    (embeds open type in a  `SET OF ANY`-like type)

   All of these use OIDs as the open type type ID field, but integer
   open type type ID fields are also supported (and needed, for
   Kerberos).

   That will cover every typed hole pattern in all our ASN.1 modules.

   With this we'll be able to automatically and recursively decode
   through all subject DN attributes even when the subject DN is a
   directoryName SAN, and subjectDirectoryAttributes, and all
   extensions, and all SANs, and all authorization-data elements, and
   PA-data, and...

   We're not really using `SingleAttribute` and `AttributeSet` yet
   because various changes are needed in `lib/hx509` for that.

 - `asn1_compile` builds and recognizes the subset of X.681/682/683 that
   we need for, and now use in, rfc2459.asn1.  It builds the necessary
   AST, generates the correct C types, and generates templating for
   object sets and open types!

 - See READMEs for details.

 - Codegen backend not tested; I won't make it implement automatic open
   type handling, but it should at least not crash by substituting
   `heim_any` for open types not embedded in `OCTET STRING`.

 - We're _really_ starting to have problems with the ITU-T ASN.1
   grammar and our version of it...

   Type names have to start with upper-case, value names with
   lower-case, but it's not enough to disambiguate.

   The fact the we've allowed value and type names to violate their
   respective start-with case rules is causing us trouble now that we're
   adding grammar from X.681/682/683, and we're going to have to undo
   that.

   In preparation for that I'm capitalizing the `heim_any` and
   `heim_any_set` types, and doing some additional cleanup, which
   requires changes to other parts of Heimdal (all in this same commit
   for now).

   Problems we have because of this:

    - We cannot IMPORT values into modules because we have no idea if a
      symbol being imported refers to a value or a type because the only
      clue we would have is the symbol's name, so we assume IMPORTed
      symbols are for types.

      This means we can't import OIDs, for example, which is super
      annoying.

      One thing we might be able to do here is mark imported symbols as
      being of an undetermined-but-not-undefined type, then coerce the
      symbol's type the first time it's used in a context where its type
      is inferred as type, value, object, object set, or class.  (Though
      since we don't generate C symbols for objects or classes, we won't
      be able to import them, especially since we need to know them at
      compile time and cannot defer their handling to link- or
      run-time.)

    - The `NULL` type name, and the `NULL` value name now cause two
      reduce/reduce conflicts via the `FieldSetting` production.

    - Various shift/reduce conflicts involving `NULL` values in
      non-top-level contexts (in constraints, for example).

 - Currently I have a bug where to disambiguate the grammar I have a
   CLASS_IDENTIFIER token that is all caps, while TYPE_IDENTIFIER must
   start with a capital but not be all caps, but this breaks Kerberos
   since all its types are all capitalized -- oof!

   To fix this I made it so class names have to be all caps and
   start with an underscore (ick).

TBD:

 - Check all the XXX comments and address them
 - Apply this treatment to Kerberos!  Automatic handling of authz-data
   sounds useful :)
 - Apply this treatment to PKCS#10 (CSRs) and other ASN.1 modules too.
 - Replace various bits of code in `lib/hx509/` with uses of this
   feature.
 - Add JER.
 - Enhance `hxtool` and `asn1_print`.

Getting there!
2021-02-28 18:13:08 -06:00
Nicolas Williams
5a13323b68 Fix Appveyor build: lib/asn1 2017-05-26 23:24:30 -04:00
Nicolas Williams
f80cc553f8 Make build on Windows 2013-06-21 23:09:44 -05:00
Nicolas Williams
19d378f44d Add 64-bit integer support to ASN.1 compiler
ASN.1 INTEGERs will now compile to C int64_t or uint64_t, depending
    on whether the constraint ranges include numbers that cannot be
    represented in 32-bit ints and whether they include negative
    numbers.

    Template backend support included.  check-template is now built with
    --template, so we know we're testing it.

    Tests included.
2011-12-12 20:01:20 -06:00
Love Hornquist Astrand
0879b9831a remove trailing whitespace 2011-05-21 11:57:31 -07:00
Andrew Bartlett
2e34d7cf6e heimdal: fixed the use of error_message() in heimdal
the lex code in heimdal had a function error_message() which is
confusingly the ame as a core function from the com_err library. This
replaces it with lex_error_message(), and allows Samba4 to have a
stricter check for duplicate symbols between it's components.

Pair-Programmed-With: Andrew Tridgell <tridge@samba.org>

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2010-11-08 13:43:25 -08:00
Love Hörnquist Åstrand
b9ff6a94a3 rename parse.y to asn1parse.y
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25255 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-05-28 01:21:29 +00:00
Love Hörnquist Åstrand
0e6b5c5c22 remove trailing whitespace
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25232 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-05-28 01:17:17 +00:00
Love Hörnquist Åstrand
6937d41a02 remove trailing whitespace
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23815 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-13 09:21:03 +00:00
Love Hörnquist Åstrand
e172367898 switch to utf8 encoding of all files
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23814 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-13 08:53:55 +00:00
Love Hörnquist Åstrand
353fbc81ad add missing */
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18738 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-10-21 11:57:22 +00:00
Love Hörnquist Åstrand
ac9fbbe08e need %e for hpux lex
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18733 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-10-21 11:02:29 +00:00
Love Hörnquist Åstrand
0bda0d4fa9 Grow an even larger output table size.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18302 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-10-07 14:04:05 +00:00
Love Hörnquist Åstrand
14f1218bfc Grow (%p, %a, %n) tables for Solaris 10 lex. From Harald Barth.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18182 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-10-01 17:36:38 +00:00
Love Hörnquist Åstrand
9eebea050b unput() have to hanppen in actions for flex 2.5.31, can do them in
user code sesction, so move up handle_comment and handle_string into
action, not much sharing was done anyway.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16054 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-09-13 18:17:16 +00:00
Love Hörnquist Åstrand
b838707d0e Commit much improved ASN.1 compiler from joda-choice-branch.
Highlighs for the compiler is support for CHOICE and in general better
support for tags. This compiler support most of what is needed for
PK-INIT, LDAP, X.509, PKCS-12 and many other protocols.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15617 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-07-12 06:27:42 +00:00
Love Hörnquist Åstrand
ee007305f2 use get_filename
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15438 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-06-16 19:58:35 +00:00
Love Hörnquist Åstrand
54bf17b263 support hex numbers
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14304 ec53bebd-3082-4978-b11e-865c3cabbd6b
2004-10-13 17:40:21 +00:00
Johan Danielsson
2510c2ae80 add support for /* */ and partial line -- comments
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@13999 ec53bebd-3082-4978-b11e-865c3cabbd6b
2004-06-27 14:26:14 +00:00
Love Hörnquist Åstrand
322b4a8a3e added dummy parsing of CHOICE
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@13434 ec53bebd-3082-4978-b11e-865c3cabbd6b
2004-03-07 12:42:55 +00:00
Love Hörnquist Åstrand
2b0cf9b3eb add BOOLEAN
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12962 ec53bebd-3082-4978-b11e-865c3cabbd6b
2003-10-03 23:49:41 +00:00
Love Hörnquist Åstrand
bd85856ef6 -= add parser/generate glue for UTF8String and NULL
(DER primitive encode/decode functions missing)
- handle parsing of DEFAULT and, ...


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12311 ec53bebd-3082-4978-b11e-865c3cabbd6b
2003-05-20 18:42:10 +00:00
Assar Westerlund
a2f8a50aea remove some warnings
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@10743 ec53bebd-3082-4978-b11e-865c3cabbd6b
2001-09-25 23:28:03 +00:00
Assar Westerlund
2bcae56ac3 add ENUMERATED and OBJECT IDENTIFIER
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@10741 ec53bebd-3082-4978-b11e-865c3cabbd6b
2001-09-25 13:39:27 +00:00
Johan Danielsson
bd56008084 add another undef ECHO to keep AIX lex happy
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@10659 ec53bebd-3082-4978-b11e-865c3cabbd6b
2001-09-05 09:09:45 +00:00
Johan Danielsson
be966dd6e2 use strtol to parse constants
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@9784 ec53bebd-3082-4978-b11e-865c3cabbd6b
2001-04-18 13:08:47 +00:00
Assar Westerlund
ef9131390a remove roken.h, now in lex.h
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8519 ec53bebd-3082-4978-b11e-865c3cabbd6b
2000-07-02 04:08:02 +00:00
Assar Westerlund
46828984cc fix includes, and lex stuff
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8446 ec53bebd-3082-4978-b11e-865c3cabbd6b
2000-06-21 22:41:45 +00:00
Johan Danielsson
6963cfa860 add support for more standards like import statements
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8395 ec53bebd-3082-4978-b11e-865c3cabbd6b
2000-06-19 15:17:22 +00:00
Assar Westerlund
149c240f4f count lines correctly.
(error_message): print filename in messages


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8152 ec53bebd-3082-4978-b11e-865c3cabbd6b
2000-04-09 09:20:22 +00:00
Assar Westerlund
4c1b22cc34 (DOTDOT): add
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8136 ec53bebd-3082-4978-b11e-865c3cabbd6b
2000-04-06 17:26:00 +00:00
Johan Danielsson
c5b916ca6f remove advertising clause
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@7464 ec53bebd-3082-4978-b11e-865c3cabbd6b
1999-12-02 17:05:13 +00:00
Assar Westerlund
662fdcd1c1 add <unistd.h>
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@5357 ec53bebd-3082-4978-b11e-865c3cabbd6b
1999-02-13 17:25:47 +00:00
Assar Westerlund
9894665a1e (filename): unused. remove.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@5345 ec53bebd-3082-4978-b11e-865c3cabbd6b
1999-02-13 16:13:24 +00:00
Johan Danielsson
ba1616dac0 Fix for AIX lex.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@2931 ec53bebd-3082-4978-b11e-865c3cabbd6b
1997-08-11 23:42:49 +00:00
Johan Danielsson
2e28cccf55 Recognize EXTERNAL
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@2479 ec53bebd-3082-4978-b11e-865c3cabbd6b
1997-07-20 00:11:01 +00:00
Johan Danielsson
5a32a5c8e7 Add copyright notice.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@2389 ec53bebd-3082-4978-b11e-865c3cabbd6b
1997-07-16 21:40:05 +00:00
Assar Westerlund
dd5d033bbd don't worry about strdup, it's defined by roken
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@2274 ec53bebd-3082-4978-b11e-865c3cabbd6b
1997-07-14 11:39:17 +00:00
Assar Westerlund
9ca662e7b7 ifdef strdup
brange-dead version of list of special characters to make stupid lex accept it.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1228 ec53bebd-3082-4978-b11e-865c3cabbd6b
1997-02-11 02:55:21 +00:00
Johan Danielsson
dbdb412ba0 Ugh
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@864 ec53bebd-3082-4978-b11e-865c3cabbd6b
1996-10-20 16:47:54 +00:00
Assar Westerlund
b55aed018f Now uses generated ASN1-code.
kinit should be able to get a initial message from FOO.SE.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@844 ec53bebd-3082-4978-b11e-865c3cabbd6b
1996-10-13 21:13:38 +00:00