Bug 1178653 - softhsm2 library generates invalid ECC secp384r1 parameters
Summary: softhsm2 library generates invalid ECC secp384r1 parameters
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: softhsm
Version: 21
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Paul Wouters
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-01-05 09:11 UTC by Nikos Mavrogiannopoulos
Modified: 2015-12-02 16:58 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-12-02 06:55:10 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
valgrind output (4.01 KB, text/plain)
2015-01-05 09:11 UTC, Nikos Mavrogiannopoulos
no flags Details
/tmp/s/softhsm-valgrind.txt.gz (102.45 KB, text/plain)
2015-02-16 15:50 UTC, Paul Wouters
no flags Details

Description Nikos Mavrogiannopoulos 2015-01-05 09:11:17 UTC
Created attachment 976257 [details]
valgrind output

[I reported this originally to https://issues.opendnssec.org/browse/SUPPORT-152 but it is a FEDORA only issue]

When I generate ECC parameters with SECP384r1 using opensc's pkcs11-tool (or p11tool), I get uninitialized values warnings in valgrind. This does occur for 2048-bit rsa as well, but NOT for secp256r1.

One would have expected the bytes of the generated keys to be properly initialized.

I use softhsm-2.0.0b1-3.fc21.x86_64, compiled with openssl, and I get the conditional jumps with both pkcs11-tool and gnutls' p11tool.

How to reproduce:
$ valgrind pkcs11-tool --module /usr/lib64/pkcs11/libsofthsm2.so --keypairgen --key-type EC:secp384r1 --pin 12345678 --login --label test15

The output is attached.

Comment 1 Nikos Mavrogiannopoulos 2015-02-16 15:39:34 UTC
Upstream in https://issues.opendnssec.org/browse/SUPPORT-152
fails to reproduce this in F21. Paul, could you verify whether the reproducer  works in your F21?

The full list of commands used are shown below.

$ echo "directories.tokendir = ./db" >softhsm.conf
$ echo "objectstore.backend = file" >>softhsm.conf
$ mkdir db
$ export SOFTHSM2_CONF=./softhsm.conf
$ softhsm2-util --init-token --slot 0 --label test --so-pin 1234 --pin 1234
$ valgrind pkcs11-tool --module /usr/lib64/pkcs11/libsofthsm2.so --keypairgen --key-type EC:secp384r1 --pin 1234 --login --label test15
[...]
Public Key Object; EC EC_POINT 384 bits
==27040== Use of uninitialised value of size 8
==27040== at 0x3E53648131: _itoa_word (_itoa.c:180)
==27040== by 0x3E5364CC21: vfprintf (vfprintf.c:1641)
==27040== by 0x3E5370FD25: __printf_chk (printf_chk.c:35)
==27040== by 0x40BBA5: UnknownInlinedFun (stdio2.h:104)
==27040== by 0x40BBA5: show_key (pkcs11-tool.c:2606)
==27040== by 0x40BBA5: show_object (pkcs11-tool.c:2397)
==27040== by 0x40C5C8: gen_keypair (pkcs11-tool.c:1605)
==27040== by 0x405443: main (pkcs11-tool.c:814)

Comment 2 Paul Wouters 2015-02-16 15:49:27 UTC
I get a similar though different error stream. See attached.

Comment 3 Paul Wouters 2015-02-16 15:50:57 UTC
Created attachment 992257 [details]
/tmp/s/softhsm-valgrind.txt.gz

Comment 4 Nikos Mavrogiannopoulos 2015-02-17 09:42:50 UTC
(In reply to Paul Wouters from comment #2)
> I get a similar though different error stream. See attached.

Could it be issues related to FIPS140-2 mode being on? Could you try without that mode?

Comment 5 Paul Wouters 2015-02-28 23:03:17 UTC
I was not in fips mode when doing the above test

Comment 6 Nikos Mavrogiannopoulos 2015-03-01 08:00:09 UTC
FIPS_selftest_rsa is run so most probably you are in FIPS testing more. That is, you have /etc/system-fips present even though your kernel may not be in FIPS mode.

Comment 7 Nikos Mavrogiannopoulos 2015-03-13 08:32:27 UTC
It seems that this issue is related to openssl. I don't see the issue at all if I use export OPENSSL_ia32cap=0

That is certainly related with some optimization openssl is using on my system, which valgrind doesn't handle well?

The problem comes back if I use export OPENSSL_ia32cap=0x200000000000000 which according to https://www.openssl.org/docs/crypto/OPENSSL_ia32cap_loc.html is the AES-NI instruction set extension. There is something fishy there. Why would AES-NI affect secp384r1 key generation, but not secp256r1? In any case why would AES-NI be used anyway? The system isn't in FIPS mode to use an AES-based generator.

I'm adding Tomas in case he has some idea on the issue.

Comment 8 Tomas Mraz 2015-03-13 08:38:29 UTC
Yes, this is pretty weird. Unless you have /etc/system-fips file the AES based DRBG should not be invoked at all. And presence of AES-NI instruction set should not affect anything else than AES.

Comment 9 Fedora End Of Life 2015-11-04 13:12:19 UTC
This message is a reminder that Fedora 21 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 21. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '21'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 21 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 10 Fedora End Of Life 2015-12-02 06:55:13 UTC
Fedora 21 changed to end-of-life (EOL) status on 2015-12-01. Fedora 21 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


Note You need to log in before you can comment on or make changes to this bug.