Commit Graph

2111 Commits

Author SHA1 Message Date
Michael Tokarev
c80c04b235 spelling fixes (underun prefered relase encyption confunder)
[abartlet@samba.org: From Samba debian package at
 https://salsa.debian.org/samba-team/samba/-/blob/master/debian/patches/heimdal-spelling.patch?ref_type=heads]

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2024-06-16 23:28:43 -04:00
Nicolas Williams
3253c49544 hx509: Add support for CSRs w/ BasicConstraints (fix) 2023-11-29 13:16:16 -06:00
Joseph Sutton
e8b42d9d42 hx509: Fix incorrect documentation comment
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:37:56 -05:00
Joseph Sutton
bbe9c83b19 hx509: Remove unused variable
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:37:56 -05:00
Joseph Sutton
59f89e4b15 hx509: Avoid misleading error message
If ‘keyid’ is an empty string, then the numeric error code that gets
appended to this error message may be mistaken for the key ID. Address
this by not mentioning any ID in such cases.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:37:56 -05:00
Joseph Sutton
df6c33ff1e hx509: Use NULL pointer constant
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:37:56 -05:00
Joseph Sutton
05602c2286 hx509: Fix code spelling
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:34:35 -05:00
Joseph Sutton
ef083a0e2c hx509: Fix code spelling
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:34:35 -05:00
Joseph Sutton
61bf5009a0 hx509: Fix spelling of error messages
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:34:35 -05:00
Nicolas Williams
2ad736a579 hx509: Fix EACCES / ENOMEM confusion 2023-11-08 14:22:02 -06:00
Nicolas Williams
be0d1e68e5 hx509: Add support for CSRs w/ BasicConstraints 2023-11-08 14:22:02 -06:00
Joseph Sutton
a840986dc0 hx509: Check return value of RAND_bytes()
Found by Coverity (Samba CID 1544600).

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Joseph Sutton
d1b9d2c2f9 hx509: Add missing format specifier
Found by Coverity (Samba CID 1544604).

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Joseph Sutton
7ee2ddd71a hx509: Use correct format specifier
Found by Coverity (Samba CID 1544606).

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Joseph Sutton
13f96a2c89 hx509: Don’t pass excess arguments to variadic functions
Found by Coverity (Samba CID 1544609).

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Joseph Sutton
d71035e2d1 hdb: Initialize ‘tm’ structure
‘tm’ must be initialized prior to calling strptime().

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Taylor R Campbell
ca0e53b64f Pass -d to yacc(1) so it generates the header file.
Bison must generate this unsolicited, but BSD yacc does not.

The makefiles for lib/com_err and lib/sl already did this; this
change just adds it to lib/asn1 and lib/hx509 too.

fix https://github.com/heimdal/heimdal/issues/1100
2023-06-21 16:07:16 -05:00
Robert Manner
e8e8b78d65 hx509/hxtool.c: ensure parse_bytes() result does not overflow 2023-06-20 12:57:28 -05:00
Taylor R Campbell
a142767598 Fix ctype.h misuse.
Excluded: libtomath and libedit files, most of which appear to be
testing or example code not involved in production, and which are
derived from an upstream that should perhaps have patches submitted
upstream instead.

fix https://github.com/heimdal/heimdal/issues/1111
2023-05-26 14:10:11 -05:00
Nicolas Williams
485b5d575a hxtool: Check hx509_request_init() return 2023-01-04 16:17:57 -06:00
Nicolas Williams
8b44896bc1 hx509: Fix harmless TOCTOU in load_crl() 2023-01-04 00:43:35 -06:00
Nicolas Williams
64254d64dd hx509: Fix ENOMEM free of garbage encoding PKCS#10 2023-01-04 00:43:35 -06:00
Nicolas Williams
1473b96d1c hx509: Fix leak in templated certificates 2023-01-04 00:43:35 -06:00
Nicolas Williams
06fdd14d4d hx509: Quiet static analyzer false positives 2023-01-04 00:43:35 -06:00
Nicolas Williams
42fff5ec5f hx509: Add content and some EXAMPLES to hxtool(1)
hxtool is a very useful command, with a very user-friendly interface, at
least compared to OpenSSL's openssl(1).  We should document it better.

Currently there are no manual pages for hxtool(1)'s subcommands, though
their --help message is pretty self-explanatory.  Now the hxtool(1) page
provides better clues to the user, including examples.
2022-12-19 17:03:38 -06:00
Nicolas Williams
d24b7fd8b2 hx509: Add hxtool cc --no-root-certs, --no-private-keys, and --append options 2022-12-19 16:26:03 -06:00
Nicolas Williams
6def4750bc hx509: Add HX509_CERTS_STORE_NO_ROOTS flag
This will allow us to add a --no-roots option to

    hxtool copy-certificate

which is convenient when copying certificate chains from stores that may
include root CA certificates.
2022-12-19 16:24:23 -06:00
Nicolas Williams
49c00512a7 hx509: Don't check if non-self-signed certs have a self-signing capable signature alg
We don't need the _hx509_self_signed_valid() check if the certificate is
not self-signed.
2022-12-19 16:23:03 -06:00
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
4da64d119e hx509: Return better error in CSR authorization functions 2022-12-05 23:01:52 -06:00
Nicolas Williams
ce1dd5fc76 hx509: Export missing CSR authz symbols 2022-12-05 23:01:52 -06:00
Nicolas Williams
5dd018b7ed hx509: Get i2d_PUBKEY() prototype from correct header 2022-11-22 15:33:03 -06:00
Nicolas Williams
264f0bd1a2 hx509: OpenSSL 3.0 support 2022-11-22 11:34:54 -05:00
Nicolas Williams
0d5b238186 hx509: PKCS#12 missing error check 2022-11-22 11:34:54 -05:00
Nicolas Williams
cce8ae9927 hx509: Pass PKCS#8 keys to lower layers
OpenSSL's d2i_ECPrivateKey() is deprecated, so we have to use
d2i_PrivateKey(), but d2i_PrivateKey() wants the whole PKCS#8 blob so it
can know what kind of key it is.  So we need to let the hx509 EC layer
get that blob.  The internal APIs need some refactoring, so for now we
use a hack where we try to parse the private key with and without the
PKCS#8 wrapper.
2022-11-22 11:34:54 -05:00
Daria Phoebe Brashear
76c110e1ef hx509: hx509_verify_path remove spurious fallthrough
fallthrough needs to be directly before the next case, and this duplicate
inside an else is unneeded
2022-09-16 15:58:45 -04:00
Daria Phoebe Brashear
133f517482 rewrite fallthrough to HEIM_FALLTHROUGH to deal with new Apple SDKs
Apple clang version 14.0.0 (clang-1400.0.17.3.1) fails the build
because stds.h defines `fallthrough` as a macro which is then
expanded when base.h evaluates

  # if __has_attribute(fallthrough) && __clang_major__ >= 5

The macOS SDK defines `DISPATCH_FALLTHROUGH` as the macro instead
of `fallthrough`.

This change replaces the use of `fallthrough` in the tree with
`HEIM_FALLTHROUGH` and updates the declaration in configure logic
to define `HEIM_FALLTHROUGH` based upon existing definitions
(if any) of `fallthrough` or `DISPATCH_FALLTHROUGH`.
2022-09-16 15:58:45 -04:00
Nicolas Williams
f40ac787b1 hxtool: Allow ca command to generate subject key
This commit makes the hxtool ca sub-command, when invoked with
--generate-key=TYPE and --certificate-private-key=STORE, write the
private key only to the given --certificate-private-key store and not
also the --certificate=STORE.

Before this commit, invoking the hxtool ca sub-command with both,
--generate-key=TYPE and --certificate-private-key=STORE, caused the
--generate-key option to be ignored and the private key to be read from
the given store and copied to the --certificate=STORE.  That was clearly
a bug and non-sensical.
2022-08-10 19:07:54 -05:00
Nicolas Williams
9c0bc47efc Add hxtool(1) manual page 2022-08-07 18:59:28 -05:00
Nicolas Williams
563964ce96 hx509: Use %left for ! instead of %precedence 2022-01-21 23:34:40 -06:00
Nicolas Williams
88e31d2da8 sl: Add missing sel-gram.h target 2022-01-21 23:15:21 -06:00
Nicolas Williams
664b749399 hx509: Fix sel-gram.y shift/reduce conflicts
AND and OR are now binary operators, left-associative, with AND having
higher precedence than OR.

The not operator is now higher-precedence than the AND and OR operators.
2022-01-21 22:58:22 -06:00
Jeffrey Altman
04527412e3 Follow the Linux kernel's lead on "fallthrough"
The pseudo keyword 'fallthrough' is defined such that case statement
blocks must end with any of these keywords:
 * break;
 * fallthrough;
 * continue;
 * goto <label>;
 * return [expression];
 *
 *  gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes

The macro is defined either as

  __attribute__((__fallthrough__))

or as

  do {} while (0)  /* fallthrough */

not including the semicolon.

This change implements the Linux kernel style and updates several locations
where "/*fallthrough*/ and /* FALLTHROUGH */ were not previously replaced.

Externally imported code such as libedit, libtommath and sqlite are
restored to their unaltered state.

Change-Id: I69db8167b0d5884f55d96d72de3059a0235a1ba3
2022-01-21 10:39:47 -05:00
Nicolas Williams
dd71303a2f hx509: Fix coverity warnings 2022-01-17 17:36:48 -06:00
Nicolas Williams
4b7ad8ee43 hx509: Fix strerror(negative); streamline code
Calling strerror() with a negative value is an error.

Besides fixing that, we streamline hx509_get_error_string(), making it much
simpler and easier to read.
2022-01-17 15:17:33 -06:00
Jeffrey Altman
401bdd8bf3 lib/hx509: hx509_request_get_san SAN_TYPE_PKINIT return failure
if _hx509_unparse_KRB5PrincipalName() fails return the error code
to the hx509_request_get_san() caller.

Change-Id: I3ad8ceda23f00263890115f292ca7e4c8ce9317b
2022-01-16 22:43:02 -05:00
Jeffrey Altman
a73c45bef1 lib/hx509: hxtool test_crypto destroy 'vctx'
call hx509_verify_destroy_ctx to free 'vctx'

Change-Id: I4125a46760b8b988a63fb8d96d91a4a8b948b606
2022-01-16 22:11:28 -05:00
Jeffrey Altman
53e0b5448e lib/hx509: revoke_print addrof to hx509_revoke_free
1a793c04fa
("lib/hx509: revoke_print free revoke_context") forgot to pass
the address of 'revoke_ctx' to hx509_revoke_free().

Change-Id: I430a72a4dc7bce7099fc02bbe1feae625304a53a
2022-01-16 22:07:52 -05:00
Jeffrey Altman
603ee4d65d lib/hx509: _hx509_cert_to_env free 'buf'
The output buffer returned from hx509_name_to_string() must be
freed before it is overwritten by another call to
hx509_name_to_string().

Change-Id: Iaf28b14a2712cd28085ac5452819818e739d43ed
2022-01-16 21:59:49 -05:00
Jeffrey Altman
1a793c04fa lib/hx509: revoke_print free revoke_context
call hx509_revoke_free() to free the context.

Change-Id: I2f4439a848011cc0ab46f2802f5e4871baba348f
2022-01-16 21:53:06 -05:00