Commit Graph

53 Commits

Author SHA1 Message Date
Luke Howard
ef1d63a997 kinit: add --pk-anon-fast-armor option
Add the  --pk-anon-fast-armor option, which acquires a temporary anonymous
PKINIT TGT to use as a FAST armor key.
2021-08-10 15:30:45 +10:00
Nicolas Williams
15b2094079 hx509: Add Heimdal cert ext for ticket max_life
This adds support for using a Heimdal-specific PKIX extension to derive
a maximum Kerberos ticket lifetime from a client's PKINIT certificate:

 - a `--pkinit-max-life` to the `hxtool ca` command
 - `hx509_ca_tbs_set_pkinit_max_life()`
 - `hx509_cert_get_pkinit_max_life()`
 - `HX509_CA_TEMPLATE_PKINIT_MAX_LIFE`

There are two extensions.  One is an EKU, which if present means that
the maximum ticket lifetime should be derived from the notAfter minus
notBefore.  The other is a certificate extension whose value is a
maximum ticket lifetime in seconds.  The latter is preferred.
2021-03-24 19:12:00 -05: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
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
e515745996 hx509: private key exclusion options
Add two ways to exclude private keys when dealing with an hx509
certificate store.  One as a load option (load no private keys, never
add private keys), one as a store option (store no private keys).

This is useful for CA code so it can have a single store with the
issuer's credentials _and_ the chain for it, and copy those to a store
with the issued certificate and _not_ accidentally include the issuer's
private key.

It would be much safer still to flip the default for this flag, but that
could break out-of-tree libhx509 dependents.
2019-12-09 18:10:10 -06:00
Nicolas Williams
a7a1d798c3 hx509: keep track of authorized CSR features
This commit adds a few functions for marking KU, EKUs, and SANs as
authorized, and for getting a count of unsupported certificate
extensions requested, and a count of authorized KU/EKUs/SANs.

The intent is to make it easier to build CSR authorization and CA code
that is robust in the face of future support for certificate extensions
and SAN types not currently supported.  An application could parse a
CSR, iterate all KU/EKUs/SANs, check a subject's authorization to them,
mark them authorized where authorized, then check if there are any
remaining unauthorized extensions or unsupported extensions requested.

Ultimately, if a CSR's KU/EKUs/SANs are all authorized, then they can
all be copied to a TBS, and a certificate can be issued.
2019-12-04 21:34:37 -06:00
Nicolas Williams
5a0d85e423 hx509: Add PKCS#8 private key format option 2019-10-03 13:09:18 -05:00
Jelmer Vernooij
906922b990 Include heimbase.h in hx509.h; required for heim_err_t.
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
2013-11-20 00:42:26 +00: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
Simon Wilkinson
3d7fc1001a Assign a value for HX509_CMS_EV_ID_NAME
667ec8eb81 introduced the flag
HX509_CMS_EV_ID_NAME, without defining a value for that flag.
Assign a value using the next available bit.

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2010-10-11 20:05:26 -07:00
Love Hornquist Astrand
48ad3e1e65 add import/export type for private keys 2010-10-03 16:32:01 -07:00
Love Hornquist Astrand
6f328a9194 add padding support via hx509_crypto_set_padding 2010-09-22 14:41:17 -07:00
Love Hornquist Astrand
bcf2cbca83 add HX509_CMS_SIGNATURE_NO_CERTS and HX509_CMS_SIGNATURE_LEAF_ONLY 2010-08-10 10:19:51 -07:00
Love Hörnquist Åstrand
1859798544 allow weak flags for cms
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24819 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-27 03:24:18 +00:00
Love Hörnquist Åstrand
50c7425369 include <stdio.h>
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24799 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-22 23:28:57 +00:00
Love Hörnquist Åstrand
74377bbf5c include <stdarg.h>
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24797 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-22 23:28:38 +00:00
Love Hörnquist Åstrand
89e9107f8d drop <heim_extra.h>
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24796 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-22 23:28:28 +00:00
Love Hörnquist Åstrand
9b8c1d9569 spelling
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24589 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-04 22:06:01 +00:00
Love Hörnquist Åstrand
de35928c20 add HX509_CMS_SIGATURE_NO_SIGNER and indent
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24581 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-04 22:04:38 +00:00
Love Hörnquist Åstrand
7e1b5d3a55 better name for zero signer
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24575 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-04 22:03:37 +00:00
Love Hörnquist Åstrand
2e93ad7a9f add more hx509_cms_verify_signed flags.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24573 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-04 22:03:17 +00:00
Love Hörnquist Åstrand
26abb7e637 option to turn off the KeyUsage check in CMS verify SignedData
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24204 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-12-15 04:32:49 +00:00
Love Hörnquist Åstrand
e893e7bd5b Add HX509_CMS_EV_NO_KU_CHECK and HX509_CMS_VS_ALLOW_DATA_OID_MISMATCH
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24198 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-12-15 04:31:51 +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
e447e5b619 Make self-standing by including missing files.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22908 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-04-08 08:16:32 +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
634a0a544f add HX509_CERTS_UNPROTECT_ALL
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22464 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-01-16 14:24:50 +00:00
Love Hörnquist Åstrand
a959e6cd3e Add HX509_VHN_F_ALLOW_NO_MATCH.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22237 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-12-08 22:43:15 +00:00
Love Hörnquist Åstrand
de375f7467 PEM struct/function declarations.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21310 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-25 18:26:06 +00:00
Love Hörnquist Åstrand
4f99a5fdd6 fixate HX509_HN_HOSTNAME at 0.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21277 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-25 04:54:20 +00:00
Love Hörnquist Åstrand
0a6bc4b22c Add HX509_CMS_SIGATURE_ID_NAME, use subject name for CMS.Identifier.
hx509_hostname_type: add hostname type for matching.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21266 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-24 19:21:00 +00:00
Love Hörnquist Åstrand
0d7c929c6d Add hx509_crl.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20798 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-02 03:28:55 +00:00
Love Hörnquist Åstrand
c1da454788 Add HX509_SELECT_SECRET_ENC.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20702 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-05-30 18:38:14 +00:00
Love Hörnquist Åstrand
1820a1f17b Flag to generate detached signatures.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20167 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-02-03 22:45:00 +00:00
Love Hörnquist Åstrand
9b40125782 Add template flags.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19898 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-14 18:19:27 +00:00
Love Hörnquist Åstrand
342aad4138 add hx509_env
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19884 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-13 11:18:33 +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
23b2e5ae89 Add hx509_ca_tbs and HX509_QUERY_OPTION_KU_KEYCERTSIGN.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19560 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-12-29 15:50:05 +00:00
Love Hörnquist Åstrand
9b5b13dc57 update (c)
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19146 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-11-27 10:43:28 +00:00
Love Hörnquist Åstrand
2022239dd6 Spelling.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19145 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-11-27 10:43:15 +00:00
Love Hörnquist Åstrand
03ef18c610 add HX509_SELECT_ALL
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19144 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-11-27 10:42:48 +00:00
Love Hörnquist Åstrand
84293fbe7c Add hx509_peer_info and hx509_select selectors.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19116 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-11-26 15:18:47 +00:00
Love Hörnquist Åstrand
15a66286ab Add HX509_CMS_UE_DONT_REQUIRE_KU_ENCIPHERMENT.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18064 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-09-11 06:35:53 +00:00
Love Hörnquist Åstrand
69b7cec07b Reshuffle the prompter types, remove the hidden field.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17551 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-05-12 10:13:18 +00:00
Love Hörnquist Åstrand
775dc15b9b Make hx509_prompt.reply not a pointer.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17415 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-05-03 16:38:32 +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
3a78c8c3a4 Add hx509_request.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16964 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-04-02 20:15:14 +00:00
Love Hörnquist Åstrand
e0955cb5ba Add hx509_query.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16808 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-03-26 23:33:55 +00:00
Love Hörnquist Åstrand
da94d04998 Add hx509_revoke_ctx.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16596 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-01-18 20:49:21 +00:00