Commit Graph

61 Commits

Author SHA1 Message Date
Nicolas Williams
168124cd09 hx509: Add hx509_cert_is_{ca,root,self_signed}()
These are convenient utility functions.
2022-12-19 16:21:42 -06:00
Nicolas Williams
ce1dd5fc76 hx509: Export missing CSR authz symbols 2022-12-05 23:01:52 -06:00
Nicolas Williams
264f0bd1a2 hx509: OpenSSL 3.0 support 2022-11-22 11:34:54 -05:00
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
5d939ba1b6 hx509: Make hxtool default store type to FILE
A common complaint about hxtool(1) is that if one fails to add a TYPE:
prefix to a CSR or certificate/private key store names, then hxtool
fails somewhat inscrutably.  We can't just fix hx509_certs_init() or
hx509_certs_append() because they default to "MEMORY" so who knows what
might break.  Instead we fix all uses of user-provided store names in
hxtool to have a FILE: prefix if no type was given.  For CSRs we'll
default to adding the only type prefix supported, "PKCS10".
2021-03-24 11:03:14 -05: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
dbb0463ca8 hx509: Add support for cert policies and mappings 2021-01-15 13:21:18 -06:00
Nicolas Williams
4f0249cd94 hx509/kdc: Move KDC CA utility function into hx509
This is part of the program to move REST services like bx509d out of
kdc/.
2020-09-08 00:25:24 -05: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
fce3f16859 hx509: Add hx509_ca_tbs_get_name()
This is so we can check if a TBS gets an empty subject name, then refuse
to issue the certificate if it doesn't also have at least one SAN.
2019-11-06 19:51:21 -06:00
Nicolas Williams
35c91324ed hx509: Add hx509_get_instance() 2019-11-02 18:49:42 -05:00
Nicolas Williams
6612090ba0 hx509: Export missing symbols 2019-11-02 18:49:42 -05:00
Nicolas Williams
8af2d79d35 hx509: Add missing CSR extension request support
This is necessary in order to add proper support for CSRs in kx509,
where the KDC can examine all requested KUs/EKUs/SANs, check
authorization, and issue a certificate with all those extensions if
authorized.

This is the convention used by OpenSSL, of encoding all the KU, EKUs,
and SANs being requested as Extensions as they would appear in the
TBSCertificate, then putting those in as a single Attribute in the CSR's
Attributes list with attribute OID {id-pkcs-9, 14}.

 - expose all hx509_request_*() functions
 - finish support in hx509_request_parse*() for KU, EKU, and SAN CSR
   attributes
 - finish support in hx509_request_to_pkcs10() for encoding all
   requested KU, EKU, and SAN extensions as a CSR extReq (extension request)
 - add hx509_request_add_*() support for:
    - id-pkinit-san and ms-upn-pkinit-san
    - XMPP (Jabber) SAN
    - registeredID (useless but trivial)
 - add hxtool request-create options for all supported SANs
 - add hxtool request-create options for KeyUsage
 - add hxtool request-create options for ExtKeyUsage
 - add hxtool request-print support for all these things
 - fix bugs in existing id-pkinit-san handling

Possible future improvements

 - add HX509_TRACE env var and support (it would be nice to be able to
   observe why some certificate is rejected, or not matched in a query)
 - add testing that CSR creating and printing round-trip for all KUs,
   EKUs, and SANs
   (probably in tests/kdc/check-pkinit.in)
 - add testing that OpenSSL can print a CSR made by hxtool and
   vice-versa
 - hxtool ca: add KU sanity checking (via hx509_ca_sign() and/or friends)
   (don't allow encrypt for signing-only algs)
   (don't allow encrypt for RSA at all, or for RSA with small e exponents)
 - hxtool request-print: warn about all unknown attributes and
   extensions
 - hxtool ca: MAYBE add support for adding requested extensions from the
   --req=CSR
   ("Maybe" because CA operators should really verify and authorize all
    requested attributes, and should acknowledge that they have, and the
    simplest way to do this is to make them add all the corresponding
    CLI arguments to the hxtool ca command, but too, that is
    error-prone, thus it's not clear yet which approach is best.
    Perhaps interactively prompt for yes/no for each attribute.)
 - add additional SAN types:
    - iPAddress                 (useless?)
    - dNSSrv                    (useful!)
    - directoryName             (useless, but trivial)
    - uniformResourceIdentifier (useful)
 - it would be nice if the ASN.1 compiler could generate print
   functions..., and/or even better, to-JSON functions
 - it would be nice if we had a known-OID db, including the names of the
   types they refer to in certificate extensions, otherName SANs and CSR
   attributes, then we could generate a CSR and certificate printer for
   all known options even when they are not supported by the rest of
   Heimdal
    - and we could also get friendly names for OIDs, and we could
      resolve their arc names
    - longer term, we could also stand to add some ASN.1 information
      object system functionality, just enough to make
      lib/hx509/asn1_print awesome by being able to automatically decode
      all heim_any and OCTET STRING content (better than its current
      --inner option)
2019-10-08 22:20:40 -05:00
Nicolas Williams
25dbe28291 hx509: SANs are critical if DN is empty 2019-10-07 21:32:00 -05:00
Nicolas Williams
d13f89cb11 hx509: expose hx509_request_parse*() 2019-10-03 13:09:18 -05:00
Nicolas Williams
41fcafd20c hx509: add hx509_certs_destroy() 2019-10-03 13:09:18 -05:00
Nicolas Williams
859c587dc2 Add more hxtool EKU options, and KeyUsage too
This is necessary in order to have more control over, e.g., template
certificates for kx509.  But also it's good to have this more generally.

Some batteries not included.  Specifically: no attempt is made to validate that
given KeyUsage values are compatible with the subjectPublicKey's alrogithm and
parameters.
2019-10-03 13:09:18 -05:00
Nicolas Williams
252487dfe4 hx509: support reading private keys from PEM files
This commit adds:

 - hx509_cert_init_private_key() for creating an hx509_cert object that
   has just a private key

 - hx509_cert_have_private_key_only() for checking whether an hx509_cert
   object has just a private key

This also generalizes the get_key() internal function in hxtool, which
is tasked with reding or generating a private key for use in signing
CSRs.  Now hxtool request-create can read/write private keys to/from PEM
files, not just DER files.

This is needed to support key types other than just RSA for CSRs and
certificates.
2019-10-03 13:09:18 -05:00
Nicolas Williams
32bc4083c4 libhx509: export some missing symbols 2019-07-09 12:34:26 -05:00
Ed Maste
8ef0071d96 Remove duplicate symbols from libhx509 version-script.map
Commit 7758a5d0 (r21331) added semiprivate function
_hx509_request_to_pkcs10 twice.
2016-07-21 14:39:37 -04:00
Jelmer Vernooij
cc495fd78d Avoid breaking symbol names for all previously present functions.
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
Signed-off-by: Nicolas Williams <nico@cryptonector.com>
2014-03-24 22:45:13 -05:00
Jeffrey Altman
f3d9d4119e export hx509_ca_tbs_set_signature_algorithm
hx509_ca_tbs_set_signature_algorithm was added by commit
c69c4634ad.  It must be exported
for use by hxtool on Windows.

Change-Id: I14b927abde96814ae2e0a90f232ab00915a9f29e
2014-02-16 21:01:57 -05:00
Patrik Lundin
0ff637618e add version print 2013-05-01 13:46:35 -07:00
Jelmer Vernooij
36ade8b509 hx509: Make various functions used by Samba public.
* hx509_cert_public_encrypt
* hx509_parse_private_key
* hx509_private_key_assign_rsa
* hx509_private_key_free
* hx509_private_key_private_decrypt
* hx509_private_key_init
* hx509_private_key2SPKI
* hx509_request_get_name
* hx509_request_get_SubjectPublicKeyInfo
* hx509_request_free
* hx509_request_init
* hx509_request_set_name
* hx509_request_set_SubjectPublicKeyInfo

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2011-02-23 19:47:28 -08:00
Matthieu Patou
8ce821c387 heimdal: make some private key manipulation function public
Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2011-01-26 12:03:50 -08:00
Matthieu Patou
4c507594d3 heimdal: make hx509_cert_public_encrypt public
Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2011-01-26 12:03:35 -08:00
Love Hornquist Astrand
49ca1a40fa export hx509_find_private_alg 2011-01-12 17:49:12 +01:00
Love Hornquist Astrand
6f328a9194 add padding support via hx509_crypto_set_padding 2010-09-22 14:41:17 -07:00
Love Hornquist Astrand
94c720a453 add new symbols 2010-08-10 09:22:30 -07:00
Love Hornquist Astrand
2a842e90d3 Drop MD2 support
Patch partly from Guillaume Rousse
2010-04-28 22:10:27 +02:00
Love Hornquist Astrand
f45766eda0 add hx509_certs_iter_f 2009-11-22 13:54:02 -08:00
Love Hornquist Astrand
ec47674c2b expose hx509_certs_ref 2009-09-29 09:42:15 -07:00
Love Hornquist Astrand
b9c11926f7 add hx509_print_cert 2009-09-21 06:24:14 -07:00
Love Hörnquist Åstrand
2f58f14e09 add hx509_peer_info_add_cms_alg and sort
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25256 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-05-28 01:21:39 +00:00
Love Hörnquist Åstrand
bbfb5e38e7 export hx509_crypto_allow_weak
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24817 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-27 03:23:48 +00:00
Love Hörnquist Åstrand
02dab69819 hx509_cms_create_signed;
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24755 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-16 19:13:55 +00:00
Love Hörnquist Åstrand
f374e9b14f add hx509_certs_filter
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24584 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-02-04 22:05:08 +00:00
Love Hörnquist Åstrand
ba69102e6b add flags to hx509_cms_verify_signed
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24192 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-12-15 04:30:52 +00:00
Love Hörnquist Åstrand
b1f885befe use rk_undumpdata, spelling
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23413 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-07-26 18:34:53 +00:00
Love Hörnquist Åstrand
75ea702745 new version
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23315 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-06-23 04:30:31 +00:00
Love Hörnquist Åstrand
e4549b08d5 add missing symbols
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22689 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-03-16 11:35:21 +00:00
Love Hörnquist Åstrand
00f8b507cb rename to be more consistent, export for teting
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22679 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-03-14 14:52:48 +00:00
Love Hörnquist Åstrand
90c30290de Export hx509_query_match_expr.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22678 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-03-14 01:23:04 +00:00
Love Hörnquist Åstrand
d635542a92 add hx509_pem_read
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22662 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-02-26 16:19:36 +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
a4bfd78fb7 Export hx509_free_error_string().
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22480 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-01-18 11:15:49 +00:00
Love Hörnquist Åstrand
1514df0d1b only export C_GetFunctionList
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22476 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-01-17 11:27:56 +00:00
Love Hörnquist Åstrand
c9f443454e Add a PKCS11 provider supporting signing and verifing sigatures.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22435 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-01-14 20:53:56 +00:00
Love Hörnquist Åstrand
7e262db693 Replace hx509_name_to_der_name with hx509_name_binary.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22431 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-01-13 14:07:41 +00:00