Commit Graph

101 Commits

Author SHA1 Message Date
Nicolas Williams
96b7ea671d gss: Fix warnings 2022-01-14 17:39:05 -06: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
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
2a826d769f gss: expose PAC info buffers under urn:mspac:
Expose PAC info buffers using naming attributes prefixed with urn:mspac:,
aligned with MIT.
2022-01-03 15:59:16 +11:00
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
Luke Howard
8fc67658a6 various: squash MSVC uninitialized variable warnings (C4701)
Initialize some variables to silence some false positive MSVC warnings.
2021-09-21 18:59:38 +10:00
Luke Howard
06232dfcce gss: fix import/export of accumulating contexts
gss_{import,export}_sec_context did not work with partially accumulating
contexts, where the initial context token had not been completely accumulated,

Further, in gss_import_sec_context(), ctx->gc_input.value was not allocated to
a buffer sufficiently large to accumulate the target length.
2021-08-08 14:46:49 +10:00
Luke Howard
3b1f9f0a3f gss: error out in test_context if unknown OID
Fix regression in previous commit: exit with an error if test_context is called
with an unknown mechanism type.
2021-08-08 13:45:32 +10:00
Luke Howard
18c18d84b1 gss: merge gss_name_to_oid and gss_mg_name_to_oid
The recently introduced gss_mg_name_to_oid() function supported looking up
dynamically loaded mechanisms by name, but did not support partial matches or
the legacy "Kerberos 5" name as supported by gss_name_to_oid().

Consolidate these into a single function, and also add support for dynamically
loaded mechanisms to gss_oid_to_name().

API behavior difference: the Kerberos mechanism is now referred to by "krb5"
rather tha "Kerberos 5", although for legacy compatibility gss_name_to_oid()
will recognize the old name. However, gss_oid_to_name() will return "krb5". The
anticipated impact is minimal as these are not standard GSS-APIs and do not
appear to have any public usage outside Heimdal.
2021-08-08 11:37:09 +10:00
Roland C. Dowdeswell
3a6229f64a gss_accept_sec_context: support reassembling split tokens.
Microsoft will sometimes split GSS tokens when they exceed a certain
size in some protocols.  This is specified in

	[MS-SPNG]: Simple and Protected GSS-API Negotiation
	Mechanism (SPNEGO) Extension

https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-SPNG/%5bMS-SPNG%5d.pdf

sections 3.1.5.4 to 3.1.5.9.

We extend gss_accept_sec_context() to recognise partial tokens and
to accumulate the fragments until an entire token is available to
be processed.  If the entire token is not yet available,
GSS_S_CONTINUE_NEEDED is returned with a zero length output token.
This is specified in RFC2744 page 25-26 to indicate that no reply
need be sent.

We include updates to the test framework to test split tokens when
using SPNEGO.
2021-08-07 18:54:56 +10:00
Isaac Boukris
d83321fdf3 Add channel-bindings tests 2021-08-06 13:15:19 +10:00
Luke Howard
62d913a551 gssapi/krb5: use GSS_IOV_BUFFER_FLAG_ALLOCATE constants
GSS_IOV_BUFFER_TYPE_FLAG_ALLOCATE is deprecated as indicated in gssapi.h, use
GSS_IOV_BUFFER_FLAG_ALLOCATE instead
2020-07-12 14:26:14 +10:00
Luke Howard
4a7eb74374 gss: SAnon - the Simple Anonymous GSS-API mechanism
Add support for SAnon, a simple key agreement protocol that provides no
authentication of initiator or acceptor using x25519 ECDH key exchange.
See doc/standardization/draft-howard-gss-sanon-xx.txt for a protocol
description.
2020-04-25 23:19:30 -05:00
Nicolas Williams
20f9b2be48 gss: Fix some test leaks 2020-04-25 21:22:32 -05:00
Nicolas Williams
1a8855e6c4 spnego: Also use mechglue names 2020-04-25 21:22: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
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
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
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
4fb6a6adc9 gss: port NegoEx implementation from MIT
An implementation of draft-zhu-negoex-04 for MIT Kerberos was developed in
2011. This has been recently integrated, with many fixes from Greg Hudson. This
commit ports it to Heimdal. The implementation has been interoperability tested
with MIT Kerberos and Windows, using the GSS EAP mechanism developed as part of
the Moonshot project.

The SPNEGO code was also updated to import the state machine from Apple which
improves mechListMIC processing and avoids discarding initial context tokens
generated during mechanism probing, that can be used for optimistic tokens.

Finally, to aid in testing, the GSS-API mechanism glue configuration file can
be changed using the environment variable GSS_MECH_CONFIG. This environment
variable name, along with the format of the configuration file, is compatible
with MIT (although it would be difficult for a single mechanism binary to
support both implementations).
2020-02-04 17:28:35 +11:00
Luke Howard
e0bb9c10ca gssapi: credential store extensions (#451)
Implement the GSS-API credential store API extensions defined by MIT here:

https://k5wiki.kerberos.org/wiki/Projects/Credential_Store_extensions

Note: we kill off gss_acquire_cred_ext() here. This was never a public API,
although mechanisms could have implemented it and I briefly used it in my
BrowserID prototype mechanism. gss_acquire_cred_ext_from() occupies the place
in the dispatch table where gss_acquire_cred_ext() used to, but this structure
was never visible outside Heimdal (i.e. it is only used by internal
mechanisms);

(Mechanisms that need to accept arbitrary key/value dictionaries from
applications should now implement gss_acquire_cred_from().)
2019-01-03 14:38:39 -06:00
Nicolas Williams
b0a357429d Fix warning in lib/gssapi/test_context.c 2018-12-28 01:09:38 -06:00
Simon Wilkinson
07b3e6fd74 Allow zero-length encrypt IOVs in _krb5_evp_encrypt_iov_cts()
The iovec encryption code doesn't handle 0 length iovecs correctly.
Instead of just skipping them, _krb5_evp_encrypt_iov_cts() will spin
on the 0 length iovec.

Modify the _krb5_evp_iov_cursor_expand helper so that iovec expansion
simply skips 0 length iovecs, and make _krb5_evp_iov_cursor_nextcrypt
do the same.

Original bug report and tests from Andrew Bartlett <abartlet@samba.org>
2018-09-18 19:23:31 -04:00
Jeffrey Altman
02ea07f93d gssapi: remove dead code
Remove assignment of a variable to itself.

Identified by AppChecker.

Change-Id: I94012849d8200dc91394a8548e72c61404d7e5b6
2017-04-29 01:06:00 -04:00
Luke Howard
33ce593b6d gss_wrap/gss_unwrap_aead implementation
Signed-off-by: Nicolas Williams <nico@twosigma.com>
2016-02-05 18:01:15 -06:00
Luke Howard
f5b4ef3ed8 gssapi: plug leak in test_context IOV test 2015-12-09 19:05:11 +11:00
Nicolas Williams
420c080a8f Can't use deleg creds with SPNEGO (test_context)
It isn't possible to use non-default credentials to init a context with
a mechanism for which the credential doesn't have an element.  That's
exactly what was happening here.  The code was left commented out to
describe how one might use SPNEGO with delegated credentials:
store them with gss_store_cred(), then acquire them back.
2015-04-17 10:55:47 -05:00
Nicolas Williams
5d50d06845 Better test workaround for NTLM bug 2015-04-16 19:53:22 -05:00
Nicolas Williams
d6a7d14fc5 Workaround bugs exposed by test_context changes
Bugs exposed by 61720a0:

 - test_context --client-name=... --mech-type=ntlm ... fails;

 - gss_acquire_cred() with desired_mech=NTLM and
   desired_name==GSS_C_NO_NAME fails;

 - gss_init_sec_context() with non-default cred handle calls the
   mechanism even when the given cred handle has no element for the
   requencet mechanism.

tests/gss/check-ntlm works by accident: gss_acquire_cred() with
desired_mechs==GSS_C_NO_OID_SET succeeds mostly because there are
Kerberos credentials available, and then the subsequent
gss_init_sec_context() call works because of the third bug described
above.
2015-04-16 18:42:51 -05:00
Nicolas Williams
61720a0177 Improve test_context, add mech oid set 2015-04-15 12:27:40 -05:00
Jelmer Vernooij
70e43e9808 Fix some typos. 2014-04-25 02:42:17 +02:00
Roland C. Dowdeswell
e8779d5d4a Add -Wshadow and deal with the warnings. 2012-02-21 11:17:55 +00:00
Love Hornquist Astrand
58ea513056 fix error message 2011-05-21 12:11:04 -07:00
Love Hornquist Astrand
0879b9831a remove trailing whitespace 2011-05-21 11:57:31 -07:00
Luke Howard
79ff133ae9 make gss_acquire_cred_ext private 2011-05-20 14:31:08 +02:00
Luke Howard
48719d5651 shim acquire_cred_with_password SPI into acquire_cred_ext 2011-05-14 17:00:55 +02:00
Luke Howard
dfba868910 Merge branch 'master' into lukeh/acquire-cred-ex-moonshot-integ
Conflicts:
	lib/gssapi/Makefile.am
	lib/gssapi/mech/gss_acquire_cred_with_password.c
	lib/gssapi/test_context.c
	lib/gssapi/version-script.map
2011-05-14 16:48:49 +02:00
Luke Howard
2a8dc252b6 add gss_acquire_cred_with_password test to test_context 2011-05-14 16:26:14 +02:00
Luke Howard
3069d80734 Merge branch 'master' into lukeh/acquire-cred-ex 2011-05-14 14:56:16 +02:00
Luke Howard
02cf28e20b implement gss_acquire_cred_ex with password support
add missing SPIs to gss_mech_switch

s/acquire_cred_ex/acquire_cred_ext/g
2011-04-16 11:06:24 +02:00
Love Hornquist Astrand
d8b5246607 catch error from gsskrb5_register_acceptor_identity 2011-04-14 12:54:16 -07:00
Asanka C. Herath
7ba01bda98 Deal with possibly non-const initializers 2010-12-02 01:18:03 -05:00
Love Hornquist Astrand
1021099f3d rename external so that they can be included in array and struct initializer 2010-07-22 20:47:04 -07:00
Love Hornquist Astrand
01a1e1baef check that gss_krb5_set_allowable_enctypes works 2009-11-30 17:19:13 -08:00
Stefan Metzmacher
2f1a370cd3 hack for gss-wrap-iov to it work
Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2009-08-28 13:31:12 -07:00
Love Hornquist Astrand
45cfe3f971 Fix server context client context order to match callee 2009-08-27 18:30:28 -07:00
Love Hornquist Astrand
1999c85670 Make mech glue layer aware of composite mechs that uses mech glue layer credentials
This make it possible to use krb5/ntlm credentials with SPNEGO.
Needs some more work to avoid double fetching credentials.
2009-08-27 12:12:44 -07:00
Love Hornquist Astrand
32ee735d73 drop RCSID 2009-08-26 23:15:35 -07:00