Stef Walter [Wed, 23 Jan 2013 11:15:27 +0000 (12:15 +0100)]
Implement code for writing PEM
* Based on the gcr code
* Bring in base64 output code from BSD
* Make sure to output base64 lines of 64 character length since
this is what OpenSSL expects
Stef Walter [Wed, 23 Jan 2013 16:35:58 +0000 (17:35 +0100)]
Support for sane writing to files extracted
* Implement atomic writes of files
* Writing with checks that not overwriting anything unless desired
* Writing and overwriting of directory contents in a robust way
Stef Walter [Fri, 4 Jan 2013 12:57:28 +0000 (13:57 +0100)]
Implement trust assertion PKCS#11 objects
* Implement trust assertions for anchored and distrusted certs
* Pinned certificate trust assertions are not implemented yet
* Add an internal tool for pulling apart bits of certificates
Stef Walter [Thu, 3 Jan 2013 10:07:47 +0000 (11:07 +0100)]
Fill in certificate authority and trust data correctly
* Fill in CKA_CERTIFICATE_CATEGORY properly for authorities
based on the presence of BasicConstraints and/or v1 certificates
* Fill in CKA_TRUSTED and CKA_X_DISTRUSTED based on whether the
parser is running for anchors or blacklist
* In addition support the concept of blacklisted certificates mixed
in with the anchors (without any purposes) since that's what exists
in the real world.
* We do this after the various hooks have had a chance to mess
with the certificate extensions and such.
* Use stapled certificate extensions to represent loaded trust policy
* Build NSS trust objects from stapled certificate extensions
* Add further attribute debugging for NSS trust objects
* Use a custom certificate extension for the OpenSSL reject purpose data
* Use SubjectKeyIdentifier for OpenSSL keyid data
* Use ExtendedKeyUsage for OpenSSL trust purpose data
* Implement simple way to handle binary DER OIDs, using the DER TLV
length. DER OIDs are used in the CKA_OBJECT_ID value, and elsewhere.
* Split out the building of NSS trust objects from the main parser
Stef Walter [Thu, 24 Jan 2013 10:28:47 +0000 (11:28 +0100)]
Add basic checksum algorithms
The SHA-1 and MD5 digests here are used for checksums in legacy
protocols. We don't use them in cryptographic contexts at all.
These particular algorithms would be poor choices for that.
Stef Walter [Tue, 29 Jan 2013 10:43:09 +0000 (11:43 +0100)]
Make the p11-kit tool have distinct commands
* Change the -l argument into the list-modules command.
* Add proper functions for printing usage
* Support for external commands in the path or /usr/share/p11-kit
Stef Walter [Thu, 24 Jan 2013 13:36:59 +0000 (14:36 +0100)]
Further tweaks and cleanup for functions dealing with PKCS#11 attributes
* Check that the size is correct when looking for a boolean
or a ulong.
* Make sure that the length is not the invalid negative ulong.
* Functions for dumping out attribute contents
* Make it possible to use attributes in hash tables
Stef Walter [Wed, 23 Jan 2013 13:29:25 +0000 (14:29 +0100)]
Use the stdbool.h C99 bool type
It was getting really wild knowing whether a function returning
an int would return -1 on failure or 0 or whether the int return
value was actually a number etc..
Stef Walter [Wed, 2 Jan 2013 15:52:02 +0000 (16:52 +0100)]
Move the pkcs11.h header files into common directory
* Allows use of them across the whole project
* Put a stub file in the p11-kit/ directory, so we can still refer
to the headers using that path, which is what it will be at
when in the installed includes directory.
Stef Walter [Mon, 7 Jan 2013 10:01:09 +0000 (11:01 +0100)]
Fix documentation warnings.
* P11_KIT_URI_NO_MEMORY is an unexpected state, that will probably
never actually be returned. But kept for API compatibility.
* make distcheck doc fix
Stef Walter [Mon, 7 Jan 2013 08:20:25 +0000 (09:20 +0100)]
Guarantee that the key is freed when replaced
* When setting a key in a map that already exists, then free
the old key and replace with the new one.
* Fix related bug where key was not properly allocated
* Add tests for this
Stef Walter [Tue, 18 Sep 2012 14:26:06 +0000 (16:26 +0200)]
Refuse to load the p11-kit-proxy.so as a registered module
* Since p11-kit-proxy.so is a symlink to the libp11-kit.so library
we check that we are not calling into our known CK_FUNCTION_LIST
for the proxy code.
* Although such a configuration is invalid, detecting this directly
prevents strange initialization loop issues that are hard to debug.
Stef Walter [Tue, 18 Sep 2012 12:01:54 +0000 (14:01 +0200)]
Don't fail initialization if last initialized module fails
* We weren't resetting the result code after a failure,
so even though failures for critical modules didn't interrupt
the initialization loop, the result still leaked to callers.
* Also print an error message clearly indicating that a module
failed to initialize, regardless of whether critical or not.
Stef Walter [Thu, 6 Sep 2012 09:01:57 +0000 (11:01 +0200)]
Change the default of 'user-config' to merge.
* This allows user configured PKCS#11 modules by default.
* Admins can change this to 'none' in /etc/pkcs11/pkcs11.conf
to go back to the previous behavior.
* Posted to the mailing list.
Stef Walter [Tue, 17 Jul 2012 06:08:04 +0000 (08:08 +0200)]
Don't rely on loading order for duplicate modules
* We had relied on module 'two' loading before 'two-duplicate'
in the conf tests. However this isn't always the case, and the
name of the module can end up as 'two-duplicate'
Stef Walter [Tue, 17 Jul 2012 06:06:28 +0000 (08:06 +0200)]
Use Windows thread ids instead of handles for comparisons
* It seems that the HANDLE's returned from GetCurrentThread
are often equal for two threads. GetCurrentThreadID doesn't
have this problem.
* Separate our cross platform thread_t and thread_id_t types
even though on unix they're the same thing.
Stef Walter [Mon, 16 Jul 2012 15:56:24 +0000 (17:56 +0200)]
Use '.module' extension on module configs
* And want alphanumeric/_.- filenames
* Currently this is just a warning, soon it will be enforced
* The name of a module does not include the extension
Andreas Metzler and Ubuntu both worked on this patch, and I've made
some more changes.
See https://bugs.launchpad.net/ubuntu/+source/p11-kit/+bug/911436
Stef Walter [Fri, 8 Jun 2012 07:29:59 +0000 (09:29 +0200)]
Fix the flags in pin.h
* Due to a brain fart the P11_KIT_PIN_* flags were not
bit flags but decimal numbers.
* This necessarily breaks API/ABI for users of the
P11_KIT_PIN_FLAGS_RETRY, P11_KIT_PIN_FLAGS_MANY_TRIES and
P11_KIT_PIN_FLAGS_FINAL_TRY flags. But those wouldn't have
worked anyway.
Stef Walter [Sun, 13 May 2012 20:27:07 +0000 (22:27 +0200)]
Preconditions to check for input probs and out of memory
* We don't try to guarantee completely robust and problem
free behavior in cases where the caller or process isn't
behaving. We consider these to be outside of our control.
Stef Walter [Sun, 1 Apr 2012 19:53:04 +0000 (21:53 +0200)]
Add enable-in and disable-in options to module config
* These can be used to load certain modules in certain
programs, or prevent loading in others.
* Useful for a key manager like seahorse, so we can load
extra modules (think NSS) that other modules shouldn't
load.
Stef Walter [Tue, 27 Mar 2012 10:14:56 +0000 (12:14 +0200)]
Fix broken hashmap behavior
* We were relying on undefined gcc behavior related to the &
operator.
* This would show up as a test failure when running with -O2 on
certain GCC versions, as well as failure on clang 3.1
Stef Walter [Mon, 23 Jan 2012 08:09:31 +0000 (09:09 +0100)]
Remove automatic reinitialization of PKCS#11 after fork
* First of all one should only call async-signal-safe functions
from the callbacks of pthread_atfork(), and so we cannot
reinitialize directly.
* Some modules use pthread_atfork() to detect forking and setup
their internal state. If we call into them in our pthread_atfork()
callback then this is inherently racy.
* There was danger of endless loops and deadlocks which are caused
by handlers which fork in their C_Initialize
* Many processes do fork/exec, reinitializing PKCS#11 for these
forks is quite resourc intensive when the child process won't use
PKCS#11 at all.