Commit Graph

54 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
37ab2a5308 hx509: Add DNSSRV and TCG SAN types and DN attrs
This adds hx509 API and hxtool(1) support for PermanentIdentifier,
HardwareModuleName, and DNSSRV SAN types, as well as for serialNumber,
TPMManufacturer, TPMModel, and TPMVersion DN attributes.
2021-01-15 13:21:18 -06:00
Nicolas Williams
679bcb6872 hx509: Add hx509.conf support
Just like krb5.conf, but hx509.conf, with all the same default locations
on Windows, OS X, and elsewhere, and HX509_CONFIG as the environment
variable equivalent of KRB5_CONFIG.
2020-04-24 16:02:33 -05:00
Nicolas Williams
41fcafd20c hx509: add hx509_certs_destroy() 2019-10-03 13:09:18 -05:00
Nicolas Williams
490337f4f9 Make OpenSSL an hcrypto backend proper
This adds a new backend for libhcrypto: the OpenSSL backend.

Now libhcrypto has these backends:

 - hcrypto itself (i.e., the algorithms coded in lib/hcrypto)
 - Common Crypto (OS X)
 - PKCS#11 (specifically for Solaris, but not Solaris-specific)
 - Windows CNG (Windows)
 - OpenSSL (generic)

The ./configure --with-openssl=... option no longer disables the use of
hcrypto.  Instead it enables the use of OpenSSL as a (and the default)
backend in libhcrypto.  The libhcrypto framework is now always used.

OpenSSL should no longer be used directly within Heimdal, except in the
OpenSSL hcrypto backend itself, and files where elliptic curve (EC)
crypto is needed.

Because libhcrypto's EC support is incomplete, we can only use OpenSSL
for EC.  Currently that means separating all EC-using code so that it
does not use hcrypto, thus the libhx509/hxtool and PKINIT EC code has
been moved out of the files it used to be in.
2016-04-15 00:16:17 -05:00
Love Hornquist Astrand
0793246e99 use heim_error_t 2011-09-25 19:00:01 +02:00
Matthieu Patou
d083ae19af export hx509_private_key_ops
export hx509_private_key_ops

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2011-01-12 17:45:17 +01:00
Asanka Herath
5d48156c51 Make hx509 compile on windows
Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2009-11-25 00:20:44 +01:00
Love Hörnquist Åstrand
55bddbf305 always include <config.h>
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24794 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-22 23:28:07 +00:00
Love Hörnquist Åstrand
8ffd509d0a pass hx509_context to the matching function
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24619 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-04 22:11:01 +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
980d3d3d1e define HC_DEPRECATED_CRYPTO
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23615 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-08-17 15:57:20 +00:00
Love Hörnquist Åstrand
afe652bd26 Include <limits.h> for TYPE_MAX defines.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23189 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-05-23 15:04:27 +00:00
Love Hörnquist Åstrand
7776ed30a9 Add language to support querying certificates to find a match. Support constructs like "1.3.6.1.5.2.3.5" IN %{certificate.eku} AND %{certificate.subject} TAILMATCH "C=SE"".
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22677 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-03-13 17:35:49 +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
98b5a611bd Now that KEYCHAIN:system-anchors is fast again, use that.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21083 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-13 02:11:19 +00:00
Love Hörnquist Åstrand
5652b93c15 Disable KEYCHAIN for now, its slow.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20930 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-06 00:23:42 +00:00
Love Hörnquist Åstrand
31ac88517f Add concept of default_trust_anchors.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20914 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-05 03:58:24 +00:00
Love Hörnquist Åstrand
7cf2f2ac1a Provide default AlgorithmIdentifier.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20789 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-02 02:30:11 +00:00
Love Hörnquist Åstrand
8ed2bb38e4 Add querystat to hx509_context.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20784 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-02 00:48:51 +00:00
Love Hörnquist Åstrand
e59e71f307 Allow setting parameters to private key generation.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19871 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-12 22:01:58 +00:00
Love Hörnquist Åstrand
82a45c7036 constify
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19839 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-11 09:55:09 +00:00
Love Hörnquist Åstrand
396d442179 make printinfo char * argument const.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19838 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-11 09:38:23 +00:00
Love Hörnquist Åstrand
80977a02f6 Factor out private key operation out of the signing, operations, support import, export, and generation of private keys. Add support for writing PEM and PKCS12 files with private keys in them.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19778 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-09 10:52:13 +00:00
Love Hörnquist Åstrand
5e5521c9e1 Include <pkinit_asn1.h>.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19268 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-12-07 16:16:46 +00:00
Love Hörnquist Åstrand
7a308c3ab3 add HX509_CALCULATE_PATH_NO_ANCHOR
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19237 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-12-06 10:32:42 +00:00
Love Hörnquist Åstrand
db093bb975 add time validity-testing to query mask
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19227 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-12-05 23:44:32 +00:00
Love Hörnquist Åstrand
1ad4760402 add struct hx509_peer_info
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19119 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-11-26 15:49:25 +00:00
Love Hörnquist Åstrand
159fc828ab add context variable to cmp function.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18910 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-11-04 23:31:41 +00:00
Love Hörnquist Åstrand
f20917383b Include <parse_bytes.h>.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18486 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-10-16 14:03:16 +00:00
Love Hörnquist Åstrand
3c1036c1ca Drop heim_any.h
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18450 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-10-14 09:22:46 +00:00
Love Hörnquist Åstrand
fd39e36e9c Include <parse_units.h>.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17971 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-09-04 08:17:52 +00:00
Love Hörnquist Åstrand
e678f6b2a5 (hx509_keyset_ops): add printinfo
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17965 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-09-04 07:21:23 +00:00
Love Hörnquist Åstrand
7f6b59890e prototype for _hx509_cert_release_func
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17590 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-05-27 10:59:50 +00:00
Love Hörnquist Åstrand
4123507b93 Add support for error strings.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17393 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-05-01 14:04:21 +00:00
Love Hörnquist Åstrand
8699156461 Expose the path building function to internal functions.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17167 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-04-22 11:38:39 +00:00
Love Hörnquist Åstrand
220564fa0e Add <ctype.h>
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17129 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-04-21 12:58:05 +00:00
Love Hörnquist Åstrand
64e02c3d8d Include <hex.h>.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16987 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-04-03 15:22:17 +00:00
Love Hörnquist Åstrand
71767d72c9 Include <pkcs10_asn1.h>.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16920 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-04-01 09:48:16 +00:00
Love Hörnquist Åstrand
7a53af1e6a Add HX509_QUERY_MATCH_KEY_HASH_SHA1
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16911 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-04-01 02:10:24 +00:00
Love Hörnquist Åstrand
51fc07bc6d Add ocsp_time_diff to hx509_context
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16886 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-03-31 22:06:49 +00:00
Love Hörnquist Åstrand
de44f94103 rename HX509_CTX_CRL_MISSING_OK to HX509_CTX_VERIFY_MISSING_OK now
that we have OCSP glue


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16865 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-03-31 01:43:10 +00:00
Love Hörnquist Åstrand
6a3ce9e3ae Add <krb5-types.h> to make it compile on Solaris, from Alex V. Labuta.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16861 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-03-30 08:57:37 +00:00
Love Hörnquist Åstrand
12096c0f04 Remove hx509_query, its exposed now.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16809 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-03-26 23:39:08 +00:00
Love Hörnquist Åstrand
9a0a60e0ee Add HX509_CTX_CRL_MISSING_OK.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16612 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-01-19 18:13:38 +00:00
Love Hörnquist Åstrand
163c6cb7b5 delete crypto_headers.h, use global file instead
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16560 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-01-13 14:02:49 +00:00
Love Hörnquist Åstrand
7dcf3289bb add a hx509_context where we can store configuration
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16476 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-01-04 20:33:31 +00:00
Love Hörnquist Åstrand
069cfd602a forward type declaration of struct hx509_collector.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16447 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-01-03 16:30:03 +00:00
Love Hörnquist Åstrand
430ca62d97 Add HX509_QUERY_MATCH_FUNCTION that allows caller to match by
function, note that this doesn't not work directly for backends that
implements ->query, they must do their own processing.
(I'm running out of flags, only 12 left now)


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15810 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-07-27 21:45:25 +00:00