From 1c09fa8a22d918dc2a0505d0b1eb62b6e079c0b8 Mon Sep 17 00:00:00 2001 From: Hannu Honkanen Date: Fri, 17 Nov 2017 15:51:48 +0200 Subject: [PATCH] Handle AES algorithm. Doesn't set any flags, but check for AES is needed to avoid SC_ERROR_NOT_SUPPORTED. --- src/libopensc/padding.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/libopensc/padding.c b/src/libopensc/padding.c index 75c92b65..1cb38b0d 100644 --- a/src/libopensc/padding.c +++ b/src/libopensc/padding.c @@ -480,12 +480,12 @@ int sc_get_encoding_flags(sc_context_t *ctx, /* TODO: Could convert GOSTR3410_HASH_GOSTR3411 -> GOSTR3410_RAW and * ECDSA_HASH_ -> ECDSA_RAW using OpenSSL (not much benefit though). */ + if ((caps & iflags) == iflags) { /* Card supports the signature operation we want to do, great, let's * go with it then. */ *sflags = iflags; *pflags = 0; - } else if ((caps & SC_ALGORITHM_RSA_PAD_PSS) && (iflags & SC_ALGORITHM_RSA_PAD_PSS)) { *sflags |= SC_ALGORITHM_RSA_PAD_PSS; @@ -505,6 +505,17 @@ int sc_get_encoding_flags(sc_context_t *ctx, *sflags = SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE; *pflags = iflags & SC_ALGORITHM_RSA_HASHES; + } else if ((iflags & SC_ALGORITHM_AES) == SC_ALGORITHM_AES) { /* TODO: seems like this constant does not belong to the same set of flags used form asymmetric algos. Fix this! */ + *sflags = 0; + *pflags = 0; + + } else if ((iflags & SC_ALGORITHM_AES_FLAGS) > 0) { + *sflags = iflags & SC_ALGORITHM_AES_FLAGS; + if (iflags & SC_ALGORITHM_AES_CBC_PAD) + *pflags = SC_ALGORITHM_AES_CBC_PAD; + else + *pflags = 0; + } else { LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "unsupported algorithm"); }