Skip to content

Commit

Permalink
Refactor setup
Browse files Browse the repository at this point in the history
Move only the token specific initialization into custom setup files, and
the use pkcs11-tool and a single script to set up all the keys and
certificates.

Signed-off-by: Simo Sorce <[email protected]>
  • Loading branch information
simo5 committed Aug 26, 2024
1 parent 7d8b369 commit 34616e1
Show file tree
Hide file tree
Showing 9 changed files with 260 additions and 854 deletions.
42 changes: 42 additions & 0 deletions tests/kryoptic-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash -e
# Copyright (C) 2024 Simo Sorce <[email protected]>
# SPDX-License-Identifier: Apache-2.0

title SECTION "Searching for Kryoptic module"

find_kryoptic() {
for _lib in "$@" ; do
if test -f "$_lib" ; then
echo "Using kryoptic path $_lib"
P11LIB="$_lib"
return
fi
done
echo "skipped: Unable to find kryoptic PKCS#11 library"
exit 0
}

find_kryoptic \
"${KRYOPTIC}/target/debug/libkryoptic_pkcs11.so" \
"${KRYOPTIC}/target/release/libkryoptic_pkcs11.so" \
/usr/local/lib/kryoptic/libkryoptic_pkcs11so \
/usr/lib64/pkcs11/libkryoptic_pkcs11.so \
/usr/lib/pkcs11/libkryoptic_pkcs11.so \
/usr/lib/x86_64-linux-gnu/kryoptic/libkryoptic_pkcs11.so

title LINE "Creating Kyroptic database"

# Kryoptic configuration
export KRYOPTIC_CONF="$TOKDIR/kryoptic.sql"

export TOKENLABEL="Kryoptic Token"
export TOKENLABELURI="Kryoptic%20Token"

# init token
pkcs11-tool --module "${P11LIB}" --init-token \
--label "${TOKENLABEL}" --so-pin "${PINVALUE}" 2>&1
# set user pin
pkcs11-tool --module "${P11LIB}" --so-pin "${PINVALUE}" \
--login --login-type so --init-pin --pin "${PINVALUE}" 2>&1

export TOKENCONFIGVARS="export KRYOPTIC_CONF=$TOKDIR/kryoptic.sql"
16 changes: 6 additions & 10 deletions tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,13 @@ if nss_softokn.found()
endif
endif

test_setup = {
'setup_softokn': {'suite': 'softokn', 'exe': find_program('setup-softokn.sh')},
'setup_softhsm': {'suite': 'softhsm', 'exe': find_program('setup-softhsm.sh')},
'setup_kryoptic': {'suite': 'kryoptic', 'exe': find_program('setup-kryoptic.sh')},
}

foreach name, targs : test_setup
setup_script=find_program('setup.sh')
foreach suite : ['softokn', 'softhsm', 'kryoptic']
test(
name,
targs.get('exe'),
suite: targs.get('suite'),
'setup',
setup_script,
args: suite,
suite: suite,
env: conf_env,
is_parallel: false,
)
Expand Down
3 changes: 1 addition & 2 deletions tests/openssl.cnf.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ activate = 1

[pkcs11_sect]
module = @libtoollibs@/pkcs11@SHARED_EXT@
pkcs11-module-init-args = configDir=@testsblddir@/tmp.softokn/tokens
pkcs11-module-token-pin = file:@PINFILE@
##TOKENOPTIONS
#pkcs11-module-encode-provider-uri-to-pem
#pkcs11-module-allow-export
#pkcs11-module-load-behavior
#pkcs11-module-block-operations
##QUIRKS
activate = 1

####################################################################
Expand Down
Loading

0 comments on commit 34616e1

Please sign in to comment.