1
0
mirror of https://github.com/opencryptoki/opencryptoki.git synced 2026-10-24 05:39:17 +03:00

49 Commits

Author SHA1 Message Date
Ingo Franzki
c87900ac8f CONFIGURE/MAKE: Fix configure script and make files
Fix several inconsistencies and errors in the configure script and make files.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
2026-08-25 14:45:29 +02:00
Ingo Franzki
f805c40269 SysV: Use full path of pkcsslotd executable
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
2026-08-25 14:45:29 +02:00
Ingo Franzki
30fdb2786f OPENCRYPTOKI.PC: Don't shadow libdir variable
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
2026-08-25 14:45:29 +02:00
Ingo Franzki
9a8d1b7a36 PKCSSLOTD.SERVICE: Add rundir to ReadWritePaths
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
2026-08-25 14:45:29 +02:00
Ingo Franzki
4a41b4f525 tmpfiles.conf: Do not create token specific dirs inside /var/lock/opencryptoki/
Do not let tmpfiles.d create the token specific directories inside
/var/lock/opencryptoki/. It is not known during build time which tokens
will exist later during run time. A user may configure any number of
tokens with any names in /etc/opencryptoki/opencryptoki.conf.

The API layer will create any non-existing token specific lock directories
inside /var/lock/opencryptoki/ during C_Initialize() as needed.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
2023-10-23 09:33:25 +02:00
Ingo Franzki
ff52d11160 Make pkcsslotd user and pkcs11 group configurable
Allow to specify the pkcsslotd user and the pkcs11 group during
configuration.

Use '--with-pkcsslotd-user=USER' and/or '--with-pkcs-group=GROUP'
to specify the user and group name. The defaults are 'pkcsslotd'
and 'pkcs11'.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
2023-04-20 15:13:44 +02:00
Ingo Franzki
64f33c5729 pkcsslotd.service: harden pkcsslotd service unit using sandboxing options
Use various sandboxing options for running the pkcsslotd via systemd.

Many of these options are not really needed, because pkcsslotd run under
a non-privileged user (user pkcsslotd) so it can't perform any privileged
actions anyway.

With these settings, 'systemd-analyze security pkcsslotd.service' reports
an exposure level of 1.7 (score range 0.0 - 10.0).

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
2023-04-20 15:13:44 +02:00
Ingo Franzki
9b977a5954 Run pkcsslotd under the pkcsslotd user and not under root
Create the unix sockets and the PID file in /run/opencryptoki, and make
sure the /run/opencryptoki directory as well as the lock and log directories
are created during 'make install' as well as during system startup via
tmpfiles.d. Since the /run directory usually is within a tmpfs file system,
it won't exist after a system restart otherwise.

Also make the /run/opencryptoki directory be owned by the 'pkcsslotd' user
and the 'pkcs11' group, and only writable by the 'pkcsslotd' user.
That way, pkcsslotd can only be started by the 'pkcsslotd' user (or root).
Nevertheless, members of the 'pkcs11' group can still connect to the sockets,
and thus can still communicate with pkcsslotd.

The 'pkcsslotd' user is created (if not already existent) during 'make install'
and RPM installation, together with the 'pkcs11' group.

When the pkcsslotd is started as 'root', change its uid to 'pkcsslotd' to drop
privileges and capabilities. Any capabilities set on the executable file
are retained, regardless if started as root or as pkcsslotd user.

If started as root, pkcsslotd can create any missing base directories, otherwise
an error is reported. It is expected that the base directories have been created
during package installation and/or tmpfiles.d prior to starting pkcsslotd.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
2023-04-20 15:13:44 +02:00
Ingo Franzki
d81d638fc3 configure: Fix install location of tmpfiles.d config file
Don't prefix with destination directory, as this would produce an invalid directory.
This would for example cause rpmbuild to fail.
Autoconf prefixes it with the destination directory automatically.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
2023-02-06 11:46:51 +01:00
Ingo Franzki
dd7b4fe1ed makefile: Move pkgconfig file opencryptoki.pc.in into misc directory
The opencryptoki pkgconfig file opencryptoki.pc.in is similar to the other
files currently residing in the misc directory, such as the systemd service
unit file pkcsslotd.service.in, the init.d script pkcsslotd.in, and the
tmpfiles.d config file tmpfiles.conf.in. So lets move it there.

opencryptoki.pc is built from opencryptoki.pc.in via AC_CONFIG_FILES
in configure.ac, so no need to include it into DISTCLEANFILES explicitly,
it will be cleaned with 'make distclean' automatically.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
2022-10-21 11:15:27 +02:00
Ingo Franzki
4d4712a172 makefile: Correct installation of opencryptoki.conf into tempfiles.d
Install opencryptoki.conf (which is built from misc/tmpfiles.conf.in)
right into /usr/lib/tmpfiles.d/.

Currently, misc/tmpfiles.conf is built from misc/tmpfiles.conf.in and is
then installed into /lib/systemd/system/ together with the systemd-service
unit file. Afterwards Makefile.am installs misc/tmpfiles.conf as
opencryptoki.conf into /usr/lib/tmpfiles.d/ and attempts to remove the
unnecessary copy from /lib/systemd/system/.

This is error prone, since there could have already been a file called
tmpfiles.conf (owned by another package) in /lib/systemd/system/ which
was now overwritten.

Use tmpfiles_DATA and tmpfilesdir in misc.mk instead to install it into
the right place right away, without possibly tampering any existing
files in /lib/systemd/system/.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
2022-10-21 11:15:27 +02:00
Ingo Franzki
43915e824f Remove superfluous/unused files from misc directory
These files are not used, have not been maintained for a long time,
and thus are superfluous.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
2022-10-19 13:27:33 +02:00
Ingo Franzki
08eaca0238 Change /var/run to /run/opencryptoki for pid file and sockets
The usage of /var/run is deprecated. Also introduce a sub-directory under /run
because we have more than one run-time file.

Change was suggested by Mark Post in https://github.com/opencryptoki/opencryptoki/pull/403

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
2022-01-24 12:50:02 +01:00
Patrick Steuer
4ab1354547 Correct soft token model name everywhere
Fixup for 5d3d1e0.

Signed-off-by: Patrick Steuer <patrick.steuer@de.ibm.com>
2020-10-08 13:04:02 +02:00
Ingo Franzki
fa2889928e COMMON: Add defines for CMAC mechanisms
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
2019-09-20 12:06:02 +02:00
Patrick Steuer
2b36533cb8 Expand %C% and %D% in makefiles
Old autotools dont know %C% and %D%.

Signed-off-by: Patrick Steuer <patrick.steuer@de.ibm.com>
2018-11-06 17:22:29 +01:00
Patrick Steuer
e6d7071e89 Autotools rework: get rid of recursive make
Signed-off-by: Patrick Steuer <patrick.steuer@de.ibm.com>
2018-10-08 10:48:42 +02:00
Ingo Franzki
ad3c195ccd Update ec testcase to test ECDSA_SHA224 mechanism
The ec testcase (ec_func.c) will now also test
mechanism CKM_ECDSA_SHA224.

Signed-off-by: Ingo Franzki <ifranzki@linux.vnet.ibm.com>
2018-01-31 10:20:07 -02:00
Eduardo Barretto
5e14f30973 Remove tmpfiles.conf from install and fix doc names
During install the tmpfiles.conf is copied together with pkcsslotd.service into
the usr/lib/systemd/system/. But we already have tmpfiles.conf as
opencryptoki.conf in the correct folder usr/lib/tmpfiles.d/. So we can remove
it.
Also fixed some documents name in spec file.

Signed-off-by: Eduardo Barretto <ebarretto@linux.vnet.ibm.com>
2017-11-03 18:29:58 -02:00
Eduardo Barretto
6ffee250c3 Remove some pkcs11_startup leftovers
The old (previous version 3) pkcs11_startup configuration script was still being
called and mentioned in some of the code. Removed it to fix.
There is still mentioning of pkcs11_startup in some documents, those should be
maintained.

Signed-off-by: Eduardo Barretto <ebarretto@linux.vnet.ibm.com>
2017-11-03 18:29:58 -02:00
Paulo Vital
8d78def16c Make sure the creation of tmpfiles.d
Add rule in Makefile to create the /usr/lib/tmpfiles.d directory
during the installation step.

Signed-off-by: Paulo Vital <pvital@linux.vnet.ibm.com>
2017-10-31 14:36:54 -02:00
Mark Post
d8fe99ffca Update pkcsslotd.service.in
Update pkcsslotd.service.in to use After=local-fs.target instead of syslog.target. The syslog target doesn't exist any more.

Signed-off-by: Mark Post <mpost@suse.com>
2017-07-27 11:29:07 -03:00
Paulo Vital
cab6bce3d7 Add support to systemd-tmpfiles config file.
Add support to create configuration file for creation, deletion and cleaning
of volatile and temporary files in systemd.

The tmpfiles.d/opencryptoki.conf file will be created automatically during
compilation time based on enabled tokens in configure. The output will be
installed in default systemd-tmpfiles path structure, described here [1].

[1] https://www.freedesktop.org/software/systemd/man/tmpfiles.d.html

This patch fixes #25

Signed-off-by: Paulo Vital <pvital@linux.vnet.ibm.com>
2017-07-25 17:39:35 -03:00
Ingo Franzki
d509a33528 ep11 token, cca token: Add ECDSA SHA2 support
Slightly adapted version of Ingo's patch:
Patch hunks needed relocation because of previous commits
in some files. Removed some trailing whitespaces.
Tested, works.

Signed-off-by: Ingo Franzki <ifranzki@de.ibm.com>
Signed-off-by: Harald Freudenberger <freude@linux.vnet.ibm.com>
2017-04-05 13:33:48 -03:00
Paulo Vital
54eb5f946a Add CPL-1.0 license header to source code files.
Add the license header in those source code files are missing it.

Signed-off-by: Paulo Vital <pvital@linux.vnet.ibm.com>
2017-03-15 16:37:46 -03:00
Paulo Vital
d0874c2fc1 Update license header of source code files to CPL-1.0
Signed-off-by: Paulo Vital <pvital@linux.vnet.ibm.com>
2017-03-15 16:37:46 -03:00
Paulo Vital
869ba187ba Add CPL-1.0 license header into Shell Script files.
Signed-off-by: Paulo Vital <pvital@linux.vnet.ibm.com>
2017-03-15 16:24:55 -03:00
Dan Horák
9c8ab7b0c7 Update unit file for 3.0.
Signed-off-by: Dan Horák <dan@danny.cz>
2013-09-04 15:58:02 -05:00
Marcelo Cerri
c1b5927ba1 Task8: remove unused file c_defs.h
Remove c_defs.h and update some comments.

Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
2013-05-20 21:24:03 +02:00
Joy Latten
788a1bb0e0 Add support for systemd
Signed-off-by: Dan Horák <dan@danny.cz>
Signed-off-by: Joy Latten <jmlatten@users.sourceforge.net>
2012-04-12 17:24:34 -05:00
Fionnuala Gunter
51497ba85b Refactored RSA testcases. RSA testcases now include published
test vectors.

Signed-off-by: Fionnuala Gunter <fin@linux.vnet.ibm.com>
2011-08-26 17:15:09 -05:00
Joy Latten
3ae4839504 Add gdb command to dump ECC key token generated by CCA
Signed-off-by: Ashley Lai <adlai@us.ibm.com>
2011-05-11 13:47:54 -05:00
Joy Latten
0fbb73ef94 Add a gdb command script with helpful commands for debugging
opencryptoki. Useful commands are prefixed with "ock_" to make easier
to callup. Internal functions are prefixed with "__ock_".
i.e. ock_dump_obj_template <OBJECT *>
     - dumps and object's template

Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2011-05-03 11:06:22 -05:00
Dan Horák
5532243e95 don't set TERM signal explicitely when calling killproc
The TERM signal is sent by default when the killproc function is called.
Also the pid file created by the pkcsslotd executable is removed by the
initscript (resp. by the killproc function) only when no signal is set.
Other solution how to remove the pid file is to remove it directly by the
executable.

Signed-off-by: Dan Horák <dan@danny.cz>
2010-05-04 13:33:07 -03:00
Dan Horák
f49465135c sync pidfile path between pkcsslotd initscript and executable
pkcsslotd executable creates a pidfile as /var/lib/opencryptoki/.slotpid
(CONFIG_PATH + "/.slotpid"), but the corresponding initscipt expects the
pidfile at /var/run/pkcsslotd.pid and this one is used to check whether
the service is running etc. The attached patch switches pkcsslotd to using
the /var/run/pkcsslotd.pid one and also simplifies the logic in the initscript
because the daemon function takes care of the checked cases.

Signed-off-by: Dan Horák <dan@danny.cz>
2010-05-04 13:32:32 -03:00
Dan Horák
14582a5292 add force-reload action to pkcsslotd initscript
force-reload action is added to the pkcsslotd initscript and also
it's documented in usage message together with reload action

Signed-off-by: Dan Horák <dan@danny.cz>
2010-05-04 13:31:49 -03:00
Klaus Heinrich Kiwi
789d86ee16 Merge branch 'master' into opencryptoki-next
* master:
  Fixed the pkcsslotd init script to make it return codes according to LSB specification.
  Version update.
  Fix wrong log message for "API already initialized" condition
  Check for vendor-defined object classes
  Fix public exponent attribute endianness bug
  AES support included into the CCA token.
  Makes pkcscca_migrate tool link dynamically to libcsulcca.so by using dlopen() instead.

Conflicts:
	configure.in - took version number from master ("2.3.1")

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-05-04 10:51:38 -03:00
Rajiv Andrade
54a2a77172 Fixed the pkcsslotd init script to make it return codes according to LSB specification.
Signed-off-by: Dan Horák <dhorak@redhat.com>
2010-04-15 16:56:07 -03:00
Klaus Heinrich Kiwi
e1956cf493 configure.in: complete refactor.
Unfortunately I couldn't split this patch in a sane way, because
essentially we're rewriting configure.in here.

In summary, the main changes are:

 * Use AC_ARG_ENABLE() only to enable/disable building certain parts
   of the code
 * Use AC_ARG_WITH() only to specify libraries that may be needed by
   certain portions of the code
 * All AC_ARG_ENABLE() macros comes with architecture-independent
   defaults. This means that we won't be trying to guess what
   features (tokens) we should or should not be building.
 * All AC_ARG_WITH() macros have 'check' as the default (check for
   that library in the default search path)
 * IMPORTANT: Separate pkcscca_migrate from cca token build, as only
   the former requires the CCA libraries to link.
 * No more dependencies of what stdll can be built based on arch.
   Theoretically all stdll can be built on all archs, given that
   it has the relevant libraries also (we know this is not always
   true, so sometimes the user needs to explicitly disable a token
   with --without-FEATURE to build on certain archs)
 * The (special case of) ica stdll: builds ica_s390_stdll on s390
   archs while using ica_stdll on any other arch.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-01-12 16:09:31 -02:00
Klaus Heinrich Kiwi
f8d47a6870 Process pkcsslotd.in at build time instead of configure time
This patch moves the processing of misc/pkcsslotd.in to use
a sed script at build time instead of relying on configure
to process it at configure time. This allows us to be more
flexible when building to non-standard directories or other
odd scenarios. Also fixed to use standard directory variables.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-01-12 08:03:28 -02:00
Klaus Heinrich Kiwi
b61e8ba70c Move loader configuration from misc dir to usr/lib dir
This is certainly more of a cosmetic change than anything
else, moving the install script that includes our library
directories in ld.so.conf from misc/Makefile.am to
usr/lib/Makefile.am, but it also brings some fixes such
as use -hook target instead of -local (make sure that
this is run *after* everything else on this dir) and
use standard pathnames variables.

Signed-off-by: Klaus Heinrich Kiwi <klausk@linux.vnet.ibm.com>
2010-01-12 07:50:00 -02:00
danielhjones
d089058f00 These modifications represent a significant change in the way opencryptoki
gets built and RPMs are created. Whereas before all possible tokens
were created by default, now only a default token is created implicitly. On
s390 systems, the default is the ica_390 token. On other platforms, the
default is the software token. Separate token RPMs may be created. A sample
spec file is provided for the a tpm token package. A package may also be
created containing just the libopencryptoki shared object. This will enable
a 32 bit libopencryptoki package to be created for 64 bit platforms in order
to maintain compatibility with previous releases.
2006-08-14 18:30:00 +00:00
danielhjones
181f75f958 Added pkcsslotd init script 2006-07-25 13:51:23 +00:00
danielhjones
70ca2d4143 Mainly a cleanup of configure.in to remove target specific conditionals and
use $libdir instead. Replaced the openCryptoki.spec file with opencryptoki.spec
and cleaned it up.
2006-07-13 15:41:57 +00:00
danielhjones
25feaa2bc1 Changes made to enable 64bit daemon/tools on 64bit platforms. Some
structures padded due to alignment variations between x86_64 64bit
and 32 bit (i386) binaries.
Full path removed from pk_config_data file. Library paths added to
ld.so.conf.d files for library location.
2006-04-17 18:23:06 +00:00
mhalcrow
dc61998b7b Flesh out the migration script 2006-01-12 15:46:45 +00:00
mhalcrow
93b2ae299d Beginnings of a script to migrate a machine from version 2.1 to 2.2. 2006-01-12 15:26:20 +00:00
mhalcrow
6cdba6b96e Test executable demonstrating how openCryptoki might use the generate_pkcs11_mech_list call. 2005-08-05 15:48:59 +00:00
mhalcrow
c41a7fc624 Example header declarations and functions for converting library-specific mechanism descriptors into an openCryptoki mechanism list. 2005-08-05 15:31:03 +00:00