Commit Graph

67 Commits

Author SHA1 Message Date
Joseph Sutton
814e58fda8 heimdal: Make _krb5_pac_get_kdc_checksum_info() into a global function
This lets us call it from Samba.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>

[abartlet@samba.org Similar to Samba commit 3bdce12789af1e7a7aba56691f184625a432410d
 but also fixed for caller in Heimdal windc plugin tests]
2021-12-14 13:44:01 +11:00
Luke Howard
eb85614c24 Revert "s4/heimdal/lib/krb5/pac.c: Align PAC buffers to match Windows"
This reverts commit 24a7a82e82.

After further discussion in #863, the alignment (which differs according to
info buffer type) should be handled by the caller.
2021-12-10 11:02:17 +11:00
Joseph Sutton
24a7a82e82 s4/heimdal/lib/krb5/pac.c: Align PAC buffers to match Windows
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14642

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry picked from Samba commit 28a5a586c8e9cd155d676dcfcb81a2587ace99d1)
2021-12-09 09:53:03 +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
Nicolas Williams
54581d2d52 krb5: Fix PAC signature leak affecting KDC 2021-10-11 13:58:15 -05:00
Luke Howard
cba3f9a563 krb5: return KRB5KRB_AP_ERR_INAPP_CKSUM if PAC checksum fails
Return KRB5KRB_AP_ERR_INAPP_CKSUM instead of EINVAL when verifying a PAC, if
the checksum is absent or unkeyed.
2021-09-21 18:17:00 +10:00
Isaac Boukris
6df8be5091 krb5: rework PAC validation loop
Avoid allocating the PAC on error.

Closes: #836
2021-09-20 11:29:11 +10:00
Isaac Boukris
b295167208 krb5: allow NULL parameter to krb5_pac_free() 2021-09-20 11:29:09 +10:00
Isaac Boukris
2ffaba9401 kdc: sign ticket using Windows PAC
Split Windows PAC signing and verification logic, as the signing has to be when
the ticket is ready.

Create sign and verify the PAC KDC signature if the plugin did not, allowing
for S4U2Proxy to work, instead of KRB5SignedPath.

Use the header key to verify PAC server signature, as the same key used to
encrypt/decrypt the ticket should be used for PAC server signature, like U2U
tickets are signed witht the tgt session-key and not with the longterm key,
and so krbtgt should be no different and the header key should be used.

Lookup the delegated client in DB instead of passing the delegator DB entry.

Add PAC ticket-signatures and related functions.

Note: due to the change from KRB5SignedPath to PAC, S4U2Proxy requests
against new KDC will not work if the evidence ticket was acquired from
an old KDC, and vide versa.

Closes: #767
2021-09-19 13:25:27 +10:00
Chris Lamb
2f3f88e53a Correct "allignment" typos.
Signed-off-by: Chris Lamb <chris@chris-lamb.co.uk>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>

(cherry-picked from Samba commit 8fcc49ecd44e69d7f9ada212c63896e0dcf488a4)
2018-09-10 14:42:18 -04:00
Simon Wilkinson
e50faea7f0 krb5: Store a digest context in the crypto structure
Creating and destroying an EVP_CTX_MD structure with every hash
operation is very expensive. Speed things up by caching one within
the krb5_crypto structure. krb5_crypto can already only be safely
used by one thread at a time - adding a message digest context here
shouldn't introduce any further threading risks.

Users of the stashed context must be careful to ensure that they
call no other hash functions whilst they are in the middle of using
the context.
2018-05-23 09:54:27 -04:00
Simon Wilkinson
ca756f0f7f krb5: Use iovecs for internal checksum handling
Modify the signature of the checksum operation in the
krb5_checksum_type structure so that it processes iovecs rather than
solid blocks of data.

Update all of the implementations of these functions for all of the
checksum types that we support so that they process iovecs, either
by iterating through the iovec in each function, or by calling
_krb5_evp_digest_iov or _krb5_evp_hmac_iov()

Update callers of these functions so that they turn their single blocks
of data into a single iovec of the correct type before calling checksum
2018-05-23 09:54:27 -04:00
Nicolas Williams
122cdc578e Fix some krb5_storage_write() usages 2017-05-26 23:24:30 -04:00
Nicolas Williams
f38089257b Misc fixes (coverity) 2016-11-20 17:43:51 -06:00
Nicolas Williams
953dc07391 Round #1 of scan-build warnings cleanup 2016-11-15 21:27:20 -06:00
Andrew Bartlett
2ff110cfa6 Merge pull request #154 from metze-samba/heimdal-for-upstream
lib/krb5: allow predefined PAC_{LOGON_NAME,PRIVSVR_CHECKSUM,SERVER_CH…
2016-05-14 22:32:13 +12:00
aaptel
08a2d1a320 lib/krb5/pac.c: fix NULL check typo 2016-03-10 10:33:53 +01:00
Stefan Metzmacher
7cd40a6105 lib/krb5: allow predefined PAC_{LOGON_NAME,PRIVSVR_CHECKSUM,SERVER_CHECKSUM} elements in _krb5_pac_sign()
A caller may want to specify an explicit order of PAC elements,
e.g. the PAC_UPN_DNS_INFO element should be placed after the PAC_LOGON_NAME
element.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
2016-02-02 15:31:18 +01:00
Stefan Metzmacher
ae4d222f58 lib/krb5: verify_logonname() to handle multi component principal
FreeIPA can generate tickets with a client principal of
'host/hostname.example.com'.

verify_logonname() should just verify the principal name
in the PAC_LOGON_NAME is the same as the principal of
the client principal (without realm) of the ticket.

Samba commit b7cc8c1187ff967e44587cd0d09185330378f366
break this. We try to compare ['host']['hostname.example.com']
with ['host/hostname.example.com]' (as we interpret it as enterprise principal)
this fail if we don't compare them as strings.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11142

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2015-07-31 17:30:23 +12:00
Stefan Metzmacher
8c8a39b0b7 heimdal:lib/krb5: let build_logon_name() use KRB5_PRINCIPAL_UNPARSE_DISPLAY
An ENTERPRISE principal should result in 'administrator@S4XDOM.BASE'
instead of 'administrator\@S4XDOM.BASE'.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11142
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
2015-06-17 17:41:27 -05:00
Stefan Metzmacher
2e6318f09a heimdal:lib/krb5: allow enterprise principals in verify_logonname()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11142
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
2015-06-17 17:41:26 -05:00
Jeffrey Altman
5f138a16ef libkrb5: Add missing KRB5_LIB_FUNCTION/KRB5_LIB_CALL
KRB5_LIB_FUNCTION and KRB5_LIB_CALL are necessary even on private
functions that are exported.

Change-Id: Iccd0cfe87ff0a9d851e29890e9cb55b3ae517ce1
2013-06-22 21:17:32 -04:00
Harald Barth
3f52037382 Better error messages when UTF8 conversion fails
Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2013-04-26 00:05:53 -07:00
Viktor Dukhovni
435c02fa26 Compare pac timestamp to unix timestamp right when neither are set
Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2013-04-24 16:28:26 -07:00
Stefan Metzmacher
7ecbac23f6 lib/krb5: add utf8 support to build_logon_name() for the PAC
Pair-Programmed-With: Arvid Requate <requate@univention.de>

metze

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2011-11-16 19:42:45 -08: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
03806492d9 prefix symbols that are _krb5_ structures 2011-03-12 13:45:09 -08:00
Love Hornquist Astrand
ea2534a55f export krb5_enomem 2010-11-24 14:35:56 -08:00
Asanka C. Herath
0f853405fe Add missing export and calling convention annotations 2010-11-24 15:32:49 -05:00
Love Hornquist Astrand
f178458310 use krb5_data_ct_cmp 2010-11-06 20:53:04 +01:00
Love Hornquist Astrand
55ccd5ff9c use _krb5_enomem and indent 2010-11-06 20:10:26 +01:00
Love Hornquist Astrand
5ab43b8520 plug memory leak 2010-11-06 20:01:02 +01:00
Andrew Bartlett
a42b77fb22 heimdal Add handling for PAC signatures over all encryption types
There are exceptions from the expected behaviour of 'checksum type
matches key type' that we must deal with here, or else we can't serve
DES-only servers.

Andrew Bartlett

Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2010-11-06 19:56:48 +01:00
Love Hörnquist Åstrand
942a821fab remove RCSID
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25171 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-05-04 06:17:40 +00:00
Love Hörnquist Åstrand
a222d53b7f free utf8 string on failure, cid#87
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24098 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-12-11 04:59:18 +00:00
Love Hörnquist Åstrand
03babea1e3 switch to krb5_clear_error_message
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23911 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-10-14 02:55:39 +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
ad4fcfd6d2 N_()ify
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23790 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-07 21:29:43 +00:00
Love Hörnquist Åstrand
39f62b79e4 Don't hide the checksums from the caller, From Andrew Bartlett.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23711 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-08-28 13:48:56 +00:00
Love Hörnquist Åstrand
1427d9773f add doxygen
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23703 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-08-28 01:12:16 +00:00
Love Hörnquist Åstrand
11752006c3 ignore error from crypto_destro to catch more intresting error
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23506 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-08-11 10:00:28 +00:00
Love Hörnquist Åstrand
7fcd266fdd use krb5_set_error_message
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23316 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-06-23 04:32:32 +00:00
Love Hörnquist Åstrand
b39eeb6c7a use krb5_set_error_message
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23299 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-06-23 03:29:14 +00:00
Love Hörnquist Åstrand
4212ec831b Cast size_t to unsigned long to avoid warning.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22989 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-04-15 15:55:12 +00:00
Love Hörnquist Åstrand
69c1f4ee7b Use libwind.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22562 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-02-03 17:38:35 +00:00
Love Hörnquist Åstrand
743ccd85cf make work with cpp again, reported by Hai Zaar
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21934 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-08-27 14:21:04 +00:00
Love Hörnquist Åstrand
d68b36bb90 make compile
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21149 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-18 21:50:22 +00:00
Love Hörnquist Åstrand
c614532c87 (verify_checksum): memset cksum to avoid using pointer from stack.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21135 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-18 21:06:08 +00:00