Commit Graph

78 Commits

Author SHA1 Message Date
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
64d5f86ec3 Fix warnings (some bugs, some spurious)
Many spurious VC warnings not quieted though.
2020-03-12 21:02:09 -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
038ed5ec31 hx509: check Name RDN attribute size bounds 2019-10-07 21:32:00 -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
Nicolas Williams
943e76f99b Fix leak in hx509_general_name_unparse() 2016-11-20 17:43:51 -06:00
Nicolas Williams
1c81ddf4e2 Round #2 of scan-build warnings cleanup 2016-11-16 17:03:14 -06:00
Love Hornquist Astrand
4e44171a28 cast away enum warnings 2013-06-03 22:05:09 -07: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
Karolin Seeger
77a6204452 s4-heimdal: Fix typo in comment.
Karolin

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2010-09-26 15:08:28 -07:00
Love Hornquist Astrand
fa4c84e6d6 make printablestring and ia5string octetstrings 2010-08-08 15:51:33 -07:00
Love Hornquist Astrand
fd107d08c4 use case compare for teletex string 2010-05-01 11:47:02 +02:00
Love Hornquist Astrand
7b999148f8 Rename str to oid in the function namespace to avoid -Wshadow warning
Based on a report from Matthias Dieter Wallnöfer.
2009-10-03 11:35:45 -07:00
Love Hornquist Astrand
215b3813f6 teletexString is now a real string type 2009-09-30 00:54:13 -07:00
Love Hornquist Astrand
d3828fe201 Don't depend on that memcmp() have same return value on all platforms
BSDish libc returns -14 3 14, while GNU LIBC returns -1 3 1.
2009-08-14 05:34:50 +02:00
Love Hornquist Astrand
b1dc4dc97e (_hx509_Name_to_string): free memory on failure (that should not happen) [CID 176] 2009-07-30 07:25:36 +02:00
Love Hörnquist Åstrand
4cd4853c3b Use OID variable instead of function.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25244 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-05-28 01:19:22 +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
0efc14ab95 fix warning
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24478 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-01-25 20:49:13 +00:00
Love Hörnquist Åstrand
b2744f137f (c)
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24475 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-01-25 20:48:44 +00:00
Love Hörnquist Åstrand
92d16c8a19 use wind to convert strings
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24474 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-01-25 20:48:34 +00:00
Love Hörnquist Åstrand
dd23f4a8a9 free name on error, from coverity #115
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24090 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-12-11 04:57:58 +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
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
8b9c6c4121 Use ldap-prep (with libwind) to compare names
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22583 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-02-11 20:46:21 +00:00
Love Hörnquist Åstrand
7f8059130a Replace hx509_name_to_der_name with hx509_name_binary.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22432 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-01-13 14:08:03 +00:00
Love Hörnquist Åstrand
b3efcbda59 more documentation
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22327 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-12-15 04:49:37 +00:00
Love Hörnquist Åstrand
d651f2187d More documentation
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22275 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-12-11 11:02:11 +00:00
Love Hörnquist Åstrand
1a0d3ae4bc spelling.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22220 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-12-08 08:03:56 +00:00
Love Hörnquist Åstrand
382da5981b fix doxygen compiling.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22218 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-12-08 07:56:22 +00:00
Love Hörnquist Åstrand
0c2180d1de (_hx509_Name_to_string): make printableString handle space (0x20)
diffrences as required by rfc3280.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21797 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-08-02 22:20:25 +00:00
Love Hörnquist Åstrand
0f76edd889 (quote_string): don't sign extend the (signed) char to avoid printing
too much, add an assert to check that we didn't overrun the buffer.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20891 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-04 22:51:41 +00:00
Love Hörnquist Åstrand
fcc3edd1aa Use right element out of the CHOICE for printableString and utf8String
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20890 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-04 22:39:51 +00:00
Love Hörnquist Åstrand
4204cbd8b1 Reset name before parsing it.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20883 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-04 21:11:53 +00:00
Love Hörnquist Åstrand
5ed0a6bdd9 (hx509_general_name_unparse): unparse the other GeneralName nametypes.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20158 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-02-03 09:54:27 +00:00
Love Hörnquist Åstrand
7d4ebe6f73 (hx509_general_name_unparse): function for unparsing GeneralName, only
supports GeneralName.URI


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20099 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-31 15:33:04 +00:00
Love Hörnquist Åstrand
dd4af7d8b0 Add STREET.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19933 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-16 13:07:13 +00:00
Love Hörnquist Åstrand
ba9774453c (hx509_name_expand): if env is NULL, return directly
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19904 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-14 22:17:42 +00:00
Love Hörnquist Åstrand
8ddc5a6aa6 Remove abort, add error handling.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19885 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-13 12:13:37 +00:00
Love Hörnquist Åstrand
a7ffead44c add hx509_name_expand
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19879 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-13 01:00:06 +00:00
Love Hörnquist Åstrand
91a0892b93 constify
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19840 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-11 10:36:29 +00:00
Love Hörnquist Åstrand
5b9b07461e (hx509_name_cmp): add
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19815 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-10 21:44:25 +00:00
Love Hörnquist Åstrand
2dcbc1ab7e Split building RDN to a separate function.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19596 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-12-30 23:04:11 +00:00
Love Hörnquist Åstrand
05a31a062b (no): add S=stateOrProvinceName
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19311 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-12-11 19:03:44 +00:00
Love Hörnquist Åstrand
a111935bca Handle printing and parsing raw oids in name.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19105 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-11-24 06:09:48 +00:00
Love Hörnquist Åstrand
96204e40a8 prefix der primitives with der_
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18453 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-10-14 09:42:43 +00:00
Love Hörnquist Åstrand
bf89bf0115 (_hx509_Name_to_string): remove dup const
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18251 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-10-06 07:23:29 +00:00