Commit Graph

29131 Commits

Author SHA1 Message Date
Luke Howard
c403b66082 hcrypto: import libtommath v1.2.0 2020-04-24 11:59:54 +10:00
Nicolas Williams
7181c109d0 Properly implement neg_mechs & GM_USE_MG_CRED (fix) 2020-04-21 19:51:55 -05:00
Nicolas Williams
e48e75cd22 Better support for "non-standard" GSS mechs (fix) 2020-04-21 19:51:16 -05:00
Luke Howard
3bfe62df6a gss: remove gss_release_cred_by_mech()
gss_release_cred_by_mech() was previously used by SPNEGO's implementation of
gss_set_neg_mechs(). This is now implemented in the mechanism glue. As we never
shipped gss_release_cred_by_mech(), it is safe to remove it and its exported
symbol.
2020-04-21 00:21:32 -05:00
Nicolas Williams
a54761d68a Properly implement neg_mechs & GM_USE_MG_CRED
SPNEGO was already using union creds.  Now make the mechglue know about
it, delete all of the cred-related SPNEGO stubs that are now not called
(lib/gssapi/spnego/cred_stubs.c), and implement gss_get/set_neg_mechs()
by storing the OID set in the union cred.

This commit was essentially authored as much if not more by Luke Howard
<lukeh at padl.com> as much as by the listed author.
2020-04-21 00:21:32 -05:00
Luke Howard
2ec9e17042 gss: intern OID before adding to OID set
gss_add_oid_set_member() should according to RFC2744 add a copy of the OID to
the set; the current implementation just stored a pointer (which may not be
stable). As we have _gss_intern_oid(), call that before adding.
2020-04-21 00:13:50 -05:00
Nicolas Williams
9f3d9e1a0a Add gss_duplicate_oid_set() 2020-04-21 00:13:50 -05:00
Nicolas Williams
92c288994a Better support for "non-standard" GSS mechs
If an initial security context token doesn't have a standard header per
RFC2743 then try all mechanisms until one succeeds or all fail.

We still try to guess NTLMSSP, raw Kerberos, and SPNEGO, from tasting
the initial security context token.
2020-04-17 14:37:39 -05:00
Luke Howard
4199118c76 gss: fix gss_decapsulate_token() return codes
gss_decapsulate_token() should return GSS_S_BAD_MECH if the mechanism did not
match the expected one, and GSS_S_DEFECTIVE_TOKEN if the token could not be
parsed for some other reason, rather than GSS_S_FAILURE in both cases
2020-04-17 11:11:43 +10:00
Luke Howard
26a69856f6 gss: GSS_KRB5_IMPORT_RFC4121_CONTEXT_X / _gss_mg_import_rfc4121_context()
Add a new private interface (accessed through _gss_mg_import_rfc4121_context())
through which a skeletal krb5 mechanism context can be created, suitable for
RFC4121 message protection and PRF services.
2020-04-17 11:04:33 +10:00
Luke Howard
9383a88a86 gss: honor allocated_ctx in gss_{exchange,query}_meta_data
The NegoEx gss_{exchange,query}_meta_data functions set allocated_ctx but never
did anything with it. Use it to determine whether we should free the context
handle on error.
2020-04-16 17:22:37 +10:00
Luke Howard
c70540480b gss: free user keytab before resolving system keytab
get_client_keytab() leaked the user keytab if it resolved but we could not find
the client principal. Free it before trying the system keytab.
2020-04-16 17:22:31 +10:00
Luke Howard
9eab344d35 gss: don't leak client_cred in test_context
Don't leak client credential handle in test_context.
2020-04-16 17:22:27 +10:00
Luke Howard
33137a8c82 gss: allow source/target to be null on export/import
Allow the source and target names to be NULL when exporting or importing a
security context for the krb5 mechanism. This will be used in the future to
support skeletal contexts that only provide RFC4121 message protection
services.
2020-04-16 15:20:10 +10:00
Luke Howard
865fffb0f5 gss: fix typo regression in setting minor_status
_gss_secure_release_buffer_set() patch changed minor_status to 0, not
*minor_status as correct. No behavioural change as
_gss_secure_release_buffer_set() would have set it anyway, but obviously this
was unintentional.
2020-04-16 10:44:04 +10:00
Nicolas Williams
354d76f63a Improve coverage script a bit 2020-04-15 19:05:21 -05:00
Luke Howard
2c8fa27224 gss: use _gss_secure_release_buffer_[set]
Use new helper APIs for securely zeroing and releasing buffers and buffer sets.
2020-04-15 16:23:17 +10:00
Luke Howard
689eef20ec gss: add _gss_secure_release_buffer_set()
Add _gss_secure_release_buffer_set() helper function for zeroing buffer set
contents before release.
2020-04-15 16:23:13 +10:00
Luke Howard
b2eb5b0edf gss: add _gss_secure_release_buffer()
Add _gss_secure_release_buffer() helper function that zeros buffer
2020-04-15 16:23:08 +10:00
Luke Howard
1611ac457f krb5: allow NULL authenticator in krb5_auth_con_free()
When freeing an auth context, allow the authenticator to be NULL. Useful for
freeing partially allocated authentication context.
2020-04-15 16:23:02 +10:00
Nicolas Williams
d2880425e5 Fix Coveralls badge to master branch 2020-04-14 20:48:19 -05:00
Nicolas Williams
3bdd074595 Recover coverage data on more files 2020-04-14 20:15:48 -05:00
Luke Howard
4411448bfd krb5: always zero elastic storage
Elastic storage (returned from krb5_storage_emem()) often contains secret keys.
Ensure memory is zeroed on free using memset_s() rather than memset().
2020-04-15 09:00:20 +10:00
Nicolas Williams
a7c332700d Add Coveralls badge to README.md 2020-04-14 17:03:05 -05:00
Nicolas Williams
4ac8d44f14 Send coverage data from Travis to Coveralls 2020-04-14 17:00:54 -05:00
Luke Howard
ed41592876 krb5: use memset_s() in krb5_free_keyblock_contents()
krb5_free_keyblock_contents() should use memset_s() to ensure that the key is
zero'd before freeing
2020-04-14 20:22:07 +10:00
Luke Howard
baeebd4113 gss: check for replays in test_context
Add GSS_C_REPLAY_FLAG to the default set of flags in test_context.
2020-04-14 20:03:29 +10:00
Luke Howard
8fad2cf5c3 gss: don't use heim_assert() in test_context
Use errx() rather than heim_assert() in test_context
2020-04-14 17:27:55 +10:00
Luke Howard
73a5bc8499 gss: make gss_compare_name comply with RFC2743
Anonymous names should always compare FALSE in GSS_Compare_name(). If the names
are being compared at the mechglue layer then we should check for
GSS_C_NT_ANONYMOUS.
2020-04-14 17:04:25 +10:00
Luke Howard
846c839cbf gss: add tests for importing and exporting contexts
Add the --export-import-context flag to test_context, for validating that
security contexts round-trip through GSS_Export_sec_context() and
GSS_Import_sec_context().
2020-04-14 17:04:03 +10:00
Luke Howard
9a9aaa078c gss: allow gss_set_sec_context_option() to allocate a context
The prototype for gss_set_sec_context_option() allows it to return a new
context, however this was not implemented. This functionality is required by
GSS_KRB5_IMPORT_RFC4121_CONTEXT_X.
2020-04-14 17:03:58 +10:00
Luke Howard
b73c9cc063 gss: add support for gss_duplicate_cred() in SPNEGO
The SPNEGO dispatch table does not include gss_duplicate_cred(). It can call
directly into the mechglue because a SPNEGO credential is a mechglue
credential.
2020-04-13 21:06:42 +10:00
Luke Howard
9eb01c66e9 gss: remove superfluous SPNEGO cred wrappers
SPNEGO credentials are mechglue credentials. SPNEGO credential wrapper
functions can be replaced with direct calls into the mechglue, unless a
specific check is required to avoid infinite recursion (as is the case where
the mechglue enumerates all mechanism when passed a null credential handle).
2020-04-13 21:06:37 +10:00
Luke Howard
2d2d8a0979 gss: fix test_acquire_cred usage description 2020-04-13 16:39:44 +10:00
Luke Howard
7df0195c26 gss: fix downlevel Windows interop regression
The recent changes to SPNEGO removed support for GSS_C_PEER_HAS_UPDATED_SPNEGO,
through which the Kerberos mechanism could indicate to SPNEGO that the peer did
not suffer from SPNEGO conformance bugs present in some versions of Windows.*

This patch restores this workaround, documented in [MS-SPNG] Appendix A <7>
Section 3.1.5.1. Whilst improving interoperability with these admittedly now
unsupported versions of Windows, it does introduce a risk that Kerberos with
pre-AES ciphers could be negotiated in lieu of a stronger and more preferred
mechanism.

Note: this patch inverts the mechanism interface from
GSS_C_PEER_HAS_UPDATED_SPNEGO to GSS_C_INQ_PEER_HAS_BUGGY_SPNEGO, so that new
mechanisms (which did not ship with these older versions of Windows) are not
required to implement it.

* Windows 2000, Windows 2003, and Windows XP
2020-04-13 10:26:38 +10:00
Luke Howard
0cb752258e gss: remove GSS_C_MA_AUTH_INIT_ANON from krb5 mech
Pending integration of #551, the krb5 mechanism does not support
GSS_C_ANON_FLAG. Remove the GSS_C_MA_AUTH_INIT_ANON mechanism attribute until
such time it does.
2020-04-13 09:50:18 +10:00
Luke Howard
3b7aae7fce gss: order SPNEGO proposed mechs by req_flags
Sort the list of mechanisms proposed by the initiator so that mechanisms are
preferred by their advertised support for GSS flags. For example, if
GSS_C_MUTUAL_FLAG is requested, a mechanism that offers GSS_C_MA_AUTH_TARG will
be preferred over one that doesn't. The flag/mechanism attribute combinations
are also assigned a weight (mutual trumps anonymous, for example).
2020-04-12 13:25:09 -05:00
Luke Howard
1c74afb01a roken: add mergesort_r()
Add mergesort_r() as a stable sort function that can be used by other
components of Heimdal. Note that there is no standardized prototype for this
function, however it appears that both FreeBSD and glibc would adopt the glibc
convention (where the private data argument appears last). See:

    https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214248
2020-04-12 13:25:09 -05:00
Luke Howard
4f7dc7694e gss: __gss_c_attr_stream_sizes_oid_desc declspec
__gss_c_attr_stream_sizes_oid_desc was tagged with GSSAPI_LIB_FUNCTION instead
of GSSAPI_LIB_VARIABLE; whilst the macro expansion is identical, fix for
cleanliness
2020-04-11 10:04:43 +10:00
Luke Howard
30bf21401c gss: fix copy/paste error in gss_destroy_cred()
gss_destroy_cred() was missing a calling convention, instead had the import
declaration twice
2020-04-11 10:02:09 +10:00
Nicolas Williams
7055365f47 Expand tokens in gss cred store "ccache" value
This is needed so that sshd and such can get make practical use of the
"ccache" key in GSS cred stores.

This commit only changes the store path, not the acquisition path.
2020-03-18 13:37:13 -05:00
Nicolas Williams
31a73c3c27 List FILE collection even when KRB5CCNAME is a sub
Setting KRB5CCNAME=/tmp/krb5cc_${UID}+${princ} should not prevent
listing the FILE collection.
2020-03-18 00:43:01 -05:00
Nicolas Williams
cc6a3f337b hcrypto: Fix Makefile build race 2020-03-17 19:46:37 -05:00
Nicolas Williams
8f3b5e0862 krb5: Use sqlite3_close(), not v2 2020-03-17 19:45:51 -05:00
Nicolas Williams
a8874a62bb krb5: Fix kinit harder
The previous fixes for using `krb5_cc_default_for()` weren't quite
correct.
2020-03-17 19:13:16 -05:00
Nicolas Williams
4c736cbeec krb5: Allow rename of empty FILE ccaches 2020-03-17 14:55:42 -05:00
Nicolas Williams
d725f28384 gss: Sometimes set KRB5CCNAME when not overwriting 2020-03-13 18:53:52 -05:00
Nicolas Williams
93d638a486 gss: Fix default cache preference 2020-03-13 18:14:17 -05:00
Nicolas Williams
327d7e7b43 Fix Appveyor Windows build 2020-03-12 23:05:50 -05:00
Nicolas Williams
312f353b98 gss: Prefer the default ccache when user_realm
gss_store_cred_into*() will now switch the new cred cache to be the
primary/default cred cache when

 - the caller requested it and,
 - if the caller passed in a user name, the creds' principal is the best
   principal for the named user.

A principal is the best principal for a user when the principal has just
one component, the component is the user's username, and the realm is
the configured user_realm.
2020-03-12 21:02:09 -05:00