Commit Graph

17873 Commits

Author SHA1 Message Date
Luke Howard
ef906991fd asn1: don't include decoration header for void *
If the decorated external type is a void *, don't include the decoration
header in the ASN.1 header, only in the template implementation. This allows
the copy constructor and destructor to be implementation private.
2022-01-11 09:57:11 -06:00
Nicolas Williams
df3e08485b asn1: Add support for decoration w/ external types
This adds support for asn1_compile --decorate=... variation that causes
decoration of an ASN.1 SET/SEQUENCE type with a field of a non-ASN.1
type.

This means we can now have an ASN.1 type to represent a request that can
then have a "hidden" field -- hidden in that it is neither encoded nor
decoded.  This field will be copied and freed when the decoration is of
an ASN.1 type or of a external, C type that comes with copy constructor
and destructor functions.  Decoration with a `void *` field which is
neither copied nor freed is also supported.

We may end up using this to, for example, replace the `hdb_entry_ex`
type by decorating `HDB_entry` with a C type that points to the `HDB` in
which the entry was found or to which it should be written.
2022-01-11 09:57:11 -06:00
Luke Howard
2520c30b28 base: harmonize implementation/headers
heim_retain() should both accept and return a heim_object_t; harmonize this
across header and implementation
2022-01-08 17:40:22 +11:00
Luke Howard
a96f87c4ab asn1: don't clobber checked in files in clean target
Fix regression introduced in 9427796f, where checked in files matching asn1_*.c
would be clobbered by "make clean".

Change-Id: Ifc4bbe3c46dd357fdd642040ad964c7cfe1d395c
2022-01-08 17:38:46 +11:00
Nicolas Williams
472509fd46 gsskrb5: Do not leak authenticator on retry
We have a Heimdal special where when the acceptor sends back an error
token for clock skew or ticket-not-yet-valid errors then the acceptor
application will get GSS_S_CONTINUE_NEEDED from gss_accept_sec_context()
so that the initiator may retry with the same context.

But we were retaining the auth_context, which means that when the
initiator does send a new token, the acceptor leaks memory because
krb5_verify_ap_req2() doesn't clean up the auth_context on reuse.  The
end result is that we leak a lot in those cases.
2022-01-07 21:04:19 -06:00
Nicolas Williams
2d83a0b8cd gss: Make sure to indicate PAC buffers 2022-01-08 10:38:01 +11:00
Nicolas Williams
c2e3c5b66e gss: Add way to set authenticator authz-data
Now we can set Authenticator authorization-data with
gss_set_name_attribute().
2022-01-08 10:38:01 +11:00
Nicolas Williams
fe11481cc5 gss: Make krb5 name attrs table-driven
The implementation of GSS name attributes for Kerberos (or any mechanism
with more than a tiny handful) is much nicer as a table-driven
implementation.

We now have stubs for setting and deleting attributes as well, though
these currently always fail.
2022-01-08 10:38:01 +11:00
Luke Howard
27d62bb27e gss: avoid showing PAC in test_context if anon
The Heimdal KDC does not add a PAC if an anonymous ticket was issued. As such,
test_context should not expect PAC naming attributes to be present if the
--anonymous option was passed. (This is irrelevant for now as GSS_C_ANON_FLAG
is not honored by the krb5 mechanism.)
2022-01-08 10:12:07 +11:00
Luke Howard
402884a310 gss: validate attr enumeration in test_context
Ensure the "urn:mspac:client-info" name attribute is enumerated by
gss_inquire_name(), as well as being available via gss_get_name_attribute().
2022-01-08 09:38:30 +11:00
Luke Howard
e5e87497b1 hdb: use memset_s to zero HDB keys 2022-01-08 08:49:45 +11:00
Nicolas Williams
768d193e01 krb5: Fix warnings (from 54581d2d) 2022-01-06 16:24:08 -06:00
Nicolas Williams
2b9b701dc4 gss: Fix warnings (from be708ca3cf) 2022-01-06 16:21:55 -06:00
Nicolas Williams
3af6926c7d gss: Fix sign extension bug (from be708ca3cf)
When unsigned char values are shifted, they are promoted to int (unless
sizeof(int) == sizeof(char)).  This means that the change in be708ca3cf
ultimately leads to a sign extension bug.
2022-01-06 15:25:38 -06:00
Luke Howard
e06eeb5256 roken: use %zu format string for size_t 2022-01-06 22:36:48 +11:00
Luke Howard
90704baf76 asn1: use %zu format string for size_t 2022-01-06 17:52:09 +11:00
Luke Howard
0a4830068f roken: use %zu format string for size_t 2022-01-06 17:52:00 +11:00
Luke Howard
97cca6f921 base: use uintptr_t for hash type
Use uintptr_t for hash type; this is consistent with CoreFoundation, which uses
32-bit integers on 32-bit platforms for the hash code, and 64-bit integers on
64-bit platforms. (libheimbase is modelled on CoreFoundation.)

Previously we used unsigned long, which would have the same behavior on
LP32/LP64 systems, but not on Windows (where unsigned long is 32-bits on 64-bit
platforms).
2022-01-06 17:21:06 +11:00
Jeffrey Altman
6b788c2378 lib/asn1: template cast integer const to uintptr_t then void ptr
Cast integer constants to (void *) with an intermediate cast to
(uintptr_t).   On Windows this avoid warnings about a signed
integer being cast to a pointer of larger size.

No functional change.

Change-Id: I7289fb772870c5f492c1a8b988e0d80cf008b7f4
2022-01-05 19:56:43 -05:00
Nicolas Williams
2375fa9d1e gss: Too many compilers don't support 'restrict' 2022-01-05 18:03:39 -06:00
Nicolas Williams
01b1916ec2 asn1: Close _files output last 2022-01-05 17:50:00 -06:00
Jeffrey Altman
9427796f1a Generate .x source files as .c source files
The generated .x source and .hx header files are plain C source files.
Generate them as .c source files and avoid unnecessary file copying
and special makefile rules.

Change-Id: Ifc4bbe3c46dd357fdd642040ad964c7cfe1d395c
2022-01-05 17:36:24 -06:00
Jeffrey Altman
fb1ded497a lib/asn1: gen_template cast integer const to uintptr_t then void ptr
When generating code cast integer constants to (void *) with an
intermediate cast to (uintptr_t).   On Windows this avoid hundreds
of warnings about a signed integer being cast to a pointer of larger
size.

No functional change.

Change-Id: Ifd2acd0cfe99a7859aad58e79ab0f0c12b28fdeb
2022-01-05 12:58:48 -06:00
Jeffrey Altman
42ad8b4c55 lib/asn1: build static runtime version of libasn1 on Windows
This commit builds a static runtime version of the asn1 library
which is required for some thirdparty applications.

  LIBASN1_S   =$(LIBDIR)\libasn1_s.lib

This differs from libasn1.lib which is compiled to use the
dynamic runtime.

Change-Id: Ib04f5b53a7f16d7bbe9d2debb75e944322a6792a
2022-01-05 12:58:48 -06:00
Jeffrey Altman
6694f98791 lib/asn1: gen require ASN1_LIB be defined on Windows when compiling
Instead of defining ASN1_LIB in each of the generated ASN1 source
files require that the generated source file be compiled with the
ASN1_LIB symbol defined (on Windows).  All of the compiled objects
linked into the same library which might be accessing an ASN1 exported
symbol must have ASN1_LIB defined to ensure that the use of the
exported symbols will not be via an import.

Change-Id: Ie38c105d1d376419717fce0830dc28f5b82547d4
2022-01-05 12:58:48 -06:00
Jeffrey Altman
4f4d1a0288 lib/hdb: define LIB_ASN1 on Windows if ASN1 generated objects
The LIB_ASN1 definition instructs the library objects to access
exported ASN1 generated DATA symbols as internal symbols.

Change-Id: I58b055808893c6f3af48fc2dd997e0dedea2ffcb
2022-01-05 12:58:48 -06:00
Jeffrey Altman
3efca1e98a lib/gssapi: define LIB_ASN1 on Windows if ASN1 generated objects
The LIB_ASN1 definition instructs the library objects to access
exported ASN1 generated DATA symbols as internal symbols.

Change-Id: Ia8c674c879c9bc46ca9dc7f249114f22b1d0dfd5
2022-01-05 12:58:48 -06:00
Jeffrey Altman
0a7d227788 lib/asn1: define LIB_ASN1 when building Windows ASN1 libraries
The LIB_ASN1 definition instructs the library objects to access
exported DATA symbols as internal symbols.

Change-Id: Ifbc80a4e3c357cb323f7763c116101ae495b11df
2022-01-05 12:58:48 -06:00
Jeffrey Altman
a4ba38ff7e asn1: NTMakefile include oid_resolution.obj in LIBASN1_OBJS
oid_resolution.obj does not depend upon $(LIBASN1_OBJ) object
files.  It depends upon the generated .x files produced by
asn1_compile.exe when building $(gen_files_xxx).   Create a
new list of those dependencies explicitly for oid_resolution.obj.

Change-Id: I09a4dc9efb7a84e68da939b6a3ec5f55354c02ee
2022-01-05 12:58:48 -06:00
Luke Howard
ec866e635e Windows 10 SDK build fixes
Build without Win32.mak, and using Universal C Runtime (UCRT)

windows: Check for APPVER, not VCVER for UCRT

When deciding whether UCRT is used (and thus no CRT merge modules), check for
Windows 10 rather than the version of Visual Studio, as we may be building with
an older SDK.
2022-01-05 12:58:48 -06:00
Luke Howard
06f8985c55 hdb: consolidate preauth audit event types
Instead of having distinct preauth success/failure events for different
mechanisms, have a single event; the mechanism can be disambiguated by querying
the HDB_REQUEST_KV_PA_NAME key.

Note: there is still an explicit event for long-term key-based success/failure
in order to help the backend implement lockout.

Audit failure (HDB_AUTH_EVENT_PREAUTH_FAILED) in the main preauth loop, rather
than in each mechanism. Success is still audited in the mechanism to allow
client pre-authentication success to be noted even if something subsequent
(e.g. encoding a reply, memory allocation) fails. The generic catch-all for
success remains.
2022-01-05 09:42:03 +11:00
Luke Howard
d90718c9b6 base: set HEIM_JSON_F_NO_DATA_DICT in heim_audit_setkv_object()
Fixes pretty-printing data print to work with heim_audit_setkv_object() as well
as heim_audit_addkv_object().
2022-01-04 06:30:32 +00:00
Luke Howard
503cb27740 base: add heim_data_t support to heim_audit_trail()
Allow heim_audit_trail() to log heim_data_t types.
2022-01-04 17:17:56 +11:00
Luke Howard
2574648308 base: pretty-print heim_data_t when debug logging 2022-01-04 17:10:33 +11:00
Luke Howard
466658e929 Revert "Windows 10 SDK build fixes"
This reverts commit ceef0a0089.
2022-01-04 14:44:13 +11:00
Luke Howard
6d505df510 gss: link test_names.exe against Heimdal DLL 2022-01-04 14:35:28 +11:00
Nicolas Williams
b102c3c27f krb5: Fix canon name w/ attrs issue 2022-01-03 20:39:12 -06:00
Nicolas Williams
9e683f3d9a asn1: Fix template decoration copy moar 2022-01-03 20:39:12 -06:00
Luke Howard
efdd0bda24 base: export heim_audit_addkv_{number,object} 2022-01-04 02:22:23 +00:00
Luke Howard
daf1eacfdb base: cast int64_t to long long
In heim_audit_{add,set}kv_number, cast int64_t to long long/use %lld format
string, to avoid compiler warnings.
2022-01-04 13:12:41 +11:00
Luke Howard
4803969580 gssapi: add name_attrs.c to Windows build 2022-01-04 13:06:48 +11:00
Luke Howard
e0ea123e1c asn1: export CompositePrincipal on Windows
Export CompositePrincipal functions on Windows, because libasn1
functions are explictiyl exported (unlike with libtool).
2022-01-04 13:06:02 +11:00
Luke Howard
3b7a17e8b1 base: heim_audit_{add,set}kv_number should take int64_t
heim_number_t holds int64_t, not intptr_t; adjust heim_audit_{add,set}kv_number
accordingly. The libkdc wrapper functions were previously updated.
2022-01-04 12:35:57 +11:00
Luke Howard
81708f9f39 base: add heim_audit_addkv_{number,object} 2022-01-04 12:35:55 +11:00
Luke Howard
a8ff420b16 kdc: add attribute dictionary to kdc_request_t
Add a heim_dict_t to the KDC request structure for use by pre-authentication
mechanisms and plugins.
2022-01-04 12:27:43 +11:00
Luke Howard
b27026996a base: s/addkv_{bool,number,object}/setkv
Now heim_audit_addkv() correctly supports multiple values, the other functions
that (by design) replace existing values with a single value should use the
heim_audit_setkv prefix.

A subsequent commit could add variants that support multiple values for
non-string types.
2022-01-04 09:07:10 +11:00
Luke Howard
c8656863ba base: factor out addkv() array promotion logic 2022-01-04 09:07:10 +11:00
Luke Howard
ceef0a0089 Windows 10 SDK build fixes
Build without Win32.mak, and using Universal C Runtime (UCRT)

windows: Check for APPVER, not VCVER for UCRT

When deciding whether UCRT is used (and thus no CRT merge modules), check for
Windows 10 rather than the version of Visual Studio, as we may be building with
an older SDK.
2022-01-03 09:25:18 -05:00
Jeffrey Altman
95021a3284 roken: ndbm_wrap support for db6
use the db6/db.h header if present on the system.
2022-01-03 18:09:08 +11:00
Luke Howard
77f33c1fde base: preserve multiple values in heim_audit_vaddkv()
Previously, if heim_audit_vaddkv() was called multiple times, values would be
concatenated; since changing the request kv type to a dictionary, only the most
recently set value was preserved.

Fix this by promoting multi-valued values to an array of values, which is
visualized in the same manner as it was prior to b1dcc1a4.
2022-01-03 16:35:36 +11:00