Commit Graph

20 Commits

Author SHA1 Message Date
Nicolas Williams
5f63215d0d Always perform == or != operation on cmp function result
Although not required to address bad code generation in
some versions of gcc 9 and 10, a coding style that requires
explicit comparison of the result to zero before use is
both clearer and would have avoided the generation of bad
code.

This change converts all use of cmp function usage from

```
    if (strcmp(a, b) || !strcmp(c, d)) ...
```

to

```
    if (strcmp(a, b) != 0 || strcmp(c, d)) == 0
```

for all C library cmp functions and related:

 - strcmp(), strncmp()
 - strcasecmp(), strncasecmp()
 - stricmp(), strnicmp()
 - memcmp()

Change-Id: Ic60c15e1e3a07e4faaf10648eefe3adae2543188
2021-11-24 22:30:44 -05:00
Nicolas Williams
b193d75a15 hx509: Revamp name handling ahead of new SAN types 2021-01-15 13:21:18 -06: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
Love Hornquist Astrand
029de6cfa4 pass back an heim_error from hx509_cert_init 2012-10-07 06:33:13 -07:00
Love Hornquist Astrand
0879b9831a remove trailing whitespace 2011-05-21 11:57:31 -07: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
7fee3c4315 fix sort order
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23942 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-10-19 03:25:45 +00:00
Love Hörnquist Åstrand
85f2710a83 check transative properties of name compare function
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23873 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-10-08 16:14:13 +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
f6cbb2eaa5 update (c)
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19882 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-13 01:02:57 +00:00
Love Hörnquist Åstrand
4b12f3487c less printing
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19881 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-13 01:01:53 +00:00
Love Hörnquist Åstrand
0d0948cd9e test name expansion
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19880 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-01-13 01:01:15 +00:00
Love Hörnquist Åstrand
87b7533d02 make hx509_parse_name take a hx509_context.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19597 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-12-30 23:04:54 +00:00
Love Hörnquist Åstrand
c0eada204f test printing and parsing raw oids in name.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19106 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-11-24 06:11:35 +00:00
Love Hörnquist Åstrand
0325e5dc59 Try to not leak memory.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18793 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-10-21 21:08:11 +00:00
Love Hörnquist Åstrand
701e7c5038 renamed one error code
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17404 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-05-01 15:28:14 +00:00
Love Hörnquist Åstrand
378ecba935 Test failure parsing name.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17292 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-04-26 20:07:48 +00:00
Love Hörnquist Åstrand
0117efb5aa test to parse and print name and check that they are the same.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17280 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-04-26 17:16:44 +00:00