Skip to content

Commit

Permalink
PKCS11: Add support for KDF after ECDH derivation (#388)
Browse files Browse the repository at this point in the history
PKCS11: Add support for ECDH derivation with KDF functions
  • Loading branch information
aveenismail authored Mar 25, 2024
1 parent 9bf4436 commit 5e73b19
Show file tree
Hide file tree
Showing 7 changed files with 711 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ jobs:
ctest --output-on-failure -E engine
elif [ $DOCKER_IMAGE = "centos:7" ]; then
# we skip the ecdh_derive tests (for now) since there is an issue with generating secp224r1 keys
ctest --output-on-failure -E ecdh_derive\|aes
ctest --output-on-failure -E ecdh_derive\|aes\|ecdh_sp800
else
ctest --output-on-failure
fi
Expand Down
6 changes: 6 additions & 0 deletions pkcs11/pkcs11y.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,10 @@
#define CKM_YUBICO_AES_CCM_WRAP \
(CKM_VENDOR_DEFINED | YUBICO_BASE_VENDOR | YH_WRAP_KEY)

// TODO: These values are from PKCS11 3.0 and should be removed when we upgrade
#define CKD_YUBICO_SHA1_KDF_SP800 0x0000000EUL
#define CKD_YUBICO_SHA256_KDF_SP800 0x00000010UL
#define CKD_YUBICO_SHA384_KDF_SP800 0x00000011UL
#define CKD_YUBICO_SHA512_KDF_SP800 0x00000012UL

#endif
17 changes: 17 additions & 0 deletions pkcs11/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ set (
common.c
)

set (
SOURCE_ECDH_SP800
ecdh_sp800_test.c
common.c
)

set (
SOURCE_AES_ENCRYPT
aes_encrypt_test.c
Expand All @@ -224,6 +230,7 @@ set (
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows")
add_executable (aes_encrypt_test ${SOURCE_AES_ENCRYPT})
add_executable (ecdh_derive_test ${SOURCE_ECDH_DERIVE})
add_executable (ecdh_sp800_test ${SOURCE_ECDH_SP800})

target_link_libraries(
aes_encrypt_test
Expand All @@ -240,11 +247,21 @@ target_link_libraries (
${LIBCRYPTO_LDFLAGS}
"-ldl")

target_link_libraries (
ecdh_sp800_test
${LIBCRYPTO_LDFLAGS}
"-ldl")

add_test (
NAME ecdh_derive_test
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/ecdh_derive_test ${CMAKE_CURRENT_BINARY_DIR}/../yubihsm_pkcs11.${LIBEXT}
)

add_test (
NAME ecdh_sp800_test
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/ecdh_sp800_test ${CMAKE_CURRENT_BINARY_DIR}/../yubihsm_pkcs11.${LIBEXT}
)

if (NOT ${LIBCRYPTO_VERSION} VERSION_LESS 1.1)
add_executable (rsa_enc_test ${SOURCE_RSA_ENC_TEST})

Expand Down
Loading

0 comments on commit 5e73b19

Please sign in to comment.