Stef Walter [Tue, 23 Jul 2013 21:04:32 +0000 (23:04 +0200)]
Make tests work on file systems with block size directories
On certain file systems the size of the directory does not
change when adding a file. This caused the tests to fail. Make
the tests wait more than a second in certain tests to get the
mtime to change.
Stef Walter [Thu, 18 Jul 2013 10:50:34 +0000 (12:50 +0200)]
Use $XDG_CONFIG_HOME/pkcs11 as default user config directory
By default this evaluates to ~/.config/pkcs11. This is a somewhat
backwards incompatible change. However so far only advanced users
have been exposed to the user p11-kit configuration.
Distributors are able to revert this if necessary with a
--with-user-config='~/.pkcs11' ./configure option.
Stef Walter [Wed, 17 Jul 2013 07:51:32 +0000 (09:51 +0200)]
tools: Use $TMPDIR instead of $TEMP
TMPDIR is a more standard environment variable for locating the
temp directory on Unix. In addition since this is only used in
tests, remove the code from the generic p11_path_expand() func.
In general remove the possibility for forks to put $HOME or $TEMP
environment variables in configured paths. This was possible
due to code in p11_path_expand() but not something we supported.
Stef Walter [Tue, 16 Jul 2013 19:20:44 +0000 (21:20 +0200)]
buffer: Check for unlikely integer overflow
If we see an integer overflow here something has gone horribly wrong
(or malicious code is present). So treat this as unrecoverable, and
fail if we're going to overflow.
Stef Walter [Tue, 16 Jul 2013 15:18:02 +0000 (17:18 +0200)]
iter: Document guarantees for filter matches argumet
The matches argument is always initialized to CK_TRUE when a filter
is called, and it's up to filters to set it to CK_FALSE. Filters
don't need to set to CK_TRUE.
Stef Walter [Thu, 4 Jul 2013 13:48:38 +0000 (15:48 +0200)]
trust: Port to use CKA_PUBLIC_KEY_INFO and updated trust store spec
* Use the concepts and PKCS#11 objects described in the
recently updated (still work in progress) storing trust spec.
* Define our own CKA_X_PUBLIC_KEY_INFO define for now, since the
the CKA_PUBLIC_KEY_INFO isn't defined yet.
* Most notably, the association between certificates and stapled
extensions is by public key.
* Rework some of the tests to take into account the above.
Stef Walter [Fri, 28 Jun 2013 15:19:22 +0000 (17:19 +0200)]
trust: Rename p11_index_batch() to p11_index_load()
The name makes it clearer what's going on. This is only used
during loading, so we can track whether a change has resulted
from the trust module or from the file storage.
Stef Walter [Fri, 28 Jun 2013 11:27:42 +0000 (13:27 +0200)]
trust: Implement reloading of token data
* Reload token data whenever a new session is opened.
* Only reload files/directories that have changed.
* Move duplicate anchor/blacklist detection logic into
the extract code. This is in line with the approach
being discussed on the mailing lists and spec document.
* New internal attribute CKA_X_ORIGIN set on all objects
so we can track where an object came from, and replace
it when reloaded.
In general this is a prerequisite for modification of objects
reload before modify is necessary to prevent multiple callers
clobbering each other's changes.
Stef Walter [Fri, 28 Jun 2013 11:00:02 +0000 (13:00 +0200)]
iter: Add iteration mode where session is not busy
In order to use the session we are iterating on for other tasks
such as other C_FindObject() calls, we need to make sure that
it's not in the middle of a find operation. Finish up the
complete find operation in advance of returning objects from
a session.
Make this the default mode. The previous behavior remains
as an option. Add tests.
Stef Walter [Mon, 24 Jun 2013 11:34:30 +0000 (13:34 +0200)]
Reorganize various components
* p11-kit library and tool in the p11-kit/ subdirectory
* trust module and new trust tool in trust/ subdirectory
* No more tools/ subdirectory
* Lots less in the common/ subdirectory
Stef Walter [Fri, 14 Jun 2013 20:00:42 +0000 (22:00 +0200)]
trust: Writable module PKCS#11 token functions
Although we don't actually write anything out yet, make the
various PKCS#11 functions behave properly when faced with
requests to write to token objects
Stef Walter [Mon, 17 Jun 2013 12:36:37 +0000 (14:36 +0200)]
tools: Only use our private path when looking for external commands
Instead of looking for external commands in the path, just look
for them in our private directory.
We want to be conservative early on, and limit what sorta things
we have to maintain later. We can later remove this restriction
if a real use case presents itself.
Stef Walter [Fri, 5 Apr 2013 21:52:39 +0000 (23:52 +0200)]
Our own unit testing framework
* Support the TAP protocol
* Much cleaner without having to carry around state
* First class support for setup/teardown
* Port the common tests
* Wait on porting other tests until we've merged outstanding code
Stef Walter [Sat, 6 Apr 2013 14:42:01 +0000 (16:42 +0200)]
Further reorganization of the core module tracking
* Keep the module ownership apart from the tracking of module
function pointers, since these are only relevant for unmanaged
modules.
* Less assumptions that each module has a raw unmanaged module
function pointer.
* More clarity in the naming of dictionaries tracking the modules.
Stef Walter [Fri, 15 Feb 2013 20:34:20 +0000 (21:34 +0100)]
Update the proxy module to use managed PKCS#11 modules
Each time C_GetFunctionList is called on the proxy module, a new
managed PKCS#11 set of functions is returned. These are all cleaned
up when the module is unloaded.
We want the proxy module to continue to work even without the highly
recommended libffi. For that reason we still keep the old behavior of
sharing state in the proxy module.
Stef Walter [Wed, 6 Feb 2013 20:57:45 +0000 (21:57 +0100)]
p11-kit: Managed PKCS#11 module loading
Support a new managed style module loading for PKCS#11 modules. This
allows us to better coordinate between multiple callers of the same
PKCS#11 modules and provide hooks into their behavior.
This meant redoing the public facing API. The old methods are now
deprecated, marked and documented as such.
Stef Walter [Thu, 14 Feb 2013 14:41:45 +0000 (15:41 +0100)]
Add subclassable CK_X_FUNCTION_LIST
One of the flaws in PKCS#11 for our usage is that each PKCS#11 module
is not passed the pointer to the function list, ie: the vtable
Here we define a new function list vtable, where each PKCS#11 function
takes the vtable itself as the first argument. We use this new
list internally to represent subclassable PKCS#11 modules for
various features.
Stef Walter [Wed, 15 May 2013 09:51:22 +0000 (11:51 +0200)]
Implement valgrind's hellgrind checks for threading problems
And cleanup our locks/locking model. There's no need to use
recursive locks, especially since we can't use them on all
platforms. In addition adjust taking of locks during initialization
so that there's no chance of deadlocking here.