Commit Graph

16856 Commits

Author SHA1 Message Date
Luke Howard
cf940e15f4 krb5: rename constrained-delegatiom to cname-in-addl-tkt
For consistency with [MS-SFU] rename the constrained-delegation KDC option to
cname-in-addl-tkt (client name in additional ticket).
2019-06-02 14:44:11 +10:00
Isaac Boukris
ea7615ade3 Do not set anonymous flag in S4U2Proxy request
It is not specified in MS-SFU, Apple dropped it as well and
it now breaks master branch.

Signed-off-by: Isaac Boukris <iboukris@gmail.com>
2019-06-01 11:14:27 -04:00
Rod Widdowson
e143639400 Windows: Windows CRT doesn't support %k as format for strftime
The fix involves:
  - Removing HAVE_STRFTIME from config.h.w32
  - Adding strftime.c to the makefile
  - Defining timezone and tzname to their windows equivalent
    for the compile of this module
2019-05-22 09:47:59 -04:00
Jeffrey Altman
b276d139ef lib/krb5: add plugin headers to Makefiles
Change-Id: I6701035da2e7ff3f83feee6cbb4921e5bd5dfd75
2019-05-21 22:20:14 -04:00
Jeffrey Altman
434b34d71c lib/krb5: prevent build failures of krb5_plugin_common on Windows
The Microsoft compiler cannot handle multiple const modifiers
for the same type.    It is also unhappy with the output pointer
parameter being declared const.

This change introduces new typedefs and cast of the dlsym() return
type to prevent warnings.

Change-Id: Ia92645efab8d2ec6745339a6f47c690782ae730a
2019-05-21 22:20:14 -04:00
Jeffrey Altman
ac6fa4cadc lib/krb5: prepare to make common plugins public
Rename common_plugin_ftable to krb5_plugin_common_ftable.

Create lib/krb5/common_plugin.h to include the structure and typedef.

The common_plugin.h header is now included by ccache_plugin.h
along with a prototype for the required ccache_ops_plugin_load()
function.

Change-Id: I2b27d6d0f5cf0544482c3f01784fef945e12e8d8
2019-05-21 22:20:14 -04:00
Jeffrey Altman
df78c88cc0 lib/krb5: common_plugin_ftable_desc funcs KRB5_LIB_CALL
As with the krb5plugin_an2ln_ftable_desc, krb5plugin_db_ftable_desc,
and krb5plugin_kuserok_ftable_desc the function pointers in
common_plugin_ftable_desc must be annotated with KRB5_LIB_CALL.

Change-Id: Ia7ea78743ee9eb8c7f6b648063852ca91a360d2c
2019-05-21 22:20:14 -04:00
Jeffrey Altman
32fe791c2e lib/krb5: common plugin only fallback if load_fn() fails
Only fallback to loading the plugin function table directly if
if the initialization function is not exported.  Failing a
consistency check should not permit falling back to a potentially
incompatible function table.

Change-Id: Ic753ed9a090aef6073853f7309f0f8f0f29d0aa9
2019-05-21 22:20:14 -04:00
Jeffrey Altman
cc2070dbc8 lib/krb5: fix krb5_get_instance_func_t prototype
KRB5_LIB_CALL not KRB5_CALLCONV

Change-Id: I31b8750d63849c2f5cce49642a63fd66e7fa1a32
2019-05-21 22:20:14 -04:00
Jeffrey Altman
22cf04fdaf lib/krb5: krb5.h missing KRB5_LIB_CALL definition
KRB5_LIB_CALL must be defined for out of tree users.

Change-Id: I10a02fdca3ed64093fabd8d391761448b9c480a5
2019-05-21 22:20:14 -04:00
Luke Howard
fd209c5dca krb5: set PKINIT_BTMM flag per Apple implementation 2019-05-18 23:19:06 -04:00
Luke Howard
8350f34a05 krb5: don't require krbtgt otherName match for Win2K
Merged from Apple branch: when the Win2K PKINIT compatibility option is set, do
not require krbtgt otherName to match when validating KDC certificate.
2019-05-18 23:19:06 -04:00
Isaac Boukris
b7fe0fb85a kdc: allow checksum of PA-FOR-USER to be HMAC_MD5
even if tgt used an enctype with a different checksum.

Per [MS-SFU] 2.2.1 PA-FOR-USER the checksum is always
HMAC_MD5, and that's what Windows and MIT clients send.

In heimdal both the client and kdc use instead the
checksum of the tgt, and therefore work with each other
but windows and MIT clients fail against heimdal KDC.

Both Windows and MIT KDC would allow any keyed checksum
to be used so Heimdal client work fine against it.

Change Heimdal KDC to allow HMAC_MD5 even for non RC4
based tgt in order to support per-spec clients.

Signed-off-by: Isaac Boukris <iboukris@gmail.com>
2019-05-18 22:33:48 -04:00
Luke Howard
014e318d6b krb5: check KDC supports anonymous if requested
Verify the KDC recognized the request-anonymous flag by validating the returned
client principal name.
2019-05-18 20:31:52 -04:00
Luke Howard
5c70e5015e hcrypto-pkcs11: check mechanism flags
Before committing to a PKCS#11 mechanism, check that it can provide the
required encryption or digest services by validating the flags returned by
C_GetMechanismInfo().
2019-05-18 17:15:26 -04:00
Luke Howard
dc791c8fcf krb5: remove duplicate KRB5_ANON_MATCH_xxx defines
Commit bdcd7d2f moved the KRB5_ANON_MATCH_xxx preprocessor symbols to krb5.h,
but did not remove the originals from krb5_locl.h. This commit removes them.
2019-05-18 13:57:43 +10:00
Jeffrey Altman
a1276c54aa krb5_sendto_kdc: Windows no KDC reachable error
The combination of 8740528b24
("Windows-compatible sentinel socket type and value") and
d497d7e4a7 ("krb5_sendto_kdc:
failover for multiple AAAA/A RRs on one domain") broke
all the send to kdc loop on Windows.  rk_socket_t is
a HANDLE and rk_INVALID_SOCKET is the max value.  Therefore,
no valid socket will be larger and all communications
will fail.

Change-Id: I3464f78d67b19f14050ad7a01738fb32bac99385
2019-05-16 12:09:59 -04:00
Jeffrey Altman
bdcd7d2f3d krb5_principal_is_anonymous
_krb5_principal_is_anonymous() is used outside lib/krb5 and
therefore it needs to be properly exported and its flag macros
need to be in a public header: krb5.h not krb5_locl.h.

Including krb5_locl.h from within kuser_locl.h for instance
results in build failures on Solaris.

This change renames the function and makes it part of the public
api.

Change-Id: I130d1698b10bdbd150b95e8c7d32dfc362889ce6
2019-05-16 16:23:20 +10:00
Daria Phoebe Brashear
c3e2c048c3 tests: generate test_template_asn1-template.c for testing
the rule to generate test_template_asn1-template.c from
test_template_asn1-template.x was missing. add it.
2019-05-15 14:12:28 -04:00
Luke Howard
38c797e1ae krb5: always confirm PA-PKINIT-KX for anon PKINIT
RFC8062 Section 7 requires verification of the PA-PKINIT-KX key excahnge
when anonymous PKINIT is used.  Failure to do so can permit an active
attacker to become a man-in-the-middle.

Introduced by a1ef548600.  First tagged
release Heimdal 1.4.0.

CVSS:3.0/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:N (4.8)

Change-Id: I6cc1c0c24985936468af08693839ac6c3edda133
Signed-off-by: Jeffrey Altman <jaltman@auristor.com>
Approved-by: Jeffrey Altman <jaltman@auritor.com>
2019-05-14 15:52:24 -04:00
Viktor Dukhovni
8740528b24 Windows-compatible sentinel socket type and value 2019-05-14 15:52:01 -04:00
Roland C. Dowdeswell
d497d7e4a7 krb5_sendto_kdc: failover for multiple AAAA/A RRs on one domain
We found that the libraries behaviour when dealing with domains with
more than one entry in them is slightly suboptimal.  The situation
was

kdc1		IN	A	1.2.3.4
kdc1		IN	AAAA	ff02::1

I.e. a single hostmame with both IPv6 and IPv4 addresses.  When we
run krb5_sendto_kdc on a box with only IPv4 addresses, there is a
3s delay before it fails back to the IPv4 address.  This is because
the library sets the 2nd address on each hostname to be 3s in the
future and each additional one another 3s.

We change wait_response() s.t. if one is able to make progress, we
iterate over the list of hosts and move them all 1s forward.  We
also modify submit_request() to skip hosts if host_connect() fails.
2019-05-14 15:52:01 -04:00
Luke Howard
5ca229e0d9 krb5: krb5_get_init_creds_opt_set_pkinit flag names
Add macros to give symbolic names to the flags which can be passed to
krb5_get_init_creds_opt_set_pkinit(). Reserve flags for BTMM and not validating
KDC anchors.
2019-05-14 15:16:19 -04:00
Luke Howard
bcc90f1b87 krb5: _krb5_principal_is_anonymous() helper API
Add _krb5_principal_is_anonymous() private API for checking if a principal is
anonymous or not. The third argument determines whether to match authenticated
anonymous, unauthenticated anonymous, or both types of principal.
2019-05-14 15:16:19 -04:00
Luke Howard
55ee6c1282 krb5: support for anonymous TGS requests
Add support to krb5_get_creds() for requesting anonymous service tickets using
a TGT, using the flag KRB5_GC_ANONYMOUS.
2019-05-14 15:16:19 -04:00
Luke Howard
1bc2eb33f9 krb5: fix spelling error in debug log 2019-05-14 15:16:19 -04:00
Jeffrey Altman
e60955e835 roken: getuserinfo WIN32 fix username string termination
95eb83c424 ("roken: Add roken_get_username() and friends")
failed to copy the username C-String NUL terminator.  As a result
a "DOMAIN\user" is returned as "userIN\user".

Change-Id: I10027e4eef18364074eecf385fa9fab1ae68dbe7
2019-05-02 13:42:01 -04:00
Rod Widdowson
f1b27d77cd Windows: Make getaddrinfo-test work
Before we call gettaddrinfo we have to call rx_SOCK_INIT

In order to exercise the test we have to supply parameters to the command line
2019-03-25 16:38:56 -07:00
Quanah Gibson-Mount
aad5c71014 Fixes https://github.com/heimdal/heimdal/issues/533
Update certs to no longer be expired, last 500 years.
2019-03-22 20:59:04 -04:00
Quanah Gibson-Mount
2d193d380d For https://github.com/heimdal/heimdal/issues/392
Correctly reference the OID so gen-cert.sh works correctly
2019-03-22 18:23:45 -04:00
Quanah Gibson-Mount
98f904036c For https://github.com/heimdal/heimdal/issues/392
Modern OpenSSL no longer has the 2038 year restriction.  Update the
certs to last 500 years rather than 10 years.

Modern crypto requirements suggest a stronger key strength than 1024.
Update to use a minimum of 4096.

Fix executable bit on gen-req.sh
2019-03-22 17:49:46 -04:00
Roland C. Dowdeswell
c827cd48f6 Optimise stdio krb5_storage by tracking offset 2019-03-21 11:23:39 -05:00
Roland C. Dowdeswell
56a32a8dbd krb5_storage: normalise truncate behaviour w.r.t. file offset
We choose a semantic for the file offset during truncate operations
which is to leave the offset as is unless it is off the end of the
file in which case we pull it back in to the end.  We update fd and
stdio handling to match the {,e}mem behaviour.
2019-03-21 11:23:39 -05:00
Roland C. Dowdeswell
b2332b9684 add a couple of tests to test_store.c for fd, stdio w.r.t. trunc 2019-03-21 11:23:39 -05:00
Jeffrey Altman
43a34f6663 roken: tsearch use rk_UNCONST instead of __DECONST #307
The rk_UNCONST macro exists because neither __DECONST nor uintptr_t
are available on all platforms (for example, AIX).

Change-Id: Ie36f0dd7a9ce454d411761ee4dbd6fc1f7c6692c
2019-02-21 15:46:51 -05:00
Jeffrey Altman
f0d9289d86 roken: fix strtoll
b10ad7eb57
("roken: strtoll.c negation is a no-op on unsigned integer")
broke strtoll() by failing to assign 'ret' in the success case.

Change-Id: I30535d83a2bef305140f1a6bd1ed2eeba23db9b9
2019-01-22 00:02:57 -05:00
Jeffrey Altman
9ce2683f2d roken: strtoull.c negation is a no-op on unsigned integer
strtoull() returns an unsigned long long.  However, then the input
string represents a negative number the return value is supposed to
be the unsigned representation of the negative value.  Before applying
the negation the value must be cast to (long long).

Change-Id: Icf9e75400ff736819b1f7e0e6fb3c8abd707a23a
2019-01-21 22:28:02 -05:00
Jeffrey Altman
b10ad7eb57 roken: strtoll.c negation is a no-op on unsigned integer
strtoll() returns a signed long long not an unsigned long long.
When applying the negation for negatives the value must be cast
from unsigned to signed and then stored in a signed variable
before returning it.

Change-Id: If568afd2509d27c7bf206ca59d32ca150cb34857
2019-01-21 22:25:19 -05:00
Jeffrey Altman
3bbd8663b0 WIN32: fix roken build
__declspec not _declspec

Include "err.h" not <err.h>

Include "roken.h" before "err.h"

Indent "#if" as "# if" within roken.h.in when CPP rules must be copied
into the generated "roken.h".

Correct verr() attribute to be ROKEN_LIB_NORETURN_FUNCTION.

Change-Id: I4289ecaba4a097175b4a5a1cde529b59038c72e3
2019-01-21 22:04:06 -05:00
Nicolas Williams
18226819cd ASN.1 compiler: check write errors 2019-01-15 13:21:25 -06:00
Nicolas Williams
a3a8c1e4a4 ASN.1: Support wider bit sets (fix #514) 2019-01-15 13:21:25 -06:00
Jeffrey Altman
a205fe17c6 lib/kadm5: WIN32 fix callback calling conventions
chpass_principal_with_key_hook_cb added by 57c25d9828 must be
KRB5_LIB_CALL for 32-bit Windows builds.

Change-Id: Ifd61caeee76f9d048bb13f93e226b99ce7e8b75c
2019-01-14 06:12:36 -05:00
Jeffrey Altman
387684aa93 WIN32: fix calling conventions for 32-bit builds
On 32-bit Windows Intel builds the __cdecl and __stdcall calling
conventions are different so labeling the functions that are
exported or assigned to function pointers matters.

Change-Id: I03b6f34baeb9ffb2e683fd979f12f27a5078a4da
2019-01-14 06:12:36 -05:00
Jeffrey Altman
dcfcdd00d8 lib/asn1: WIN32 suppress "unreferenced local variable" warning
the code generated by asn1_compile.exe includes a large number
of unreferenced local variables.  The resulting warnings drown
out other potentially more serious warnings.

This change suppresses the C4101 warnings in the generated
source files.

Change-Id: I17642ff427f457c885b1eb0e62436f3bc9057ee1
2019-01-14 06:12:36 -05:00
Jeffrey Altman
7d5b844538 lib/krb5: WIN32 disable warnings
Heimdal declares functions that never return as non-void.  Suppress
the following warnings now that functions are labeled 'noreturn'.

4646 - function declared with __declspec(noreturn) has non-void return type

4716 - 'function' must return a value

Change-Id: Id85cc435e99688bae7326a723a5a80d828859bf2
2019-01-14 06:12:36 -05:00
Jeffrey Altman
9d3e206b76 lib/krb5: WIN32 _krb5_load_plugins wrong constness
The 'plugin_prefix' variable was declared 'const' which generates
a warning because the C string is freed.

This change removes the 'const' designation.

Change-Id: I6f3838d6dbf1bb496f286c96aea96bae8948930d
2019-01-14 06:12:36 -05:00
Jeffrey Altman
9358747426 lib/gssapi/mech: gss_acquire_cred_from calling conventions
gss_acquire_cred_from() is an exported function and therefore
must be tagged with GSSAPI_LIB_FUNCTION and GSSAPI_LIB_CALL.

Change-Id: I80918cb8083eaeac2d0eba5347f7b428e997cfaa
2019-01-14 06:12:36 -05:00
Luke Howard
57c25d9828 kadm5: add chpass_with_key hook (#397)
Add a hook for changing a password with a key. This hook should be consolidated
into one shared with randkey and setkey, but for now I have continued to have
the hooks follow the kadm5 APIs themselves in both signature and quantity.

(This means the randkey one isn't actually very useful because it doesn't
provide the hook with the keys.)
2019-01-10 15:18:10 +11:00
Luke Howard
59ba12f832 kadm5: remove unused variable from sample_hook 2019-01-10 12:40:11 +11:00
Ake Sandgren
907b9ee6c4 Fix broken return from _krb5_erase_file on missing file.
The return of lstat should be handled like the "open" if errno = ENOENT.
2019-01-09 11:27:09 -06:00