]> git.ipfire.org Git - thirdparty/krb5.git/log
thirdparty/krb5.git
12 years agoSupport PKINIT OpenSSL deferred identity prompting
Nalin Dahyabhai [Fri, 28 Jun 2013 21:12:39 +0000 (17:12 -0400)] 
Support PKINIT OpenSSL deferred identity prompting

Add a password to the set of things that we can pass to a PEM password
callback and the function we use for loading PKCS12 bundles.  If we're
meant to defer identity prompts, just store the name of the identity
which we're loading.  Otherwise, if we're passed a password, use it.
Otherwise, use the prompter callback.

Add a password to the set of things that we can pass to the function
that we use for logging in to PKCS11 tokens, too, but if we're deferring
identity prompts, just return the identity name without doing anything
else.  If not, and we're passed a password, use that.  Otherwise, try to
use the prompter callback to get one.

ticket: 7680

12 years agoSupport PKINIT NSS deferred identity prompting
Nalin Dahyabhai [Mon, 8 Jul 2013 20:49:16 +0000 (16:49 -0400)] 
Support PKINIT NSS deferred identity prompting

The password callback which we usually supply to NSS already gets a
pointer to the pkinit_identity_crypto_context structure, but it needs to
be passed the name of the identity for which it's being called.

If it gets a name, and it's deferring prompting, just add the identity
to the list of deferred identity prompts (the password callback wouldn't
have been called if its result wasn't needed), and either return NULL
(as an indication that we couldn't get a password) or an empty string (a
value which we know is invalid) if that's handier.

Otherwise, check for a password that's been stashed for its use for that
identity, and return a copy of it if one's found.  If none of that
works, try to use the prompter callback to ask for the password.

ticket: 7680

12 years agoPass PKINIT identity prompts to the responder cb
Nalin Dahyabhai [Mon, 15 Jul 2013 17:11:00 +0000 (13:11 -0400)] 
Pass PKINIT identity prompts to the responder cb

Use the list of deferred identity prompts and warnings, which we have
after calling pkinit_identity_initialize(), to build a list of questions
to supply to responder callbacks.

Before calling pkinit_identity_prompt() to actually load identities that
are protected, save any passwords and PINs which a responder callback
may have supplied.

Because pkinit_client_prep_questions() can be called multiple times, and
we don't want to try to load all of our identities each of those times,
take some steps to ensure that we only call pkinit_identity_initialize()
and pkinit_identity_prompt() once per request.

ticket: 7680

12 years agoMake the PKINIT NSS path also check for NULL certs
Nalin Dahyabhai [Tue, 9 Jul 2013 18:13:16 +0000 (14:13 -0400)] 
Make the PKINIT NSS path also check for NULL certs

When called to free identity information, do what the OpenSSL-based
version does, and error out if the identity information is NULL.

12 years agoUse PKCS11_MODNAME for NSS PKINIT by default
Nalin Dahyabhai [Fri, 28 Jun 2013 21:12:39 +0000 (17:12 -0400)] 
Use PKCS11_MODNAME for NSS PKINIT by default

Do what the OpenSSL-using code paths do, and load PKCS11_MODNAME if no
module is specified when we're told to use a PKCS11 identity.

12 years agoAdd support for PKINIT deferring identity prompts
Nalin Dahyabhai [Fri, 28 Jun 2013 21:12:39 +0000 (17:12 -0400)] 
Add support for PKINIT deferring identity prompts

Learn to manage a list of deferred identities, for which we want to
prompt for passwords or PINs, in pkinit_identity_crypto_context
structures, along with their associated token flags.  These are opaque
outside of pkinit_crypto_openssl and pkinit_crypto_nss, so both
implementations need to provide wrapper functions that can be called
from elsewhere in the module to populate and query the lists.

ticket: 7680

12 years agoSplit pkinit_identity_initialize into two phases
Nalin Dahyabhai [Fri, 28 Jun 2013 21:12:39 +0000 (17:12 -0400)] 
Split pkinit_identity_initialize into two phases

Split part of pkinit_identity_initialize() into a second piece named
pkinit_identity_prompt().  Have each piece pass a new boolean flag to
crypto_load_certs() to indicate if it should defer prompting for a
password/PIN for client identities that require one.  If the flag isn't
set, then crypto_load_certs() should attempt to use a responder-supplied
value, or call the prompter if there isn't one.

ticket: 7680

12 years agoFix OTP KDC module get_string error handling
Greg Hudson [Wed, 17 Jul 2013 16:14:13 +0000 (12:14 -0400)] 
Fix OTP KDC module get_string error handling

If cb->get_string returns 0 with no result in otp_edata, make sure we
set retval to avoid sending an empty OTP hint.  If cb->get_string
returns an error code in otp_verify, avoid masking that code.

12 years agoClarify and improve k5_json_object_set
Greg Hudson [Tue, 16 Jul 2013 22:09:55 +0000 (18:09 -0400)] 
Clarify and improve k5_json_object_set

Document that k5_json_object_set can be used to overwrite an existing
key, and make it possible to remove a key by setting it to NULL.

12 years agoAdd kadmin support for principals without keys
Greg Hudson [Tue, 9 Jul 2013 14:58:49 +0000 (10:58 -0400)] 
Add kadmin support for principals without keys

Add kadmin support for "addprinc -nokey", which creates a principal
with no keys, and "purgekeys -all", which deletes all keys from a
principal.  The KDC was modified by #7630 to support principals
without keys.

ticket: 7679 (new)

12 years agoAvoid allocating zero key_data structures
Greg Hudson [Mon, 15 Jul 2013 16:20:26 +0000 (12:20 -0400)] 
Avoid allocating zero key_data structures

When we allocate space for an array of key_data structures, make sure
we allocate at least one, so we don't spuriously fail on platforms
where malloc(0) returns NULL.  Where we use malloc, use k5calloc
instead.  Where we use krb5_db_alloc or realloc, just allocate an
extra entry.

12 years agoFix a leak when parsing PKINIT cert SANs with NSS
Nalin Dahyabhai [Tue, 9 Jul 2013 22:29:41 +0000 (18:29 -0400)] 
Fix a leak when parsing PKINIT cert SANs with NSS

When retrieving the list of a certificate's subjectAltName values, we
weren't freeing some of the temporary memory we used.

12 years agoFix minor leaks in klist
Greg Hudson [Mon, 15 Jul 2013 15:14:24 +0000 (11:14 -0400)] 
Fix minor leaks in klist

When walking the cache, if we skip a cred because it's a config entry,
make sure to free it.  Also free the result of krb5_cc_get_principal.
Based on a patch from Nalin Dahyabhai.

12 years agoDon't leak PKINIT CMS signed data certs and CRLs
Nalin Dahyabhai [Thu, 11 Jul 2013 02:17:58 +0000 (22:17 -0400)] 
Don't leak PKINIT CMS signed data certs and CRLs

The stacks of certificates and CRLs that we retrieve from CMS objects
include newly-owned references to the certificates and CRLs, so when we
go to free them, we need to remember to free those.

[ghudson@mit.edu: minor formatting change; removed unrelated style fix]

12 years agoDon't leak the reply key's memory during PKINIT
Nalin Dahyabhai [Tue, 9 Jul 2013 21:20:27 +0000 (17:20 -0400)] 
Don't leak the reply key's memory during PKINIT

12 years agoUse pipe instead of sigwait for krad tests
Greg Hudson [Mon, 15 Jul 2013 01:17:39 +0000 (21:17 -0400)] 
Use pipe instead of sigwait for krad tests

We've never used sigwait() before, and it has some problems on Solaris
10 (a nonconformant prototype by default, and experimentally it didn't
seem to work correctly with _POSIX_PTHREAD_SEMANTICS defined).  Use a
pipe instead.  Make t_daemon.py less chatty on stdout to avoid filling
the pipe buffer.

12 years agoFix minor type issues in krad tests
Greg Hudson [Sun, 14 Jul 2013 23:28:08 +0000 (19:28 -0400)] 
Fix minor type issues in krad tests

Use unsigned char for test encodings, since the initializers use
values greater than 127.

12 years agoUse k5calloc instead of k5alloc where appropriate
Greg Hudson [Fri, 12 Jul 2013 00:39:51 +0000 (20:39 -0400)] 
Use k5calloc instead of k5alloc where appropriate

Wherever we use k5alloc with a multiplication in the size parameter,,
use the new k5calloc helper function instead.

12 years agoAdd k5calloc internal helper function
Greg Hudson [Thu, 11 Jul 2013 23:47:33 +0000 (19:47 -0400)] 
Add k5calloc internal helper function

Letting calloc() do multiplication helps avoid overflow bugs, so
provide an internal k5calloc() helper which accepts both calloc
arguments, and reimplement k5alloc() in terms of it.

12 years agoFix skip logic in t_otp.py
Greg Hudson [Thu, 11 Jul 2013 23:44:11 +0000 (19:44 -0400)] 
Fix skip logic in t_otp.py

Reorder (and trim) the imports in t_otp.py so that k5test is pulled in
before we try to import pyrad and multiprocessing.  Otherwise
success() isn't defined in the case where we decide to skip the entire
test script.

12 years agoAdd server-side otp preauth plugin
Nathaniel McCallum [Wed, 3 Apr 2013 16:38:05 +0000 (12:38 -0400)] 
Add server-side otp preauth plugin

This plugin implements the proposal for providing OTP support by
proxying requests to RADIUS. Details can be found inside the
provided documentation as well as on the project page.

http://k5wiki.kerberos.org/wiki/Projects/OTPOverRADIUS

ticket: 7678

12 years agoAdd libkrad
Nathaniel McCallum [Thu, 4 Apr 2013 17:39:21 +0000 (13:39 -0400)] 
Add libkrad

The new library libkrad provides code for the parsing of RADIUS packets
as well as client implementation based around libverto.  This library
should be considered unstable.

ticket: 7678 (new)

12 years agoMention old preauth header file in docs
Greg Hudson [Wed, 10 Jul 2013 15:13:31 +0000 (11:13 -0400)] 
Mention old preauth header file in docs

The previous commit updated the header file references for 1.12 in the
clpreauth and kdcpreauth plugin interface documentation.  Add a
parenthetical so that the reference is still useful for prior
releases.

12 years agoReference correct preauth header files
Greg Hudson [Mon, 1 Jul 2013 16:12:10 +0000 (12:12 -0400)] 
Reference correct preauth header files

The clpreauth and kdcpreauth header files are split up for 1.12.  In
clpreauth.rst and kdcpreauth.rst, reference the correct header files
for each.

12 years agoAdd test case for CVE-2013-1417
Tom Yu [Fri, 28 Jun 2013 19:34:17 +0000 (15:34 -0400)] 
Add test case for CVE-2013-1417

ticket: 7670 (new)
tags: pullup
target_version: 1.11.4

12 years agoKDC null deref due to referrals [CVE-2013-1417]
Tom Yu [Fri, 21 Jun 2013 21:58:25 +0000 (17:58 -0400)] 
KDC null deref due to referrals [CVE-2013-1417]

An authenticated remote client can cause a KDC to crash by making a
valid TGS-REQ to a KDC serving a realm with a single-component name.
The process_tgs_req() function dereferences a null pointer because an
unusual failure condition causes a helper function to return success.

While attempting to provide cross-realm referrals for host-based
service principals, the find_referral_tgs() function could return a
TGS principal for a zero-length realm name (indicating that the
hostname in the service principal has no known realm associated with
it).

Subsequently, the find_alternate_tgs() function would attempt to
construct a path to this empty-string realm, and return success along
with a null pointer in its output parameter.  This happens because
krb5_walk_realm_tree() returns a list of length one when it attempts
to construct a transit path between a single-component realm and the
empty-string realm.  This list causes a loop in find_alternate_tgs()
to iterate over zero elements, resulting in the unexpected output of a
null pointer, which process_tgs_req() proceeds to dereference because
there is no error condition.

Add an error condition to find_referral_tgs() when
krb5_get_host_realm() returns an empty realm name.  Also add an error
condition to find_alternate_tgs() to handle the length-one output from
krb5_walk_realm_tree().

The vulnerable configuration is not likely to arise in practice.
(Realm names that have a single component are likely to be test
realms.)  Releases prior to krb5-1.11 are not vulnerable.

Thanks to Sol Jerome for reporting this problem.

CVSSv2: AV:N/AC:M/Au:S/C:N/I:N/A:P/E:H/RL:O/RC:C

ticket: 7668 (new)
tags: pullup
target_version: 1.11.4

12 years agoDocument dict_file format
Greg Hudson [Mon, 1 Jul 2013 16:07:39 +0000 (12:07 -0400)] 
Document dict_file format

Briefly describe the format of the kadmin dictionary file in
kdc_conf.rst.

12 years agoInstall localauth_plugin.h
Greg Hudson [Mon, 1 Jul 2013 15:40:27 +0000 (11:40 -0400)] 
Install localauth_plugin.h

The localauth pluggable interface was added on master in February, but
we neglected to install its header file.

12 years agoInstall ccselect_plugin.h
Greg Hudson [Mon, 1 Jul 2013 15:31:13 +0000 (11:31 -0400)] 
Install ccselect_plugin.h

The ccselect pluggable interface was added in release 1.10, but we
neglected to install its header file.

ticket: 7671 (new)
target_version: 1.11.4
tags: pullup

12 years agoUpdate windows README for VS2012/Windows SDK 8
Ben Kaduk [Fri, 28 Jun 2013 16:08:13 +0000 (12:08 -0400)] 
Update windows README for VS2012/Windows SDK 8

The Windows SDK 8 dropped the command-line build environment, so
provide instructions for building with the Visual Studio (2012)
command-line build environment.

ticket: 7669 (new)
queue: kfw
tags: pullup
target_version: 1.11.4

12 years agoRequire Windows Installer 4.5 or higher
Ben Kaduk [Wed, 26 Jun 2013 20:30:41 +0000 (16:30 -0400)] 
Require Windows Installer 4.5 or higher

As advised by the VC 11 merge modules.

Windows Installer 4.5 requires Windows Server 2008, Windows Vista, Windows XP
with Service Pack 2 (SP2) and later, or Windows Server 2003 with Service
Pack 1 (SP1) and later.  I believe we already enforce these restrictions
manually elsewhere, so this should not restrict our set of valid target
machines.

ticket: 7667 (new)
queue: kfw
tags: pullup
target_version: 1.11.4

12 years agoWiX support for building with VS 2012
Ben Kaduk [Wed, 26 Jun 2013 19:11:37 +0000 (15:11 -0400)] 
WiX support for building with VS 2012

The merge modules need to reference VC110 paths.
Use a variable for VC100 versus VC110 so that we don't copy a lot
of boilerplate around.

ticket: 7666 (new)
queue: kfw
tags: pullup
target_version: 1.11.4

12 years agoFix uninitialized variable bugs
Greg Hudson [Thu, 27 Jun 2013 22:41:04 +0000 (18:41 -0400)] 
Fix uninitialized variable bugs

The previous few commits introduced a couple of bugs where variables
could be used without being initialized.  Fix them.

12 years agoAdd tests for pwqual modules and plugin ordering
Greg Hudson [Fri, 14 Jun 2013 19:28:06 +0000 (15:28 -0400)] 
Add tests for pwqual modules and plugin ordering

Create a test module for the pwqual interface, and script to exercise
the built-in and test modules through kadmin.local.  Also create a
test harness to display the order of pwqual modules for the current
configuration, and use it to test the plugin module ordering
guarantees.

ticket: 7665

12 years agoRely on module ordering for localauth
Greg Hudson [Fri, 14 Jun 2013 05:55:27 +0000 (01:55 -0400)] 
Rely on module ordering for localauth

Register built-in localauth modules in the order we want them used by
default, and document accordingly.

ticket: 7665

12 years agoProvide plugin module ordering guarantees
Greg Hudson [Fri, 14 Jun 2013 05:33:26 +0000 (01:33 -0400)] 
Provide plugin module ordering guarantees

Rewrite the plugin internals so that modules have a well-defined
order--either the order of enable_only tags, or dynamic modules
followed by the built-in modules in order of registration.

ticket: 7665 (new)

12 years agoFix spin loop reading from KDC TCP socket
Viktor Dukhovni [Tue, 25 Jun 2013 16:27:42 +0000 (12:27 -0400)] 
Fix spin loop reading from KDC TCP socket

In the k5_sendto code for reading from a TCP socket, detect
end-of-stream when reading the length.  Otherwise we can get stuck in
an infinite loop of poll() and read().

[ghudson@mit.edu: commit message]

ticket: 7508
target_version: 1.11.4
tags: pullup

12 years agoBuild with Visual Studio 2012
Ben Kaduk [Mon, 24 Jun 2013 22:19:45 +0000 (18:19 -0400)] 
Build with Visual Studio 2012

It's more aggressive about enforcing that keywords are not macros
in C++ mode, and has bumped the MFC version to 11.

Keep compatibility with older versions of Visual Studio, appropriately
conditionalized.

ticket: 7664 (new)
tags: pullup
target_version: 1.11.4

12 years ago[Leash] Notify the user of password change success
Ben Kaduk [Mon, 24 Jun 2013 19:56:54 +0000 (15:56 -0400)] 
[Leash] Notify the user of password change success

ticket: 7440
tags: pullup
target_version: 1.11.4

12 years agoFix timing edge cases in t_renew.py
Greg Hudson [Sun, 16 Jun 2013 20:42:00 +0000 (16:42 -0400)] 
Fix timing edge cases in t_renew.py

When we are testing maximum renewable lifetimes, the KDC might process
the request at a later time than the request time (typically by no
more than one second).  So we need to ask for a ticket lifetime longer
than the maximum renewable lifetime, not equal to it, or we risk
getting a just-barely-renewable ticket instead of a non-renewable one.
Also fix a couple of typos in comments.

12 years agoFix sentinel position in sample u2u server
Greg Hudson [Thu, 13 Jun 2013 15:06:23 +0000 (11:06 -0400)] 
Fix sentinel position in sample u2u server

Print "Server started" after calling listen(), or there wil be a race
where the client tries to connect before there is a listen queue and
gets ECONNREFUSED.

12 years agoFix various warnings
Greg Hudson [Fri, 7 Jun 2013 19:17:31 +0000 (15:17 -0400)] 
Fix various warnings

12 years agoRefactor KDC renewable ticket handling
Greg Hudson [Thu, 6 Jun 2013 18:44:30 +0000 (14:44 -0400)] 
Refactor KDC renewable ticket handling

Create a new helper to compute the renewable lifetime for AS and TGS
requests.  This has some minor behavior differences:

* We only issue a renewable ticket if the renewable lifetime is greater
  than the normal ticket lifetime.

* We give RENEWABLE precedence over RENEWABLE-OK in determining the
  requested renewable lifetime, instead of sometimes doing the
  reverse.

* We use the client's maximum renewable life for TGS requests if we
  have looked up its DB entry.

* Instead of rejecting requests for renewable tickets (if the client
  or server principal doesn't allow it, or a TGS request's TGT isn't
  renewable), issue non-renewable tickets.

ticket: 7661 (new)

12 years agoAdd t_init_creds to .gitignore
Greg Hudson [Thu, 6 Jun 2013 18:53:23 +0000 (14:53 -0400)] 
Add t_init_creds to .gitignore

12 years agoUse KDC clock skew for AS-REQ timestamps
Greg Hudson [Sun, 2 Jun 2013 05:22:38 +0000 (01:22 -0400)] 
Use KDC clock skew for AS-REQ timestamps

Calculate request timestamps each time we encode a request, and use
the adjusted current time when calculating them, including adjustments
resulting from preauth-required errors early in the AS exchange.

As a side effect, this reverts one of the changes in commit
37b0e55e21926c7875b7176e24e13005920915a6 (#7063); we will once again
use the time adjustment from any ccache we read before the AS
exchange, if we don't have a more specific adjustment from a
preauth-required error.

Based on a patch from Stef Walter.

ticket: 7657 (new)

12 years agoRefactor AS-REQ nonce and timestamp handling
Greg Hudson [Sun, 2 Jun 2013 04:31:04 +0000 (00:31 -0400)] 
Refactor AS-REQ nonce and timestamp handling

Create helper functions to set the request nonce and to set the
request timestamp.  Don't bother picking a nonce in
restart_init_creds_loop since we will just pick a new one in
init_creds_step_request.  Create a library-internal function to get
the current time with possible adjustment from a preauth-required
error.  Only set ctx->request_time in one place (just before encoding
each request).  Remove unused parameters from stash_as_reply.

Partially based on a patch from Stef Walter.

12 years agoUntabify and reindent t_authpkinit.py
Greg Hudson [Mon, 3 Jun 2013 19:38:08 +0000 (15:38 -0400)] 
Untabify and reindent t_authpkinit.py

12 years agoFix spurious clock skew caused by preauth delay
Greg Hudson [Sun, 2 Jun 2013 19:36:40 +0000 (15:36 -0400)] 
Fix spurious clock skew caused by preauth delay

Commit 37b0e55e21926c7875b7176e24e13005920915a6 (#7063) prevented
clock skew caused by preauth delay by recording the time of the
initial request.  However, it failed to take into account delay
between requests due to prompting during preauthentication.  Fix this
by recording the request time for each request.

ticket: 7656 (new)

12 years agoClean up dangling antecedent in allow_weak_crypto
Ben Kaduk [Fri, 31 May 2013 16:48:46 +0000 (12:48 -0400)] 
Clean up dangling antecedent in allow_weak_crypto

The "previous three lists" are not previous any more.
Say explicitly which three lists, and make the parenthetical bind
to the correct noun.

ticket: 7655 (new)
tags: pullup
target_version: 1.11.4

12 years agoClarify retiring-des based on user feedback
Ben Kaduk [Fri, 31 May 2013 16:40:10 +0000 (12:40 -0400)] 
Clarify retiring-des based on user feedback

Explain why DES keys should be removed from principals, and clarify
that allow_weak_crypto overrides all other configuration.

ticket: 7654 (new)
tags: pullup
target_version: 1.11.4

12 years agoDocument preauth flags for service principals
Ben Kaduk [Thu, 30 May 2013 22:49:36 +0000 (18:49 -0400)] 
Document preauth flags for service principals

These flags are overloaded to mean different things for clients and
servers; previously we only documented the client behavior.

ticket: 7653 (new)
tags: pullup
target_version: 1.11.4

12 years agoFix warnings in dbtest.c
Gilles Espinasse [Fri, 31 May 2013 17:04:36 +0000 (13:04 -0400)] 
Fix warnings in dbtest.c

Check return values of read() and write().  Avoid some unsigned
comparisons.  Cast a ptrdiff_t value to int for use with %d in a
format string.

[ghudson@mit.edu: rewrap long lines; fix one more warning; commit
message]

12 years agoLink dbtest with libkrb5support
Greg Hudson [Fri, 31 May 2013 16:47:34 +0000 (12:47 -0400)] 
Link dbtest with libkrb5support

In a static build, linking dbtest could fail on platforms where libdb2
depends on krb5support (platforms without a native mkstemp).  Reported
by Gilles Espinasse <g.esp@free.fr>.

ticket: 7651

12 years agoProperly handle use_master in k5_init_creds_get
Greg Hudson [Thu, 30 May 2013 15:39:54 +0000 (11:39 -0400)] 
Properly handle use_master in k5_init_creds_get

If we make multiple requests in an initial creds exchange, the
krb5_sendto_kdc call in k5_init_creds_get may flip the use_master
value from 0 to 1 if it detects that the response was from a master
KDC.  Don't turn this into a requirement for future requests during
the same exchange, or we may have trouble following AS referrals.
Reported by Sumit Bose.

ticket: 7650

12 years agoChange message macro for configure selection
Gilles Espinasse [Wed, 29 May 2013 16:13:57 +0000 (12:13 -0400)] 
Change message macro for configure selection

AC_MSG_RESULT is to print result after AC_MSG_CHECKING.
AC_MSG_NOTICE is to deliver message to user.
So use AC_MSG_NOTICE for --with options.

Remove overquoting too.

ticket: 7648

12 years agoFix non-builtin crypto module builds
Greg Hudson [Wed, 29 May 2013 05:20:19 +0000 (01:20 -0400)] 
Fix non-builtin crypto module builds

Commit 4b0985f8573840838bcfa8ec1df3dcd39a3dbf15 went a bit too far in
pruning the placeholder makefiles for the openssl and nss crypto
modules.  We need enough boilerplate to create OBJS.SH in each
directory.

12 years agoMake empty passwords work via init_creds APIs
Greg Hudson [Thu, 23 May 2013 19:33:58 +0000 (15:33 -0400)] 
Make empty passwords work via init_creds APIs

In the gak_data value used by krb5_get_as_key_password, separate the
already-known password from the storage we might have allocated to put
it in, so that we no longer use an empty data buffer to determine
whether we know the password.  This allows empty passwords to work via
the API.

Remove the kadm5 test which explicitly uses an empty password.

Based on a patch from Stef Walter.

ticket: 7642

12 years agoFix rc4 string-to-key on unterminated inputs
Greg Hudson [Fri, 24 May 2013 17:16:52 +0000 (13:16 -0400)] 
Fix rc4 string-to-key on unterminated inputs

The internal UTF-8 to UCS-2 conversion functions did not properly
respect their length arguments, instead assuming that the input string
is terminated with a zero bytes.  As a result,
krb5int_arcfour_string_to_key could fail on unterminated inputs.  Fix
the underlying support functions to read their inputs only up to the
specified length.

ticket: 7643 (new)

12 years agoDon't warn or error on variadic macros
Greg Hudson [Sat, 25 May 2013 18:35:41 +0000 (14:35 -0400)] 
Don't warn or error on variadic macros

Our portability assumptions now allow the use of variadic macros, so
don't warn or error on them.

12 years agoAdd AES-NI support on Linux
Greg Hudson [Sun, 5 May 2013 01:52:21 +0000 (21:52 -0400)] 
Add AES-NI support on Linux

If yasm and cpuid.h are present on a Linux i686 or x64 system, compile
the modified Intel AES-NI assembly sources.  In the builtin AES enc
provider, check at runtime whether the CPU supports AES-NI
instructions and use the assembly functions if so.

12 years agoAdjust AESNI sources for krb5 tree
Greg Hudson [Sat, 4 May 2013 23:09:38 +0000 (19:09 -0400)] 
Adjust AESNI sources for krb5 tree

Remove functions we don't need.  Add macros to redefine functions with
an appropriate namespace prefix.

12 years agoAdd Intel AESNI assembly files
Greg Hudson [Wed, 24 Apr 2013 17:04:19 +0000 (13:04 -0400)] 
Add Intel AESNI assembly files

Add assembly files from the Intel AESNI Sample Library, version 1.2,
which implement AES encryption using AES-NI instructions.  Trailing
whitespace was removed.

12 years agoRefactor AES, Camellia builtin enc providers
Greg Hudson [Tue, 7 May 2013 00:23:09 +0000 (20:23 -0400)] 
Refactor AES, Camellia builtin enc providers

In preparation for AES-NI support, adjust the block encryption helpers
in the AES enc provider so that the cache is only touched by helpers,
and reframe the CTS operations in terms of CBC operations.  Change the
Camellia enc provider as well for consistency.

12 years agoSimplify crypto IOV helpers
Greg Hudson [Mon, 6 May 2013 04:43:27 +0000 (00:43 -0400)] 
Simplify crypto IOV helpers

Expand the concept of an IOV block state into a cursor which remembers
the IOV set being iterated over, the block size, and both input and
output positions.  Eliminate the no-copy inline block getter for now,
but provide helpers to grab contiguous chains of blocks from a cursor.
Also provide an inline helper to sum the total length of an iov chain.

12 years agoFix krb5_rd_req usage in user-to-user sample app
Greg Hudson [Wed, 22 May 2013 05:57:36 +0000 (01:57 -0400)] 
Fix krb5_rd_req usage in user-to-user sample app

Pass the server principal to krb5_rd_req so it can do proper transited
checking.

12 years agoClarify krb5_rd_req documentation
Greg Hudson [Wed, 22 May 2013 05:55:12 +0000 (01:55 -0400)] 
Clarify krb5_rd_req documentation

For the user-to-user case, document that callers should pass a server
principal to krb5_rd_req.  For the keytab case, more accurately
document which keytab keys are tried against the ticket.

ticket: 7641 (new)
target_version: 1.11.3
tags: pullup

12 years agoFix transited handling for GSSAPI acceptors
Greg Hudson [Mon, 20 May 2013 15:03:04 +0000 (11:03 -0400)] 
Fix transited handling for GSSAPI acceptors

The Acceptor Names project (#6855) extended krb5_rd_req so that it can
accept a "matching principal" in the server parameter.  If the
matching principal has an empty realm, rd_req_decoded_opt attempted to
do transited checking with an empty server realm.

To fix this, always reset server to req->ticket->server for future
processing steps if we decrypt the ticket using a keytab.
decrypt_ticket replaces req->ticket->server with the principal name
from the keytab entry, so we know this name is correct.

Based on a bug report and patch from nalin@redhat.com.

ticket: 7639
target_version: 1.11.3
tags: pullup

12 years agoClarify that kdc.conf and krb5.conf are merged
Ben Kaduk [Mon, 20 May 2013 17:04:32 +0000 (13:04 -0400)] 
Clarify that kdc.conf and krb5.conf are merged

These two files are merged into the profile for KDC applications

12 years agoTry to use best DNS search functions in dnsglue.c
Greg Hudson [Tue, 14 May 2013 18:17:05 +0000 (14:17 -0400)] 
Try to use best DNS search functions in dnsglue.c

Create macros to declare a DNS search handle, initialize a handle,
perform a search, and destroy a handle.  On OS X, use the native
dns_open, dns_search, and dns_free functions, since using the res_*
interfaces may not contact the correct servers.  On systems with
res_ninit, use res_nclose if we don't have res_ndestroy.

Based on a patch by Nate Rosenblum.

12 years agoReduce boilerplate in makefiles
Greg Hudson [Thu, 16 May 2013 18:21:12 +0000 (14:21 -0400)] 
Reduce boilerplate in makefiles

Provide default values in pre.in for PROG_LIBPATH, PROG_RPATH,
SHLIB_DIRS, SHLIB_RDIRS, and STOBJLISTS so that they don't have to be
specified in the common case.  Rename KRB5_RUN_ENV and KRB5_RUN_VARS
to RUN_SETUP (already the most commonly used name) and RUN_VARS.  Make
sure to use DEFINES for local defines (not DEFS).  Remove some other
unnecessary makefile content.

12 years agoRemove unused build system variables
Greg Hudson [Wed, 15 May 2013 18:30:26 +0000 (14:30 -0400)] 
Remove unused build system variables

12 years agoFix windows build
Ben Kaduk [Thu, 16 May 2013 20:06:51 +0000 (16:06 -0400)] 
Fix windows build

Catch a few stragglers that missed the memo that k5_mutex_lock
cannot fail, and sprinkle some cc-int.h as needed.

12 years agoFix NSS crypto back end for mutex changes
Greg Hudson [Thu, 16 May 2013 06:52:40 +0000 (02:52 -0400)] 
Fix NSS crypto back end for mutex changes

Adjust a stray k5_mutex_lock invocation in the NSS crypto back end
after 6350fd0c909d84c00200885e722cc902049ada05.

12 years agoAssume mutex locking cannot fail
Greg Hudson [Fri, 10 May 2013 18:01:48 +0000 (14:01 -0400)] 
Assume mutex locking cannot fail

Locking and unlocking a non-recursive mutex is a simple memory
operation and should not fail on any reasonable platform with correct
usage.  A pthread mutex can return EDEADLK on lock or EPERM on unlock,
or EINVAL if the mutex is uninitialized, but all of these conditions
would reflect serious bugs in the calling code.

Change the k5_mutex_lock and k5_mutex_unlock wrappers to return void
and adjust all call sites.  Propagate this change through
k5_cc_mutex_lock and k5_cc_mutex_unlock as well.

12 years agoDon't use "bool" for ASN.1 boolean macros
Nate Rosenblum [Tue, 14 May 2013 03:26:31 +0000 (20:26 -0700)] 
Don't use "bool" for ASN.1 boolean macros

When building for IOS targets with clang, the stdbool.h header is
included by default. This header includes the following C99
definition:

    #define bool _Bool

which wrecks havoc with the DEFBOOLTYPE macro.

ticket: 7525

12 years agoRename internal Camellia symbols
Greg Hudson [Tue, 14 May 2013 02:59:35 +0000 (22:59 -0400)] 
Rename internal Camellia symbols

Symbols from the NTT Camellia sources, used in the builtin crypto
provider, could conflict with symbols from other libraries such as
OpenSSL's libcrypto.  Rename those like we rename the Gladman AES
symbols.

ticket: 7626
target_version: 1.11.3
tags: pullup

12 years agoFix kpasswd UDP ping-pong [CVE-2002-2443]
Tom Yu [Fri, 3 May 2013 20:26:46 +0000 (16:26 -0400)] 
Fix kpasswd UDP ping-pong [CVE-2002-2443]

The kpasswd service provided by kadmind was vulnerable to a UDP
"ping-pong" attack [CVE-2002-2443].  Don't respond to packets unless
they pass some basic validation, and don't respond to our own error
packets.

Some authors use CVE-1999-0103 to refer to the kpasswd UDP ping-pong
attack or UDP ping-pong attacks in general, but there is discussion
leading toward narrowing the definition of CVE-1999-0103 to the echo,
chargen, or other similar built-in inetd services.

Thanks to Vincent Danen for alerting us to this issue.

CVSSv2: AV:N/AC:L/Au:N/C:N/I:N/A:P/E:P/RL:O/RC:C

ticket: 7637 (new)
target_version: 1.11.3
tags: pullup

12 years agoFixes for leaking of refcounted resources
Nalin Dahyabhai [Thu, 25 Apr 2013 22:10:40 +0000 (18:10 -0400)] 
Fixes for leaking of refcounted resources

Some fixes, some use of different APIs which seem to clean things up
better, with the goal of being able to cleanly shut down NSS when we're
done using it.

* Use PK11_FreeSlot() instead of SECMOD_CloseUserDB() to close a
  database opened with SECMOD_OpenUserDB().
* Fix a typo and use PK11_DestroyGenericObject() instead of
  PK11_DestroyGenericObjects() to destroy one object.
* Use SECMOD_DestroyModule() instead of SECMOD_UnloadUserModule()
  to close a module loaded with SECMOD_LoadUserModule().
* crypto_check_for_revocation_information(): don't leak a reference
  to the CRL, or to intermediate issuers.
* Don't leak a reference to a PEM private key.

12 years agoIn PKINIT NSS crypto, support encrypted PEM keys
Nalin Dahyabhai [Wed, 24 Apr 2013 19:29:27 +0000 (15:29 -0400)] 
In PKINIT NSS crypto, support encrypted PEM keys

When the PEM module is given an encrypted key, it changes its token
flags to indicate that a password is required (by setting needs-login)
to signal the application that we need to supply a password to decrypt
it.  Attempts to load any other items will fail until the flag is
cleared.

If we detect that the flag is set after we've attempted to load a
private key, attempt to "log in" to the "token" using a password.  Even
if we fail, the token will reset its needs-login flag, which is
necessary before we can import anything else.

12 years agoGet better at locating the just-loaded certificate
Nalin Dahyabhai [Wed, 24 Apr 2013 19:22:05 +0000 (15:22 -0400)] 
Get better at locating the just-loaded certificate

When loading certificates using the PEM module, use a better method for
finding the just-loaded certificate that will still work if we've
already got a copy of the certificate loaded somewhere else.

12 years agoIn PKINIT NSS crypto code, load certificates first
Nalin Dahyabhai [Wed, 24 Apr 2013 18:43:59 +0000 (14:43 -0400)] 
In PKINIT NSS crypto code, load certificates first

When using NSS's CMS API to generate signed-data messages, we identify
the key that we want to use for signing by specifying a certificate.
The library then looks up the corresponding private key when it needs to
generate the signature.  This lookup fails if a certificate and a its
corresponding private key were loaded key-first, but succeeds if they
were loaded certificate-first (RHBZ#859535).  To work around this,
switch to loading the certificate first.  (We switch to using different
_pkinit_identity_crypto_file pointers for each instead of reusing just
one, so the diff is messier than it might have been.)

12 years agoWhen DEBUG=1, log why we fail to log in to a token
Nalin Dahyabhai [Wed, 24 Apr 2013 17:52:23 +0000 (13:52 -0400)] 
When DEBUG=1, log why we fail to log in to a token

Use PORT_ErrorToName() to let us print an error name instead of an error
code in a couple of debug messages, since in practice we just end up
looking up the code in <secerr.h> anyway.

12 years agoTraverse tokens like we do with OpenSSL for NSS
Nalin Dahyabhai [Thu, 10 Jan 2013 20:39:15 +0000 (15:39 -0500)] 
Traverse tokens like we do with OpenSSL for NSS

When PKINIT is built with NSS, change how it traverses tokens to match
the way it's done when built using OpenSSL: ignore slot names (we used
to treat the token label as a possible slot label, too), and either only
look at the token with the specified label, or the first token if a no
token label was specified.

12 years agoOnly call SEC_PKCS12DecoderFinish() once
Nalin Dahyabhai [Thu, 20 Dec 2012 18:51:12 +0000 (13:51 -0500)] 
Only call SEC_PKCS12DecoderFinish() once

We already call SEC_PKCS12DecoderFinish() before entering the switch()
statement, so don't call it again.

12 years agoMake the text of NSS's prompts look like OpenSSL's
Nalin Dahyabhai [Tue, 18 Dec 2012 22:41:11 +0000 (17:41 -0500)] 
Make the text of NSS's prompts look like OpenSSL's

When PKINIT is built with NSS, make the text of prompts that we issue to
the user better match the text we use when we build with OpenSSL: ask
for a pass phrase when we're asking about a hardware token, ask for a
password the rest of the time, and take advantage of translations for
requests for a password.

12 years agoDon't fail if a candidate certificate has no SANs
Nalin Dahyabhai [Mon, 14 Jan 2013 18:57:54 +0000 (13:57 -0500)] 
Don't fail if a candidate certificate has no SANs

When we're doing certificate matching and we're asked for the list of
SAN values for a certifiate, and it contains none, don't return an
error, as that will eventually cause the module to just return an error.
Instead, just return an empty list of SAN values so that processing will
continue on to check if other certificates match.

12 years agoFix type mismatch in db2_exp.c
Greg Hudson [Fri, 10 May 2013 19:03:25 +0000 (15:03 -0400)] 
Fix type mismatch in db2_exp.c

The locking wrapper for audit_as_req used the wrong function
signature, which was harmless but produced a couple of warnings.  Fix
it.

12 years agoFix check for KDB: prefix in kinit
Richard Basch [Fri, 10 May 2013 16:24:21 +0000 (12:24 -0400)] 
Fix check for KDB: prefix in kinit

The string "KDB:" has four characters, not three; check for all four
of them.

[ghudson@mit.edu: commit message]

ticket: 7636

12 years agoAdd test case for CVE-2013-1416
Tom Yu [Thu, 9 May 2013 20:51:31 +0000 (16:51 -0400)] 
Add test case for CVE-2013-1416

ticket: 7635 (new)

12 years agofix crypto openssl hmac warning
Gilles Espinasse [Thu, 9 May 2013 15:58:14 +0000 (11:58 -0400)] 
fix crypto openssl hmac warning

ticket: 7634

12 years agoImprove LDAP password file error messages
Greg Hudson [Wed, 8 May 2013 19:55:58 +0000 (15:55 -0400)] 
Improve LDAP password file error messages

If we cannot open the LDAP password file or cannot find the bind DN in
it, include the filename and DN in the error message.

ticket: 7632

12 years agoMake reassembled PKCS11 names parseable
Nalin Dahyabhai [Tue, 26 Feb 2013 22:59:01 +0000 (17:59 -0500)] 
Make reassembled PKCS11 names parseable

The reassembled names used "," as a separator between attributes, when
passed-in values use ":".  This was due to the original submitter being
confused - they weren't intended to be different.

12 years agoFix a typo that caused us to not skip removing "."
Nalin Dahyabhai [Tue, 30 Apr 2013 21:37:22 +0000 (17:37 -0400)] 
Fix a typo that caused us to not skip removing "."

When attempting to clean the files out from our temporary directory,
correct the test which was supposed to let us skip over "." and ".." so
that we actually don't try to remove them with remove().

12 years agoFix checking unencrypted PKCS12: twice
Nalin Dahyabhai [Tue, 30 Apr 2013 21:07:23 +0000 (17:07 -0400)] 
Fix checking unencrypted PKCS12: twice

The test, as submitted, included a copy/paste error which caused it to
test PKINIT using unencrypted PKCS12 bundles twice, and to not test a
DIR: location containing unencrypted PEM-formatted keys at all.

12 years agoRemove some apparently-accidental debug whitespace
Nalin Dahyabhai [Wed, 13 Feb 2013 23:45:22 +0000 (18:45 -0500)] 
Remove some apparently-accidental debug whitespace

12 years agoRemove dangling reference to $with_edirectory
Nalin Dahyabhai [Thu, 20 Dec 2012 21:47:50 +0000 (16:47 -0500)] 
Remove dangling reference to $with_edirectory

Remove a reference to eDirectory that persisted after support for
eDirectory was removed.  Almost certainly harmless anyway.

[ghudson@mit.edu: also quote $with_ldap]

12 years agoMake AS requests work with no client key
Greg Hudson [Thu, 2 May 2013 20:15:32 +0000 (16:15 -0400)] 
Make AS requests work with no client key

If we cannot find a client key while preparing an AS reply, give
preauth mechanisms a chance to replace the reply key before erroring
out.

ticket: 7630

12 years agoDon't send empty etype info from KDC
Greg Hudson [Mon, 29 Apr 2013 18:55:31 +0000 (14:55 -0400)] 
Don't send empty etype info from KDC

RFC 4120 prohibits empty ETYPE-INFO2 sequences (though not ETYPE-INFO
sequences), and our client errors out if it sees an empty sequence of
either.

ticket: 7630

12 years agoCheck for keys in encrypted timestamp/challenge
Greg Hudson [Fri, 26 Apr 2013 19:51:05 +0000 (15:51 -0400)] 
Check for keys in encrypted timestamp/challenge

Encrypted timestamp and encrypted challenge cannot succeed if the
client has no long-term key matching the request enctypes, so do not
offer them in that case.

ticket: 7630

12 years agoAdd kdcpreauth callback to check for client keys
Greg Hudson [Fri, 26 Apr 2013 19:50:05 +0000 (15:50 -0400)] 
Add kdcpreauth callback to check for client keys

Add a new have_client_keys callback to the kdcpreauth interface,
allowing modules to efficiently check whether the client DB entry has
any keys matching the request enctypes.

ticket: 7630