From 39b4472f38f784bc4546f541428d5310e2225e80 Mon Sep 17 00:00:00 2001 From: Vincent JARDIN Date: Sat, 27 Mar 2021 14:05:08 +0000 Subject: [PATCH] IASECC/CPX: export pkcs15init for missing features Some cards, such as the CPX are missing features that should have been initialized using: iasecc_pkcs15_encode_supported_algos() Let's export this function in order to build a fixup when the DF should be parsed. When OPENSSL is missing, an error should be rised since this workaround for the CPX cards cannot work. It means that any environments that use the CPX cards must be compiled with ENABLE_OPENSSL. Suggested-by: Doug Engert Fix: issue #2270 --- src/libopensc/iasecc.h | 1 + src/libopensc/pkcs15-iasecc.c | 1 + src/pkcs15init/pkcs15-iasecc.c | 21 ++++++++++++++++++++- src/pkcs15init/pkcs15-iasecc.h | 25 +++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 src/pkcs15init/pkcs15-iasecc.h diff --git a/src/libopensc/iasecc.h b/src/libopensc/iasecc.h index bad11df0..4e59f69a 100644 --- a/src/libopensc/iasecc.h +++ b/src/libopensc/iasecc.h @@ -133,4 +133,5 @@ struct iasecc_private_data { struct iasecc_se_info *se_info; }; + #endif diff --git a/src/libopensc/pkcs15-iasecc.c b/src/libopensc/pkcs15-iasecc.c index a0a91769..137e4b3f 100644 --- a/src/libopensc/pkcs15-iasecc.c +++ b/src/libopensc/pkcs15-iasecc.c @@ -34,6 +34,7 @@ #include "internal.h" #include "pkcs15.h" +#include "../pkcs15init/pkcs15-iasecc.h" #include "iasecc.h" #include "aux-data.h" diff --git a/src/pkcs15init/pkcs15-iasecc.c b/src/pkcs15init/pkcs15-iasecc.c index 2fff9ab8..377385c8 100644 --- a/src/pkcs15init/pkcs15-iasecc.c +++ b/src/pkcs15init/pkcs15-iasecc.c @@ -24,6 +24,10 @@ #include #endif +#ifndef FIX_UNUSED +#define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */ +#endif + #ifdef ENABLE_OPENSSL /* empty file without openssl */ #include @@ -778,7 +782,7 @@ iasecc_pkcs15_fix_file_access(struct sc_pkcs15_card *p15card, struct sc_file *fi } -static int +int iasecc_pkcs15_encode_supported_algos(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *object) { struct sc_context *ctx = p15card->card->ctx; @@ -1881,4 +1885,19 @@ sc_pkcs15init_get_iasecc_ops(void) return &sc_pkcs15init_iasecc_operations; } +#else /* ENABLE_OPENSSL */ +#include "../libopensc/log.h" +#include "pkcs15-init.h" + +int +iasecc_pkcs15_encode_supported_algos(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *object) +{ + struct sc_context *ctx = p15card->card->ctx; + FIX_UNUSED(object); + + LOG_FUNC_CALLED(ctx); + sc_log(ctx, "OpenSC was built without OpenSSL support: skipping"); + LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_IMPLEMENTED); +} + #endif /* ENABLE_OPENSSL */ diff --git a/src/pkcs15init/pkcs15-iasecc.h b/src/pkcs15init/pkcs15-iasecc.h new file mode 100644 index 00000000..65ee0eae --- /dev/null +++ b/src/pkcs15init/pkcs15-iasecc.h @@ -0,0 +1,25 @@ +/* + * pkcs15-iasecc.h Support for IAS/ECC smart cards + * + * Copyright (C) 2021 Vincent JARDIN + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef pkcs15_iasecc_h +#define pkcs15_iasecc_h + +extern int iasecc_pkcs15_encode_supported_algos(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *object); +#endif /* #ifndef pkcs15_iasecc_h*/