Commit Graph

62 Commits

Author SHA1 Message Date
Nicolas Williams
e23bc7d53d hx509: Fix warnings and leaks 2022-01-14 12:42:52 -06:00
Luke Howard
f67dd0f903 roken: move Heimdal vis.h extensions to separate header
vis.h is not built on platforms (such as macOS) that already have
that header, which resulted in prototypes for Heimdal-specific
vis.h extensions being absent.

Move those prototypes to a separate header, vis-extras.h, which
must be explicitly included in order to use the Heimdal extensions.
2021-05-17 10:05:58 +10:00
Nicolas Williams
230580d21c hx509: Fix rfc2459.asn1 compilation w/o templates 2021-03-10 21:21:26 -06:00
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
dbb0463ca8 hx509: Add support for cert policies and mappings 2021-01-15 13:21:18 -06:00
Nicolas Williams
b193d75a15 hx509: Revamp name handling ahead of new SAN types 2021-01-15 13:21:18 -06:00
Jeffrey Altman
387684aa93 WIN32: fix calling conventions for 32-bit builds
On 32-bit Windows Intel builds the __cdecl and __stdcall calling
conventions are different so labeling the functions that are
exported or assigned to function pointers matters.

Change-Id: I03b6f34baeb9ffb2e683fd979f12f27a5078a4da
2019-01-14 06:12:36 -05:00
Jeffrey Altman
1dd38cc3de lib/hx509: declare and apply HX509_LIB_xxx macros
libhx509 is not built according to the same export and calling conventions
on Windows as the other libraries.  This change declares and applies
HX509_LIB_FUNCTION, HX509_LIB_NORETURN_FUNCTION, HX509_LIB_CALL and
HX509_LIB_VARIABLE to lib/hx509.

As a result of this change the calling convention for exported functions
will be __stdcall instead of __cdecl.

Change-Id: Ibc3f05e8088030ef7d13798f1d9c9b190bc57797
2019-01-02 10:23:39 -06:00
Quanah Gibson-Mount
7c16ce3457 Minor typo/grammar fixes 2017-03-10 15:47:43 -05:00
Jelmer Vernooij
70e43e9808 Fix some typos. 2014-04-25 02:42:17 +02:00
Love Hornquist Astrand
0879b9831a remove trailing whitespace 2011-05-21 11:57:31 -07:00
Love Hornquist Astrand
f5f9014c90 Warning fixes from Christos Zoulas
- shadowed variables
- signed/unsigned confusion
- const lossage
- incomplete structure initializations
- unused code
2011-04-29 20:25:05 -07:00
Love Hornquist Astrand
72e306c7e3 Push cert down deaper into the stack 2009-08-21 18:34:21 -07:00
Love Hörnquist Åstrand
3d88641010 Use OID variable instead of function.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25247 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-05-28 01:19:55 +00:00
Love Hörnquist Åstrand
f0f5f236dc Use OID variable instead of function.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25246 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-05-28 01:19:45 +00:00
Love Hörnquist Åstrand
ff5dab4f4a remove rcsid
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24795 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-22 23:28:18 +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
0ff6dbc8bb Add matching on EKU, validate EKUs, add hxtool matching glue, add check. Adapted from pach from Tim Miller of Mitre
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22538 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-01-27 13:05:47 +00:00
Love Hörnquist Åstrand
b5e7b818b1 make print_func static
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22420 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-01-13 09:42:35 +00:00
Love Hörnquist Åstrand
22f3d27d6f doxygen.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22347 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-12-26 19:26:28 +00:00
Love Hörnquist Åstrand
60adfe11c6 Print authorityInfoAccess.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21381 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-28 08:29:22 +00:00
Love Hörnquist Åstrand
4196398739 Rename proxyCertInfo oid.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21377 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-28 07:37:24 +00:00
Love Hörnquist Åstrand
9e262359f2 Check that the self-signed cert is really self-signed.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20908 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-05 02:59:33 +00:00
Love Hörnquist Åstrand
6623ac6441 Use selfsigned for CRL DP whine, tell if its a self-signed.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20907 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-05 02:28:18 +00:00
Love Hörnquist Åstrand
887bb5f354 Whine if its a non CA/proxy and doesn't have CRL DP.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20906 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-05 02:23:45 +00:00
Love Hörnquist Åstrand
852d5a2392 Leak less memory.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20896 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-04 23:05:31 +00:00
Love Hörnquist Åstrand
f4600fe0a5 Leak less memory, use functions that does same but more.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20894 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-04 23:03:10 +00:00
Love Hörnquist Åstrand
5e8efa4fd0 print utf8 type SAN's
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20762 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-01 03:44:48 +00:00
Love Hörnquist Åstrand
0a123869a2 Printf formating.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20733 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-05-31 15:41:41 +00:00
Love Hörnquist Åstrand
ee3f87c182 Fix printing of CRL DPnames (I hate IMPLICIT encoded structures).
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20727 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-05-31 14:50:20 +00:00
Love Hörnquist Åstrand
e7b0a46e77 Fix warning.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20700 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-05-30 16:53:35 +00:00
Love Hörnquist Åstrand
d90201bfe3 Indent.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20668 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-05-10 23:49:51 +00:00
Love Hörnquist Åstrand
592c612ff1 add Netscape cert comment
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20659 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-05-10 21:47:16 +00:00
Love Hörnquist Åstrand
b0afe13641 Add some US Fed PKI oids.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20642 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-05-10 18:30:28 +00:00
Love Hörnquist Åstrand
48515e61c5 Add some more \n's.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20183 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-02-05 09:11:19 +00:00
Love Hörnquist Åstrand
ea7f403c7c x
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20159 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-02-03 09:55:07 +00:00
Love Hörnquist Åstrand
50009d684a Use less printf. Use hx509_general_name_unparse.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20157 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-02-03 09:53:46 +00:00
Love Hörnquist Åstrand
e629fa7c61 add printing of SubjectKeyIdentifier and AuthorityKeyIdentifier
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20153 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-02-03 08:46:49 +00:00
Love Hörnquist Åstrand
c135a37d37 Check CRLDistributionPointNames.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20100 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-31 15:34:20 +00:00
Love Hörnquist Åstrand
f978746627 Fix previous test.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19875 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-12 22:45:29 +00:00
Love Hörnquist Åstrand
6efa69a5d3 Check there is a SAN if subject DN is NULL.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19874 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-12 22:44:34 +00:00
Love Hörnquist Åstrand
cd5e0fba78 Print id-pkix-on-xmppAddr OtherName.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19860 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-12 08:43:20 +00:00
Love Hörnquist Åstrand
e797c5a42c BasicConstraints vs criticality bit is complicated and not really
possible to evaluate on its own, silly RFC3280.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19820 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-10 22:11:34 +00:00
Love Hörnquist Åstrand
f4b0e6fcea fix the version vs extension test
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19818 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-10 22:02:10 +00:00
Love Hörnquist Åstrand
d8423fa525 Even more validation checks.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19817 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-10 21:53:45 +00:00
Love Hörnquist Åstrand
5bf1bd2a7d More validation checks.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19816 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-10 21:45:56 +00:00
Love Hörnquist Åstrand
d987d9258d Split OtherName printing code to a oid lookup and print function.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19278 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-12-07 20:37:57 +00:00
Love Hörnquist Åstrand
c693f4cd8e AltNames: Print all diffrent names of a GeneralName
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19275 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-12-07 17:20:09 +00:00
Love Hörnquist Åstrand
6621f45c1f (Time2string): print hour as hour not min
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19273 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-12-07 16:34:53 +00:00