Added infrastructure for hardware tests.
This commit is contained in:
+18
-4
@@ -52,8 +52,6 @@ PKG_PROG_PKG_CONFIG
|
|||||||
|
|
||||||
PKG_CHECK_MODULES(OPENSSL, libcrypto)
|
PKG_CHECK_MODULES(OPENSSL, libcrypto)
|
||||||
|
|
||||||
#PKG_CHECK_MODULES([LIBNSPR], [nspr], [], [])
|
|
||||||
|
|
||||||
gl_LD_VERSION_SCRIPT
|
gl_LD_VERSION_SCRIPT
|
||||||
gl_VALGRIND_TESTS
|
gl_VALGRIND_TESTS
|
||||||
|
|
||||||
@@ -190,10 +188,24 @@ AC_ARG_ENABLE([ykcs11-debug],
|
|||||||
|
|
||||||
AS_IF([test "x$enable_ykcs11_debug" != xno],
|
AS_IF([test "x$enable_ykcs11_debug" != xno],
|
||||||
[AC_DEFINE([YKCS11_DBG], [1], [Regular debug flag])
|
[AC_DEFINE([YKCS11_DBG], [1], [Regular debug flag])
|
||||||
AC_DEFINE([YKCS11_DINOUT], [1], [Function accessed/left debug flag])],
|
AC_DEFINE([YKCS11_DINOUT], [1], [Function accessed/left debug flag])
|
||||||
|
ykcs11_debug="ENABLED"],
|
||||||
[true],
|
[true],
|
||||||
[AC_DEFINE([YKCS11_DBG], [0], [Regular debug flag])
|
[AC_DEFINE([YKCS11_DBG], [0], [Regular debug flag])
|
||||||
AC_DEFINE([YKCS11_DINOUT], [0], [Function accessed/left debug flag])])
|
AC_DEFINE([YKCS11_DINOUT], [0], [Function accessed/left debug flag])
|
||||||
|
ykcs11_debug="DISABLED"])
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([hardware-tests],
|
||||||
|
[AS_HELP_STRING([--enable-hardware-tests],
|
||||||
|
[enables tests that require a YubiKey to be plugged in])],
|
||||||
|
[enable_hardware_tests="$enableval"],
|
||||||
|
[enable_hardware_tests="no"])
|
||||||
|
|
||||||
|
AS_IF([test "x$enable_hardware_tests" != xno],
|
||||||
|
[AC_DEFINE([HW_TESTS], [1], [Flag for hardware tests])
|
||||||
|
hw_tests="ENABLED"],
|
||||||
|
[true],
|
||||||
|
[hw_tests="DISABLED"])
|
||||||
|
|
||||||
AC_SUBST(YKPIV_VERSION_MAJOR, `echo $PACKAGE_VERSION | sed 's/\(.*\)\..*\..*/\1/g'`)
|
AC_SUBST(YKPIV_VERSION_MAJOR, `echo $PACKAGE_VERSION | sed 's/\(.*\)\..*\..*/\1/g'`)
|
||||||
AC_SUBST(YKPIV_VERSION_MINOR, `echo $PACKAGE_VERSION | sed 's/.*\.\(.*\)\..*/\1/g'`)
|
AC_SUBST(YKPIV_VERSION_MINOR, `echo $PACKAGE_VERSION | sed 's/.*\.\(.*\)\..*/\1/g'`)
|
||||||
@@ -238,4 +250,6 @@ AC_MSG_NOTICE([summary of build options:
|
|||||||
Mac PCSC
|
Mac PCSC
|
||||||
LIBS: ${PCSC_MACOSX_LIBS}
|
LIBS: ${PCSC_MACOSX_LIBS}
|
||||||
|
|
||||||
|
YKCS11 debug: ${ykcs11_debug}
|
||||||
|
Hardware tests: ${hw_tests}
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -8,22 +8,29 @@
|
|||||||
#define CRYPTOKI_VERSION_MAJ 2
|
#define CRYPTOKI_VERSION_MAJ 2
|
||||||
#define CRYPTOKI_VERSION_MIN 40
|
#define CRYPTOKI_VERSION_MIN 40
|
||||||
|
|
||||||
|
static void get_functions(CK_FUNCTION_LIST_PTR_PTR funcs) {
|
||||||
|
|
||||||
static void lib_info() {
|
if (C_GetFunctionList(funcs) != CKR_OK) {
|
||||||
|
fprintf(stderr, "Get function list failed\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_lib_info() {
|
||||||
|
|
||||||
CK_INFO info;
|
CK_INFO info;
|
||||||
CK_FUNCTION_LIST_PTR funcs;
|
CK_FUNCTION_LIST_PTR funcs;
|
||||||
|
|
||||||
if (C_GetFunctionList(&funcs) != CKR_OK) {
|
get_functions(&funcs);
|
||||||
fprintf(stderr, "Get function list failed\n");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (funcs->C_GetInfo(&info) != CKR_OK) {
|
if (funcs->C_GetInfo(&info) != CKR_OK) {
|
||||||
fprintf(stderr, "GetInfo failed\n");
|
fprintf(stderr, "GetInfo failed\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (strcmp(info.manufacturerID, MANUFACTURER_ID) != 0) {
|
if (strcmp(info.manufacturerID, MANUFACTURER_ID) != 0) {
|
||||||
fprintf(stderr, "unexpected manufacturer ID %s\n", info.manufacturerID);
|
fprintf(stderr, "unexpected manufacturer ID %s\n", info.manufacturerID);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
@@ -48,9 +55,27 @@ static void lib_info() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_initalize() {
|
||||||
|
|
||||||
|
CK_FUNCTION_LIST_PTR funcs;
|
||||||
|
|
||||||
|
get_functions(&funcs);
|
||||||
|
|
||||||
|
if (funcs->C_Initialize(NULL) != CKR_OK)
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
|
if (funcs->C_Finalize(NULL) != CKR_OK)
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
|
|
||||||
lib_info();
|
test_lib_info();
|
||||||
|
|
||||||
|
#ifdef HW_TESTS
|
||||||
|
test_initalize();
|
||||||
|
#endif
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user