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 <deengert@gmail.com>
Fix: issue #2270
This commit is contained in:
Vincent JARDIN 2021-03-27 14:05:08 +00:00 committed by Frank Morgner
parent 396cbc46cf
commit 39b4472f38
4 changed files with 47 additions and 1 deletions

View File

@ -133,4 +133,5 @@ struct iasecc_private_data {
struct iasecc_se_info *se_info;
};
#endif

View File

@ -34,6 +34,7 @@
#include "internal.h"
#include "pkcs15.h"
#include "../pkcs15init/pkcs15-iasecc.h"
#include "iasecc.h"
#include "aux-data.h"

View File

@ -24,6 +24,10 @@
#include <config.h>
#endif
#ifndef FIX_UNUSED
#define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */
#endif
#ifdef ENABLE_OPENSSL /* empty file without openssl */
#include <stdlib.h>
@ -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 */

View File

@ -0,0 +1,25 @@
/*
* pkcs15-iasecc.h Support for IAS/ECC smart cards
*
* Copyright (C) 2021 Vincent JARDIN <vjardin/AT\free.fr>
*
* 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*/