Re: mutual authentication fails when FIPS enabled
Douglas E Engert <[email protected]> Tue, 2 Feb 2021 07:48:45 -0600
| Newsgroups | gmane.comp.encryption.opensc.devel |
|---|---|
| Message-ID | <[email protected]> |
The point of using a smartcard is the crypto operations are done on the smart card, token
or other hardware like a HSM, or TPS. The point of FIPS is the software and hardware has
been approved and tested to do appropriate crypto operations.
The "fix" to just set RSA_FLAG_FIPS_METHOD is not a fix, it is lie. It in effect is saying
libp11 take the responsibility of saying the PKCS11 modules and the smart card, tokens
or other hardware are FIPS complaint.
The problem today, from the PKCS#11 standpoint, there is no way to prove the PKCS#11 modules,
and hardware meet the FIPS standards. Some PKCS#11 modules are software only,
designed they can run the cloud and with better performance. Some smart cards have applets
that have never bee approved. (Note: The RedHat comments in the bug fix say it is not a proper
fix.)
You as the application developer have a choice, as to what version of OpenSSL you use. As
Petr said, you can split the operations up, so the engine with pkcs11 is used with a non
FIPS mode OpenSSL, and FIPS mode for the rest. Or you can use non-FIPS OpenSSL. Or modify
the code like RedHat did. You also have a choice as to what PKCS11 modules and hardware
you are using.
From an OpenSC developer, I see this is a problem, but would not want to see the "fix"
in the code as it is a lie. But it might be possible to add code that would set that flag
Maybe via env variable? This would let the application developer decide if
they want to take responsibility.
This is going to be more complicated with ECC and newer versions of OpenSSL too.
P.S.
You used the phrase "get the private key". For most PKCS11 systems, the private
key never leaves the smart card. The Crypto operation is done on the card, you can only
retrieve the result of the operation, like a signature. If you can "get the private key"
off the smartcard using PKCS11, there would be no need of a smart card, it could be a
file that you read and pass to openssl and no need to use an engine or libp11.
On 2/1/2021 9:15 PM, George wrote:
> Hi Petr,
>
> I would like to clarify my original problem. The mutual authentication is between my application using OpenSSL and another server. I am using LIBP11 to with OpenSSL to allow OpenSSL to access the
> certificate and private key on my smart card. i.e. OpenSSL is using LIBP11 to get the private key and certificate.
>
> When FIPS is enabled, I see the OpenSSL error:
>
> *error:0409909D:rsa routines:RSA_public_encrypt:non fips rsa method*
>
>
> Since I am not making any calls directly to LIBP11, how can I fix this in my code? i.e. OpenSSL is using LIBP11, not my application code.
>
> This problem was described in the Red Hat bug report:
>
> https://bugzilla.redhat.com/show_bug.cgi?id=1827535 <https://bugzilla.redhat.com/show_bug.cgi?id=1827535>
>
> The solution was to add a flag RSA_FLAG_FIPS_METHOD in the p11_rsa.c function:
>
> RSA_METHOD *PKCS11_get_rsa_method(void)
> {
> static RSA_METHOD *ops = NULL;
>
> if (!ops) {
> alloc_rsa_ex_index();
> ops = RSA_meth_dup(RSA_get_default_method());
> if (!ops)
> return NULL;
> RSA_meth_set1_name(ops, "libp11 RSA method");
> *RSA_meth_set_flags(ops, RSA_FLAG_FIPS_METHOD); <-- This flag was added to fix the problem*
> RSA_meth_set_priv_enc(ops, pkcs11_rsa_priv_enc_method);
> RSA_meth_set_priv_dec(ops, pkcs11_rsa_priv_dec_method);
> RSA_meth_set_finish(ops, pkcs11_rsa_free_method);
> }
> return ops;
> }
>
>
> Is the problem related to the actual PIN? If so, how can I fix that?
>
> My OpenSSL dynamic engine is initialized with code to obtain the smart card password from the user with getPassword():
>
> ENGINE_ctrl_cmd_string(engine, "PIN", getPassword(), 0);
>
>
>
> Thanks,
> George
>
>
> On 2021-02-01 1:35 p.m., Petr Pisar wrote:
>> V Mon, Feb 01, 2021 at 12:39:30PM -0500, George napsal(a):
>>> Hi,
>>>
>>> I had a closer look at this problem and confirmed that I have
>>> successfully enabled FIPS in OpenSSL and am using the FIPS compliant
>>> cipher suite TLS_RSA_WITH_AES_128_CBC_SHA.
>>> (https://wiki.openssl.org/index.php/FIPS_mode_and_TLS#TLS_1.2)
>>>
>> That's a cipher suite for TLS (encrypted TCP).
>>
>>> However, LIBP11 still fails unless I make a modification to the source
>>> code in p11_rsa.c. Does this mean there is indeed a bug in LIBP11?
>>>
>> I think that a mutual authentication in context of libp11 means a "secure"
>> authentication of a user to a cryptographic card instead of sending a PIN in
>> a "plain" text between the user and the card. I saw a few hints that there is
>> used a MD5-based HMAC. And that probably triggers your issue.
>>
>> -- Petr
>>
>>
>> _______________________________________________
>> Opensc-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/opensc-devel
>
>
>
> _______________________________________________
> Opensc-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/opensc-devel
>
--
Douglas E. Engert <[email protected]>
_______________________________________________
Opensc-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensc-devel