Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Run TLS tests also when forcing all server operations on token #427

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/keymgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,7 @@ static void *p11prov_ec_gen(void *genctx, OSSL_CALLBACK *cb_fn, void *cb_arg)
#define EC_PRIVKEY_TMPL_SIZE 5
CK_ATTRIBUTE privkey_template[EC_PRIVKEY_TMPL_SIZE + COMMON_TMPL_SIZE] = {
{ CKA_TOKEN, DISCARD_CONST(&val_true), sizeof(CK_BBOOL) },
{ CKA_DERIVE, DISCARD_CONST(&val_true), sizeof(CK_BBOOL) },
{ CKA_PRIVATE, DISCARD_CONST(&val_true), sizeof(CK_BBOOL) },
{ CKA_SENSITIVE, DISCARD_CONST(&val_true), sizeof(CK_BBOOL) },
{ CKA_SIGN, DISCARD_CONST(&val_true), sizeof(CK_BBOOL) },
Expand Down
1 change: 1 addition & 0 deletions tests/openssl.cnf.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pkcs11-module-token-pin = file:@PINFILE@
#pkcs11-module-allow-export
#pkcs11-module-load-behavior
#pkcs11-module-block-operations
#pkcs11-module-cache-keys
##QUIRKS
activate = 1

Expand Down
53 changes: 40 additions & 13 deletions tests/ttls
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ run_test() {
expect {
eof {exit 0;};
default {exit 1;};
}" > "${TMPPDIR}/s_server_output" &
}" 2>&1 | tee "${TMPPDIR}/s_server_output" &
SERVER_PID=$!

read -r < "${TMPPDIR}/s_server_ready"

# The point is to force the server to use the pkcs11-provider for all operations, not the client now
OPENSSL_CONF="${ORIG_OPENSSL_CONF}" \
expect -c "spawn $CHECKER openssl s_client -connect \"localhost:${PORT}\" -CAfile \"${CACRT}\" $CLNT_ARGS;
set timeout 60;
expect {
Expand All @@ -67,22 +69,47 @@ run_test() {
wait_for_server_at_exit $SERVER_PID
}

title PARA "Run sanity test with default values (RSA)"
run_test "$PRIURI" "$CRTURI"
run_tests() {

title PARA "Run sanity test with default values (ECDSA)"
run_test "$ECPRIURI" "$ECCRTURI"
title PARA "Run sanity test with default values (RSA)"
run_test "$PRIURI" "$CRTURI"

title PARA "Run test with TLS 1.2"
run_test "$PRIURI" "$CRTURI" "" "-tls1_2"
title PARA "Run sanity test with default values (ECDSA)"
run_test "$ECPRIURI" "$ECCRTURI"

title PARA "Run test with explicit TLS 1.3"
run_test "$PRIURI" "$CRTURI" "" "-tls1_3"
title PARA "Run test with TLS 1.2"
run_test "$PRIURI" "$CRTURI" "" "-tls1_2"

title PARA "Run test with TLS 1.2 (ECDSA)"
run_test "$ECPRIURI" "$ECCRTURI" "" "-tls1_2"
title PARA "Run test with explicit TLS 1.3"
run_test "$PRIURI" "$CRTURI" "" "-tls1_3"

title PARA "Run test with TLS 1.2 and ECDH"
run_test "$ECPRIURI" "$ECCRTURI" "" "-tls1_2 -cipher ECDHE-ECDSA-AES128-GCM-SHA256 -groups secp256r1"
title PARA "Run test with TLS 1.2 (ECDSA)"
run_test "$ECPRIURI" "$ECCRTURI" "-tls1_2" "-tls1_2"

title PARA "Run test with TLS 1.2 and ECDH"
run_test "$ECPRIURI" "$ECCRTURI" "" "-tls1_2 -cipher ECDHE-ECDSA-AES128-GCM-SHA256 -groups secp256r1"
}

title SECTION "TLS with key in provider"
ORIG_OPENSSL_CONF=${OPENSSL_CONF}
run_tests
title ENDSECTION

title SECTION "Forcing the provider for all server operations"
ORIG_OPENSSL_CONF=${OPENSSL_CONF}
sed \
-e "s/^#pkcs11-module-cache-keys.*$/pkcs11-module-cache-keys = false/" \
-e "s/^#pkcs11-module-block-operations.*$/pkcs11-module-block-operations = digest/" \
-e "s/pkcs11-module-quirks = /pkcs11-module-quirks = no-operation-state /" \
-e "s/^##QUIRKS$/pkcs11-module-quirks = no-operation-state/" \
-e "s/#MORECONF/alg_section = algorithm_sect/" \
"${OPENSSL_CONF}" > "${OPENSSL_CONF}.force"
echo "[algorithm_sect]" >> "${OPENSSL_CONF}.force"
echo "default_properties = ?provider=pkcs11" >> "${OPENSSL_CONF}.force"
OPENSSL_CONF=${OPENSSL_CONF}.force

run_tests
OPENSSL_CONF=${ORIG_OPENSSL_CONF}
title ENDSECTION

exit 0;
Loading