Commit Graph

55 Commits

Author SHA1 Message Date
Nicolas Williams
96b7ea671d gss: Fix warnings 2022-01-14 17:39:05 -06: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
Jeffrey Altman
02200d55ea Address GCC Bug 95189 memcmp wrongly stripped like strcmp
As documented in Russell O'Connor's blog, Heimdal when compiled with
some versions of gcc 9 and 10 would generate incorrect behaviors from
_gssapi_verify_mic_arcfour(), _gssapi_unwrap_arcfour(),
_gssapi_unwrap_iov_arcfour() and _gssapi_unwrap_iov_arcfour().

As a result of the bug, code of the form

   if (memcmp(a, "\x00\x00\x00\x00"))

and

   cmp = memcmp(a, "\x00\x00\x00\x00")

will be compiled as if it were written as

   if (strcmp(a, "\x00\x00\x00\x00"))

and

   cmp = strcmp(a, "\x00\x00\x00\x00")

but not

   if (memcmp(a, "\x00\x00\x00\x00") != 0)

and

   cmp = (memcmp(a, "\x00\x00\x00\x00") != 0)

Bad code is generated whenever one of the parameters to memcmp()
is a constant with at least one NUL in the first four octets and
the return value is used immediated without a boolean comparison.

The gcc bug 95189 has since been fixed.

This change applies a defensive programming technique to avoid
the broken code generation.

Change-Id: I1db2a561735317cb6cac66a0ec9caf5443e65e03
Link: https://r6.ca/blog/20200929T023701Z.html
Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95189
Reported-by: Buck Huppmann (buckh@pobox.com) <buckh@pobox.com>
2021-11-24 22:30:44 -05:00
Jeffrey Altman
8123ffc3f2 _gssapi_unwrap_iov_arcfour remove duplicate code block
ad3acc2aef ("lib/gssapi/krb5:
implement gss_[un]wrap_iov[_length] with arcfour-hmac-md5")
introduced a duplicate block of code.

This change removes the unnecessary code duplication.

Change-Id: I557c590aea51b73dc25d6ce4be4ea84b9dfadd9f
2021-11-24 22:30:44 -05:00
Luke Howard
0dd1900308 gss: fix regression in rc4-hmac krb5 DCE unwrap
4b543b7 introduced a regression in the krb5 mechanism's gss_unwrap for
DCE applications, owing to IS_DCE_STYLE() being called with a krb5
instead of mechanism context handle.
2021-07-07 23:51:06 +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
4b543b727a gssapi/krb5: fix rc4-hmac gss_unwrap_iov() without DCE_STYLE
gss_unwrap_iov() with rc4-hmac (RFC4757) encryption types would fail unless
GSS_C_DCE_STYLE was specified, as an incorrect length was passed to
_gssapi_verify_mech_header(). (The correct length is the header length for
GSS_C_DCE_STYLE, and the wrap token length otherwise.)
2020-07-12 14:26:14 +10:00
Luke Howard
b73baa42ef gssapi/krb5: make PADDING buffer optional in GSS IOV API
RFC 4121/4757 don't require padding as they operate as stream ciphers. Make the
PADDING buffer optional when using these encryption types with gss_wrap_iov()
and gss_unwrap_iov().
2020-07-12 14:26:14 +10:00
Jeffrey Altman
93518bfab4 use memset_s
lib roken includes support for memset_s() but it was not applied
to the Heimdal source tree.

Change-Id: I8362ec97a9be50205bb2d398e65b629b88ce1acd
2017-04-29 01:05:59 -04:00
Nicolas Williams
1c81ddf4e2 Round #2 of scan-build warnings cleanup 2016-11-16 17:03:14 -06:00
Stefan Metzmacher
ad3acc2aef lib/gssapi/krb5: implement gss_[un]wrap_iov[_length] with arcfour-hmac-md5
Pair-Programmed-With: Andreas Schneider <asn@samba.org>

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Andreas Schneider <asn@samba.org>
2015-07-31 17:30:23 +12:00
Stefan Metzmacher
bafefad87f lib/gssapi/krb5: split out a arcfour_mic_cksum_iov() function
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2015-07-31 17:30:23 +12:00
Stefan Metzmacher
ef0059b8b6 lib/gssapi/krb5: add const to arcfour_mic_key()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2015-07-31 17:30:23 +12:00
Stefan Metzmacher
5f79ac2bb9 lib/gssapi/krb5: clear temporary buffer with cleartext data.
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2015-07-31 17:30:23 +12:00
Love Hörnquist Åstrand
8060a561db switch to KRB5_ENCTYPE 2011-07-24 16:02:22 -07:00
Love Hörnquist Åstrand
f60ec15834 partly unify enctype/keytype since there is only enctypes 2011-07-24 14:03:08 -07:00
Love Hornquist Astrand
0879b9831a remove trailing whitespace 2011-05-21 11:57:31 -07:00
Love Hornquist Astrand
f5f9014c90 Warning fixes from Christos Zoulas
- shadowed variables
- signed/unsigned confusion
- const lossage
- incomplete structure initializations
- unused code
2011-04-29 20:25:05 -07:00
Love Hornquist Astrand
fcfa32b0b9 Use constant time memcmp 2009-08-17 12:04:51 +02:00
Love Hornquist Astrand
42cec58cb4 switch to use EVP interface instead of old crypto interface 2009-08-17 11:43:24 +02:00
Love Hörnquist Åstrand
c99b2003e2 Implement gss_wrap_iov, gss_unwrap_iov for CFX type encryption types.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25286 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-06-22 17:56:41 +00:00
Love Hörnquist Åstrand
269a7a057b flatten include headers
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24382 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-01-25 00:35:00 +00:00
Love Hörnquist Åstrand
6937d41a02 remove trailing whitespace
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23815 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-13 09:21:03 +00:00
Love Hörnquist Åstrand
e172367898 switch to utf8 encoding of all files
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23814 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-13 08:53:55 +00:00
Love Hörnquist Åstrand
00bcd44370 Switch from using a specific error message context in the TLS to have
a whole krb5_context in TLS. This have some interestion side-effekts
for the configruration setting options since they operate on
per-thread basis now.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19031 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-11-13 18:02:57 +00:00
Love Hörnquist Åstrand
4806754426 Use IS_DCE_STYLE flag. There is no padding in DCE-STYLE, don't try to use to.
From Andrew Bartlett.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18937 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-11-07 19:05:16 +00:00
Love Hörnquist Åstrand
dfa6f7b248 reference all include files using krb5/
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18334 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-10-07 22:16:04 +00:00
Love Hörnquist Åstrand
d9bdb35e27 Thinker more with header lengths.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18207 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-10-02 20:57:02 +00:00
Love Hörnquist Åstrand
583be9c858 try harder to get the header calculations right
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18206 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-10-02 19:23:25 +00:00
Love Hörnquist Åstrand
563a9bf25e Improve the calcucation of header lengths. DCE-STYLE data is also
padded so remove if (1 || ...) code.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18204 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-10-02 19:04:50 +00:00
Love Hörnquist Åstrand
0ed8497583 Move _gssapi_wrap_size_arcfour here.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18194 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-10-02 09:14:14 +00:00
Love Hörnquist Åstrand
839c8fba02 DCE-style token do include padding, add it back.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18173 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-09-25 22:23:27 +00:00
Love Hörnquist Åstrand
26ae75721a Add wrap support, interrop with itself but not w2k3s-sp1
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18172 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-09-25 21:42:28 +00:00
Love Hörnquist Åstrand
24c75bf8eb Support DCE-style unwrap, tested with w2k3server-sp1.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18170 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-09-25 20:44:03 +00:00
Love Hörnquist Åstrand
ee09f98c15 Rename local include file, remove global files.
Stop exposing global gssapi symbols.
Rename gss_context_id_t and gss_cred_id_t to local names.
Remove SPNEGO code, its now in its own gssapi module.
Add mechglue inquire functions.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17697 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-06-28 08:54:04 +00:00
Love Hörnquist Åstrand
0e90681917 Less pointer signedness warnings.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17564 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-05-13 15:35:54 +00:00
Love Hörnquist Åstrand
3dd8e3181b Avoid pointer signedness warnings.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17435 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-05-04 11:56:50 +00:00
Love Hörnquist Åstrand
70ec67ed73 Remove signedness warnings.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16270 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-11-01 06:55:55 +00:00
Love Hörnquist Åstrand
1e4eaef45d (_gssapi_wrap_arcfour): fix calculating the encap length
Tom Maher <tmaher@eecs.berkeley.edu>


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15096 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-05-06 07:13:32 +00:00
Love Hörnquist Åstrand
d0443e2058 prefix all sequence symbols with _, they are not part of the GSS-API api. By comment from Wynn Wilkes <wynnw@vintela.com>
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14989 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-04-27 17:51:27 +00:00
Love Hörnquist Åstrand
b28cb7da78 mutex buglet, From: Luke Howard <lukeh@PADL.COM>
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14098 ec53bebd-3082-4978-b11e-865c3cabbd6b
2004-08-07 14:31:52 +00:00
Love Hörnquist Åstrand
7b94ee3d0e comment describing message formats
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@13470 ec53bebd-3082-4978-b11e-865c3cabbd6b
2004-03-07 22:29:54 +00:00
Love Hörnquist Åstrand
5a87232218 remove depenency on gss_arcfour_mic_token and gss_arcfour_warp_token
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12883 ec53bebd-3082-4978-b11e-865c3cabbd6b
2003-09-19 15:04:35 +00:00
Love Hörnquist Åstrand
6a38642fc0 (*): set minor_status
(gss_wrap): set conf_state to conf_req_flags on success
From: Luke Howard <lukeh@PADL.COM>


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12835 ec53bebd-3082-4978-b11e-865c3cabbd6b
2003-09-16 12:12:42 +00:00
Love Hörnquist Åstrand
da8892828c (arcfour_mic_cksum): use free_Checksum to free the checksum
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12695 ec53bebd-3082-4978-b11e-865c3cabbd6b
2003-08-28 11:08:26 +00:00
Love Hörnquist Åstrand
adc6d86b7d swap two last arguments to verify_mic for consistency with des3
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12694 ec53bebd-3082-4978-b11e-865c3cabbd6b
2003-08-28 11:00:23 +00:00
Love Hörnquist Åstrand
4f2548810a release the right buffer
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12691 ec53bebd-3082-4978-b11e-865c3cabbd6b
2003-08-28 10:48:32 +00:00
Love Hörnquist Åstrand
d432d068e5 rename token structure in consistency with rest of GSS-API
From: Luke Howard <lukeh@PADL.COM>


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12690 ec53bebd-3082-4978-b11e-865c3cabbd6b
2003-08-28 10:41:36 +00:00
Love Hörnquist Åstrand
504acf338f (_gssapi_wrap_arcfour): set the correct padding
(_gssapi_unwrap_arcfour): verify and strip padding


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12688 ec53bebd-3082-4978-b11e-865c3cabbd6b
2003-08-28 10:23:28 +00:00
Love Hörnquist Åstrand
8374158e8c support KEYTYPE_ARCFOUR_56 keys, from Luke Howard <lukeh@PADL.COM>
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12683 ec53bebd-3082-4978-b11e-865c3cabbd6b
2003-08-28 07:57:29 +00:00