1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466
|
certsdir=$(srcdir)/certs
USER_KEYS = \
$(certsdir)/user-key-pkcs1.pem $(certsdir)/user-key-pkcs1.der \
$(certsdir)/user-key-pkcs1-aes128.pem \
$(certsdir)/user-key-pkcs8.pem $(certsdir)/user-key-pkcs8.der \
$(certsdir)/user-key-pkcs8-pbes1-sha1-3des.pem $(certsdir)/user-key-pkcs8-pbes1-sha1-3des.der \
$(certsdir)/user-key-pkcs8-pbes2-sha1.pem $(certsdir)/user-key-pkcs8-pbes2-sha1.der \
$(certsdir)/user-key-sha1-3des-sha1.p12 $(certsdir)/user-key-sha1-3des-sha256.p12 \
$(certsdir)/user-key-aes256-cbc-sha256.p12
# We know GnuTLS doesn't support these for now. https://bugzilla.redhat.com/1369484
OSSL_KEYS = \
$(certsdir)/user-key-md5-des-sha1.p12 $(certsdir)/user-key-aes256-cbc-md5-des-sha256.p12 \
$(certsdir)/user-key-pkcs8-pbes2-sha256.pem $(certsdir)/user-key-pkcs8-pbes2-sha256.der \
$(certsdir)/user-key-pkcs8-pbes1-md5-des.pem $(certsdir)/user-key-pkcs8-pbes1-md5-des.der
if OPENCONNECT_OPENSSL
USER_KEYS += $(OSSL_KEYS)
endif
DSA_KEYS = \
$(certsdir)/dsa-key-pkcs1.pem $(certsdir)/dsa-key-pkcs1.der \
$(certsdir)/dsa-key-pkcs1-aes128.pem \
$(certsdir)/dsa-key-pkcs8.pem $(certsdir)/dsa-key-pkcs8.der \
$(certsdir)/dsa-key-pkcs8-pbes2-sha1.pem $(certsdir)/dsa-key-pkcs8-pbes2-sha1.der \
$(certsdir)/dsa-key-aes256-cbc-sha256.p12
if TEST_DSA
USER_KEYS += $(DSA_KEYS)
endif
USER_KEYS += $(certsdir)/ec-key-pkcs1.pem $(certsdir)/ec-key-pkcs1.der \
$(certsdir)/ec-key-pkcs1-aes128.pem \
$(certsdir)/ec-key-pkcs8.pem $(certsdir)/ec-key-pkcs8.der \
$(certsdir)/ec-key-pkcs8-pbes2-sha1.pem $(certsdir)/ec-key-pkcs8-pbes2-sha1.der \
$(certsdir)/ec-key-aes256-cbc-sha256.p12
SWTPM_KEYS = $(certsdir)/ec-key-swtpm.pem $(certsdir)/swtpm-rsa-key-tpm.pem \
$(certsdir)/swtpm-ec-key-tpm.pem $(certsdir)/swtpm-ec-p384-key-tpm.pem
SWTPM_CERTS = $(certsdir)/swtpm-ec-cert.pem $(certsdir)/swtpm-rsa-cert.pem \
$(certsdir)/swtpm-ec-p384-cert.pem
HWTPM_KEYS =
HWTPM_CERTS =
# Importing the existing EC key (not DSA since it's ancient and not RSA because
# the TPM probably can't cope with 2432-bit keys).
if TEST_TPM2_IMPORT
HWTPM_KEYS += ec-key-hwtpm.pem
endif
# Creating new keys in TPM.
if TEST_TPM2_CREATE
HWTPM_KEYS += hwtpm-ec-key-tpm.pem hwtpm-rsa-key-tpm.pem
HWTPM_CERTS += hwtpm-ec-cert.pem hwtpm-rsa-cert.pem
endif
USER_CERTS = $(certsdir)/user-cert.pem $(certsdir)/dsa-cert.pem $(certsdir)/ec-cert.pem
EXTRA_DIST = certs/ca.pem certs/ca-key.pem certs/user-cert.pem $(USER_KEYS) $(USER_CERTS) \
$(OSSL_KEYS) $(DSA_KEYS) $(certsdir)/user-key-nonascii-password.p12 \
pass-UTF-8 pass-ISO8859-2 $(SWTPM_KEYS) $(SWTPM_CERTS) swtpm-perm.state \
certs/server-cert.pem certs/server-key.pem configs/test1.passwd \
common.sh configs/test-user-cert.config.in \
configs/test-user-pass.config.in \
configs/test-obsolete-server-crypto.config \
configs/user-cert.prm configs/server-cert.prm \
softhsm2.conf.in softhsm ns.sh configs/test-dtls-psk.config \
scripts/vpnc-script scripts/vpnc-script-detect-disconnect \
suppressions.lsan fake-fortinet-server.py fake-f5-server.py fake-juniper-server.py \
fake-juniper-sso-server.py fake-tncc.py fake-gp-server.py fake-cisco-server.py
dist_check_SCRIPTS = autocompletion symbols
TESTS = autocompletion symbols
dist_check_SCRIPTS += dtls-psk sigterm
if HAVE_NETNS
TESTS += dtls-psk sigterm
endif
dist_check_SCRIPTS += ppp-over-tls ppp-over-tls-sync
if TEST_PPP
TESTS += ppp-over-tls ppp-over-tls-sync
endif
dist_check_SCRIPTS += auth-username-pass auth-certificate auth-nonascii cert-fingerprint \
id-test obsolete-server-crypto pfs auth-swtpm auth-hwtpm fortinet-auth-and-config \
f5-auth-and-config juniper-auth juniper-sso-auth gp-auth-and-config auth-pkcs11 \
auth-multicert
if HAVE_CWRAP
TESTS += auth-username-pass auth-certificate auth-nonascii cert-fingerprint id-test \
obsolete-server-crypto pfs
if TEST_SWTPM
TESTS += auth-swtpm
# The rules for swtpm-perm.state are not invoked during normal builds since
# the files are already present in git.
auth-swtpm: swtpm-perm.state
endif
if TEST_HWTPM
# This is only invoked *manually* with 'make TESTS=auth-hwtpm check'.
TESTS += auth-hwtpm
# These files are generated locally against the real TPM.
auth-hwtpm: $(HWTPM_CERTS) $(HWTPM_KEYS)
endif
if HAVE_PYTHON36_FLASK
TESTS += juniper-sso-auth auth-multicert
if HAVE_PYTHON37_DATACLASSES
TESTS += juniper-auth gp-auth-and-config f5-auth-and-config fortinet-auth-and-config
endif
endif
if TEST_PKCS11
TESTS += auth-pkcs11
PKCS11_TOKENS = openconnect-test openconnect-test1
PKCS11_KEYS = object=RSA id=%01
# Neither GnuTLS or libp11 support this
#PKCS11_KEYS += object=DSA id=%02
PKCS11_KEYS += object=EC id=%03
if OPENCONNECT_GNUTLS
# We fail test2 because PKCS11_enumerate_certs() still doesn't seem to return
# the certs after we log in. Perhaps it's cached the results?
PKCS11_TOKENS += openconnect-test2
endif # OPENCONNECT_GNUTLS
if OPENCONNECT_OPENSSL
# GnuTLS build fails this one: https://gitlab.com/gnutls/gnutls/-/issues/977
PKCS11_TOKENS += openconnect-test3
endif # OPENCONNECT_OPENSSL
endif # TEST_PKCS11
endif # HAVE_CWRAP
TESTS_ENVIRONMENT = srcdir="$(srcdir)" \
top_srcdir="$(top_srcdir)" \
top_builddir="$(top_builddir)" \
key_list="$(USER_KEYS)" \
swtpm_list="$(SWTPM_KEYS)" \
hwtpm_list="$(HWTPM_KEYS)" \
SWTPM="$(SWTPM)" \
SWTPM_IOCTL="$(SWTPM_IOCTL)" \
pkcs11_keys="$(PKCS11_KEYS)" \
pkcs11_tokens="$(PKCS11_TOKENS)" \
EXEEXT=$(EXEEXT) \
LSAN_OPTIONS=$(srcdir)/suppressions=suppressions.lsan
C_TESTS = lzstest seqtest buftest
if OPENCONNECT_WIN32
C_TESTS += list-taps
endif
if CHECK_DTLS
C_TESTS += bad_dtls_test
bad_dtls_test_SOURCES = bad_dtls_test.c
bad_dtls_test_CFLAGS = $(OPENSSL_CFLAGS)
bad_dtls_test_LDADD = $(OPENSSL_LIBS)
if DTLS_XFAIL
XFAIL_TESTS = bad_dtls_test
endif
endif
TESTS += $(C_TESTS)
noinst_PROGRAMS = $(C_TESTS) serverhash
serverhash_SOURCES = serverhash.c
serverhash_LDADD = ../libopenconnect.la $(SSL_LIBS)
# Nothing actually *depends* on the cert files; they are created manually
# and considered part of the sources, committed to the git tree. But for
# reference, the commands used to generate them are here...
keyfiles: $(USER_KEYS) $(USER_CERTS) $(certsdir)/server-cert.pem
OPENSSL = openssl
OSSLARGS = -in $(firstword $|) -out $@ -passout pass:password
OSSLARGSP12 = -inkey $(firstword $|) -out $@ -in $${KEYFILE%-key-pkcs8.pem}-cert.pem -passout pass:$${PASSWORD:-password}
# Strictly speaking this is only PKCS#1 for RSA. For EC it's probably
# best described as RFC5915§4, and no idea what defines it for DSA.
$(certsdir)/user-key-pkcs1.pem:
$(OPENSSL) genrsa -out $@ 2432
$(certsdir)/dsa-key-pkcs1.pem:
$(OPENSSL) dsaparam -genkey 1024 -out $@
$(certsdir)/ec-key-pkcs1.pem:
$(OPENSSL) ecparam -genkey -out $@ -name prime256v1
# Even in OpenSSL 1.1, this creates the old encrypted PEM format.
$(certsdir)/user-key-pkcs1-aes128.pem: | certs/user-key-pkcs1.pem
$(OPENSSL) rsa $(OSSLARGS) -aes128
$(certsdir)/dsa-key-pkcs1-aes128.pem: | certs/dsa-key-pkcs1.pem
$(OPENSSL) dsa $(OSSLARGS) -aes128
$(certsdir)/ec-key-pkcs1-aes128.pem: | certs/ec-key-pkcs1.pem
$(OPENSSL) ec $(OSSLARGS) -aes128
# Plain unencrypted PKCS#8
%-key-pkcs8.pem: | %-key-pkcs1.pem
$(OPENSSL) pkcs8 $(OSSLARGS) -topk8 -nocrypt
%-key-pkcs8-pbes1-sha1-3des.pem: | %-key-pkcs8.pem
$(OPENSSL) pkcs8 $(OSSLARGS) -topk8 -v1 pbeWithSHA1And3-KeyTripleDES-CBC
# This is the default created by OpenSSL 1.0.2 with -topk8
%-key-pkcs8-pbes1-md5-des.pem: | %-key-pkcs8.pem
$(OPENSSL) pkcs8 $(OSSLARGS) -topk8 -v1 pbeWithMD5AndDES-CBC
%-key-pkcs8-pbes2-sha1.pem: | %-key-pkcs8.pem
$(OPENSSL) pkcs8 $(OSSLARGS) -topk8 -v2 aes256 -v2prf hmacWithSHA1
# This is the default created by OpenSSL 1.1 with -topk8
%-key-pkcs8-pbes2-sha256.pem: | %-key-pkcs8.pem
$(OPENSSL) pkcs8 $(OSSLARGS) -topk8 -v2 aes256 -v2prf hmacWithSHA256
%-key-sha1-3des-sha1.p12: | %-key-pkcs8.pem %-cert.pem
KEYFILE="$(firstword $|)"; $(OPENSSL) pkcs12 $(OSSLARGSP12) -export -macalg SHA1 \
-certpbe pbeWithSHA1And3-KeyTripleDES-CBC -keypbe pbeWithSHA1And3-KeyTripleDES-CBC
%-key-sha1-3des-sha256.p12: | %-key-pkcs8.pem %-cert.pem
KEYFILE="$(firstword $|)"; $(OPENSSL) pkcs12 $(OSSLARGSP12) -export -macalg SHA256 \
-certpbe pbeWithSHA1And3-KeyTripleDES-CBC -keypbe pbeWithSHA1And3-KeyTripleDES-CBC
%-key-md5-des-sha1.p12: | %-key-pkcs8.pem %-cert.pem
KEYFILE="$(firstword $|)"; $(OPENSSL) pkcs12 $(OSSLARGSP12) -export -macalg SHA1 \
-certpbe pbeWithMD5AndDES-CBC -keypbe pbeWithMD5AndDES-CBC
%-key-aes256-cbc-sha256.p12: | %-key-pkcs8.pem %-cert.pem
KEYFILE="$(firstword $|)"; $(OPENSSL) pkcs12 $(OSSLARGSP12) -export -macalg SHA256 \
-certpbe AES-256-CBC -keypbe AES-256-CBC
# NB: Needs OpenSSL 1.1 or newer
%-key-nonascii-password.p12: | %-key-pkcs8.pem %-cert.pem
LC_ALL=en_GB.UTF-8 PASSWORD="$$(cat $(srcdir)/pass-UTF-8)" KEYFILE="$(firstword $|)" ; \
$(OPENSSL) pkcs12 $(OSSLARGSP12) -export -macalg SHA256 \
-certpbe AES-256-CBC -keypbe AES-256-CBC
# This one makes GnuTLS behave strangely...
%-key-aes256-cbc-md5-des-sha256.p12: | %-key-pkcs8.pem %-cert.pem
KEYFILE="$(firstword $|)"; $(OPENSSL) pkcs12 $(OSSLARGSP12) -export -macalg SHA256 \
-certpbe AES-256-CBC -keypbe pbeWithMD5AndDES-CBC
%.der: | %.pem
sed -e '0,/^-----BEGIN.*KEY-----/d' -e '/^-----END.*KEY-----/,$$d' $| | base64 -d > $@
$(certsdir)/server-cert.pem:
$(OPENSSL) req -new -config $(srcdir)/configs/server-cert.prm -key $(certsdir)/server-key.pem -out $@.csr
$(OPENSSL) x509 -days 10000 -CA $(certsdir)/ca.pem -CAkey $(certsdir)/ca-key.pem \
-extfile $(srcdir)/configs/server-cert.prm -extensions req_EXT \
-set_serial $(shell date +%s) -req -out $@ -in $@.csr
$(certsdir)/ca.pem: | $(certsdir)/ca-key.pem
openssl req -new -x509 -days 10000 -key $| -out $@ -config $(srcdir)/configs/ca.prm -extensions x509v3 -set_serial 1
# Like most of the rules to generate keys/certs, the swtpm rules are
# dormant for most builds; they were used once to generate the state
# which is committed to git and used thereafter (just like the cert
# files and the SoftHSM state). The rules here are to ensure that
# what gets committed was reproducible, and to document how it was
# created. So for swtpm, we need to:
#
# • Start a new swtpm
# • Import/create the keys
# • Generate CSRs from the created keys
# • Extract the swtpm state to 'swtpm-perm.state'
# • Shut down the swtpm
#
# These rules attempt to do that, keeping variants of the existing
# CSR/cert generation rules for the middle parts.
SWTPM_TMPDIR := $(shell echo swtpm.$$$$.tmp)
SWTPM_PRELOAD := LD_PRELOAD=libsocket_wrapper.so SOCKET_WRAPPER_DIR=$(SWTPM_TMPDIR) \
TPM_INTERFACE_TYPE=socsim TPM2TSSENGINE_TCTI=swtpm
SWTPM_IOCTL_RUN = $(SWTPM_PRELOAD) $(SWTPM_IOCTL) --tcp 127.0.0.1:2322
# This isn't safe for parallel builds, as it is invoked in mulltiple
# places and has an obvious race condition. However, this is only for
# the one-time setup of the persistent swtpm state, and I can remember
# not to use 'make -j' that one time. Fixing it to be a proper
# separate 'tpm-started' phony rule without *always* having that rule
# executed even when the certs/keys already exist is beyond me today.
START_SWTPM := \
mkdir -p $(SWTPM_TMPDIR); \
if ! $(SWTPM_IOCTL_RUN) -g; then \
if [ -r $(srcdir)/swtpm-perm.state ]; then \
$(SWTPM_PRELOAD) $(SWTPM) socket --tpm2 \
--server type=tcp,port=2321 --ctrl type=tcp,port=2322 \
--tpmstate dir=`pwd`/$(SWTPM_TMPDIR) -d; \
sleep 0.5; \
$(SWTPM_IOCTL_RUN) --load permanent $(srcdir)/swtpm-perm.state; \
$(SWTPM_IOCTL_RUN) -i; \
$(SWTPM_IOCTL_RUN) -s; \
fi; \
$(SWTPM_PRELOAD) $(SWTPM) socket --tpm2 --server type=tcp,port=2321 --ctrl type=tcp,port=2322 \
--tpmstate dir=`pwd`/$(SWTPM_TMPDIR) --flags not-need-init,startup-clear -d; \
fi
swtpm-perm.state: | $(SWTPM_KEYS) $(SWTPM_CERTS)
$(SWTPM_IOCTL_RUN) --save permanent $@
$(SWTPM_IOCTL_RUN) -s
rm -rf $(SWTPM_TMPDIR)
# This is an *import* of the normal ec key, hence having same prefix 'ec-'.
# Separate fileames for swtpm (which is shipped with OpenConnect sources)
# vs local real TPM. Like many of the key/cert rules here, the swtpm rule
# is dormant and should never really be invoked for normal users once the
# files are committed to git. Which is why it doesn't matter that it needs
# the swtpm to have been started manually.
$(certsdir)/ec-key-swtpm.pem: | certs/ec-key-pkcs8.pem
$(START_SWTPM)
$(SWTPM_PRELOAD) $(CREATE_TPM2_KEY) -w $| $@
ec-key-hwtpm.pem: | certs/ec-key-pkcs8.pem
TPM_INTERFACE_TYPE=dev $(CREATE_TPM2_KEY) -w $| $@
# These are *different* keys generated inside the TPM, hence a different prefix.
$(certsdir)/swtpm-ec-key-tpm.pem:
$(START_SWTPM)
$(SWTPM_PRELOAD) $(TPM2TSS_GENKEY) -t swtpm -a ecdsa $@
$(certsdir)/swtpm-ec-p384-key-tpm.pem:
$(START_SWTPM)
$(SWTPM_PRELOAD) $(TPM2TSS_GENKEY) -t swtpm -c nist_p384 -a ecdsa $@
hwtpm-ec-key-tpm.pem:
$(TPM2TSS_GENKEY) -t device -a ecdsa $@
$(certsdir)/swtpm-rsa-key-tpm.pem:
$(START_SWTPM)
$(SWTPM_PRELOAD) $(TPM2TSS_GENKEY) -t swtpm -a rsa -s 2048 $@
hwtpm-rsa-key-tpm.pem:
$(TPM2TSS_GENKEY) -t device -a rsa -s 2048 $@
$(certsdir)/swtpm-%-cert.csr: | $(certsdir)/swtpm-%-key-tpm.pem
$(START_SWTPM)
$(SWTPM_PRELOAD) $(OPENSSL) req -new -config $(srcdir)/configs/user-cert.prm -engine tpm2tss -keyform ENGINE -key $| -out $@
hwtpm-%-cert.csr: | hwtpm-%-key-tpm.pem
TPM2TSSENGINE_TCTI=device $(OPENSSL) req -new -config $(srcdir)/configs/user-cert.prm -engine tpm2tss -keyform ENGINE -key $| -out $@
%-cert.csr: | %-key-hwtpm.pem
TPM2TSSENGINE_TCTI=device $(OPENSSL) req -new -config $(srcdir)/configs/user-cert.prm -engine tpm2tss -keyform ENGINE -key $| -out $@
%-cert.csr: | %-key-pkcs8.pem
$(OPENSSL) req -new -config $(srcdir)/configs/user-cert.prm -key $| -out $@
%.pem: | %.csr
$(OPENSSL) x509 -days 10000 -CA $(certsdir)/ca.pem -CAkey $(certsdir)/ca-key.pem \
-set_serial $(shell date +%s) -req -out $@ -in $|
SHM2_UTIL=SOFTHSM2_CONF=softhsm2.conf softhsm2-util
P11TOOL=SOFTHSM2_CONF=softhsm2.conf p11tool
# Nice and simple: Certs visible without login, public keys present in token
softhsm-setup0:
$(SHM2_UTIL) --show-slots
$(SHM2_UTIL) --init-token --free --label openconnect-test \
--so-pin 12345678 --pin 1234
$(SHM2_UTIL) --token openconnect-test --pin 1234 --import $(certsdir)/user-key-pkcs8.pem \
--label RSA --id 01
$(P11TOOL) --load-certificate $(certsdir)/user-cert.pem --no-mark-private \
--label RSA --id 01 --set-pin 1234 --login \
--write "pkcs11:token=openconnect-test;pin-value=1234"
$(SHM2_UTIL) --token openconnect-test --pin 1234 --import $(certsdir)/dsa-key-pkcs8.pem \
--label DSA --id 02
$(P11TOOL) --load-certificate $(certsdir)/dsa-cert.pem --no-mark-private \
--label DSA --id 02 --set-pin 1234 --login \
--write "pkcs11:token=openconnect-test;pin-value=1234"
$(SHM2_UTIL) --token openconnect-test --pin 1234 --import $(certsdir)/ec-key-pkcs8.pem \
--label EC --id 03
$(P11TOOL) --load-certificate $(certsdir)/ec-cert.pem --no-mark-private \
--label EC --id 03 --set-pin 1234 --login \
--write "pkcs11:token=openconnect-test;pin-value=1234"
# Second test: Import keys with GnuTLS so public key is absent
softhsm-setup1:
$(SHM2_UTIL) --show-slots
$(SHM2_UTIL) --init-token --free --label openconnect-test1 \
--so-pin 12345678 --pin 1234
$(P11TOOL) --load-certificate $(certsdir)/user-cert.pem --no-mark-private \
--load-privkey $(certsdir)/user-key-pkcs8.pem \
--label RSA --id 01 --login \
--write "pkcs11:token=openconnect-test1;pin-value=1234"
$(P11TOOL) --load-certificate $(certsdir)/dsa-cert.pem --no-mark-private \
--load-privkey $(certsdir)/dsa-key-pkcs8.pem \
--label DSA --id 02 --login \
--write "pkcs11:token=openconnect-test1;pin-value=1234"
$(P11TOOL) --load-certificate $(certsdir)/ec-cert.pem --no-mark-private \
--load-privkey $(certsdir)/ec-key-pkcs8.pem \
--label EC --id 03 --login \
--write "pkcs11:token=openconnect-test1;pin-value=1234"
# Third test: CKA_PRIVATE on certificates
softhsm-setup2:
$(SHM2_UTIL) --show-slots
$(SHM2_UTIL) --init-token --free --label openconnect-test2 \
--so-pin 12345678 --pin 1234
$(P11TOOL) --load-certificate $(certsdir)/user-cert.pem \
--load-privkey $(certsdir)/user-key-pkcs8.pem \
--label RSA --id 01 --login \
--write "pkcs11:token=openconnect-test2;pin-value=1234"
$(P11TOOL) --load-certificate $(certsdir)/dsa-cert.pem \
--load-privkey $(certsdir)/dsa-key-pkcs8.pem \
--label DSA --id 02 --login \
--write "pkcs11:token=openconnect-test2;pin-value=1234"
$(P11TOOL) --load-certificate $(certsdir)/ec-cert.pem \
--load-privkey $(certsdir)/ec-key-pkcs8.pem \
--label EC --id 03 --login \
--write "pkcs11:token=openconnect-test2;pin-value=1234"
# Fourth test: token lacks CKF_LOGIN_REQUIRED (#123)
softhsm-setup3:
$(SHM2_UTIL) --show-slots
$(SHM2_UTIL) --init-token --free --label openconnect-test3 \
--so-pin 12345678 --pin 1234
# Remove the CKF_LOGIN_REQUIRED flag
TOKOBJ=$$(grep -l openconnect-test3 $(srcdir)/softhsm/*/token.object); \
if [ -n "$$TOKOBJ" ] && od -t x1 $$TOKOBJ | grep -q '^0000160.* 04 2d$$'; then \
echo -en \\x29 | dd bs=1 count=1 conv=notrunc seek=127 of=$$TOKOBJ; \
else \
echo "Token file not understood"; \
exit 1; \
fi
$(P11TOOL) --load-certificate $(certsdir)/user-cert.pem \
--load-privkey $(certsdir)/user-key-pkcs8.pem \
--label RSA --id 01 --login \
--write "pkcs11:token=openconnect-test3;pin-value=1234"
$(P11TOOL) --load-certificate $(certsdir)/dsa-cert.pem \
--load-privkey $(certsdir)/dsa-key-pkcs8.pem \
--label DSA --id 02 --login \
--write "pkcs11:token=openconnect-test3;pin-value=1234"
$(P11TOOL) --load-certificate $(certsdir)/ec-cert.pem \
--load-privkey $(certsdir)/ec-key-pkcs8.pem \
--label EC --id 03 --login \
--write "pkcs11:token=openconnect-test3;pin-value=1234"
if DISABLE_ASAN_BROKEN_TESTS
TESTS_ENVIRONMENT += DISABLE_ASAN_BROKEN_TESTS=1
else
TESTS_ENVIRONMENT += DISABLE_ASAN_BROKEN_TESTS=0
endif
|