Skip to contentSkip to conversation

RSA key size not allowed in FIPS

DISCUSSION Tapas Sarangi 3 participants 10 messages Aug 9, 2016 – Aug 16, 2016 Crypto API

lore
Share & tools
lore
#0 lore raw

Hello,

I am using vanilla kernel-4.7 source. It crashes with the following when booted with ³fips=1 boot=/dev/sda1² option at the kernel command line argument.

[    0.642411] RSA: key size not allowed in FIPS mode
[    0.643099] Problem loading in-kernel X.509 certificate (-22)
[    0.800524] BUG: unable to handle kernel NULL pointer dereference at
0000000000000068
[    0.803075] IP: [<ffffffff811e1ad7>] kernfs_find_ns+0x17/0xf0
[    0.804111] PGD 0
[    0.804111] Oops: 0000 [#1] SMP
[    0.804111] Modules linked in:
[    0.804111] CPU: 0 PID: 6 Comm: kworker/u2:0 Tainted: G        W
4.7.0-1.tos2_5 #1
[    0.804111] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
1.8.2-20150714_191134- 04/01/2014
[    0.804111] Workqueue: events_unbound async_run_entry_fn
[    0.804111] task: ffff88003e214100 ti: ffff88003e264000 task.ti:
ffff88003e264000
[    0.804111] RIP: 0010:[<ffffffff811e1ad7>]  [<ffffffff811e1ad7>]
kernfs_find_ns+0x17/0xf0
[    0.804111] RSP: 0018:ffff88003e267868  EFLAGS: 00010282
[    0.804111] RAX: ffff88003e214100 RBX: 0000000000000000 RCX:
ffff88003e264008
[    0.804111] RDX: 0000000000000000 RSI: ffffffff8166bb80 RDI:
0000000000000000
[    0.804111] RBP: ffff88003e267898 R08: 0000000000000000 R09:
ffffffff8166bb80
[    0.804111] R10: 00000000000c6000 R11: 0000000000000001 R12:
ffffffff8166bb80
[    0.804111] R13: 0000000000000000 R14: ffffffff8173048a R15:
ffff88003b17b1a0
[    0.804111] FS:  0000000000000000(0000) GS:ffff88003fc00000(0000)
knlGS:0000000000000000
[    0.804111] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[    0.804111] CR2: 0000000000000068 CR3: 0000000001806000 CR4:
00000000000406f0
[    0.804111] Stack:
[    0.804111]  ffff88003e267898 0000000000000000 ffff880000000001
0000000000000000
[    0.804111]  ffffffff8166bb80 0000000000000000 ffff88003e2678c8
ffffffff811e1e77
[    0.804111]  0000000000000096 ffffffff81873d40 ffff88003b152828
0000000000000005
[    0.804111] Call Trace:
[    0.804111]  [<ffffffff811e1e77>] kernfs_find_and_get_ns+0x37/0x60
[    0.804111]  [<ffffffff811e5c58>] sysfs_unmerge_group+0x18/0x60
[    0.804111]  [<ffffffff8139c187>] dpm_sysfs_remove+0x27/0x60

Thanks for any suggestion.
-Tapas
Ps : I could not send any attachment, is it possible to send attachment to this mailing list ?

________________________________

This transmission may contain information that is privileged, confidential, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is strictly prohibited. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format.

#1 lore raw

Am Dienstag, 9. August 2016, 14:10:33 CEST schrieb Tapas Sarangi:

Hi Tapas,

Quoted 5 lines

Hello,

I am using vanilla kernel-4.7 source. It crashes with the following when booted with ³fips=1 boot=/dev/sda1² option at the kernel command line argument.

The kernel only allows 2k and 3k RSA keys in FIPS mode. Please check your RSA key used for signatures.

                /* In FIPS mode only allow key size 2K & 3K */
                if (n_sz != 256 && n_sz != 384) {
                        pr_err("RSA: key size not allowed in FIPS mode\n");
                        return -EINVAL;
                }

Ciao
Stephan

#2 lore raw

Hi Stephan,

If I understand this correctly, this (CONFIG_MODULE_SIG_HASH=“sha256") tells about the key size used.
I am using “sha256”. Initially, I was using “sha512” which I thought could be causing problem, but I am getting same error when change it to “sha256”.

[root@localhost ~]# grep MODULE_SIG /boot/config-4.7.0-1.tos2_5

CONFIG_MODULE_SIG=y
# CONFIG_MODULE_SIG_FORCE is not set
CONFIG_MODULE_SIG_ALL=y
# CONFIG_MODULE_SIG_SHA1 is not set
# CONFIG_MODULE_SIG_SHA224 is not set
CONFIG_MODULE_SIG_SHA256=y
# CONFIG_MODULE_SIG_SHA384 is not set
# CONFIG_MODULE_SIG_SHA512 is not set
CONFIG_MODULE_SIG_HASH="sha256"
CONFIG_MODULE_SIG_KEY="certs/signing_key.pem"

Thanks

-Tapas

Quoted 21 lines · Stephan Mueller

Am Dienstag, 9. August 2016, 14:10:33 CEST schrieb Tapas Sarangi:

Hi Tapas,

Quoted 5 lines

Hello,

I am using vanilla kernel-4.7 source. It crashes with the following when booted with ³fips=1 boot=/dev/sda1² option at the kernel command line argument.

The kernel only allows 2k and 3k RSA keys in FIPS mode. Please check your RSA
key used for signatures.

               /* In FIPS mode only allow key size 2K & 3K */
               if (n_sz != 256 && n_sz != 384) {
                       pr_err("RSA: key size not allowed in FIPS
mode\n");
                       return -EINVAL;
               }
Quoted 2 lines

Ciao
Stephan

________________________________

This transmission may contain information that is privileged, confidential, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is strictly prohibited. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format.

#3 lore raw

Looking at the kernel compilation log, it seems to be generating a 4k (4096 bits) private key, although I am specifying CONFIG_MODULE_SIG_HASH=“sha256”. How can I generate RSA key that is within 2k-3k bits ?

Here is a snippet from the compilation log:

### Now generating an X.509 key pair to be used for signing modules.
###
### If this takes a long time, you might wish to run rngd in the ### background to keep the supply of entropy topped up. It ### needs to be run as root, and uses a hardware random ### number generator if one is available.
###
Generating a 4096 bit RSA private key

Thanks a lot.
-Tapas

Quoted 21 lines · Tapas Sarangi

Hi Stephan,

If I understand this correctly, this (CONFIG_MODULE_SIG_HASH=“sha256") tells about the key size used.
I am using “sha256”. Initially, I was using “sha512” which I thought could be causing problem, but I am getting same error when change it to “sha256”.

[root@localhost ~]# grep MODULE_SIG /boot/config-4.7.0-1.tos2_5

CONFIG_MODULE_SIG=y
# CONFIG_MODULE_SIG_FORCE is not set
CONFIG_MODULE_SIG_ALL=y
# CONFIG_MODULE_SIG_SHA1 is not set
# CONFIG_MODULE_SIG_SHA224 is not set
CONFIG_MODULE_SIG_SHA256=y
# CONFIG_MODULE_SIG_SHA384 is not set
# CONFIG_MODULE_SIG_SHA512 is not set
CONFIG_MODULE_SIG_HASH="sha256"
CONFIG_MODULE_SIG_KEY="certs/signing_key.pem"

Quoted 33 lines

Thanks

-Tapas

Quoted 24 lines · Stephan Mueller

Am Dienstag, 9. August 2016, 14:10:33 CEST schrieb Tapas Sarangi:

Hi Tapas,

Quoted 6 lines

Hello,

I am using vanilla kernel-4.7 source. It crashes with the following when
booted with ³fips=1 boot=/dev/sda1² option at the kernel command line argument.

The kernel only allows 2k and 3k RSA keys in FIPS mode. Please check your RSA
key used for signatures.

               /* In FIPS mode only allow key size 2K & 3K */
               if (n_sz != 256 && n_sz != 384) {
                       pr_err("RSA: key size not allowed in FIPS
mode\n");
                       return -EINVAL;
               }

Ciao
Stephan

________________________________

This transmission may contain information that is privileged, confidential, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is strictly prohibited. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format.

#4 lore raw
In reply to Tapas Sarangi

Am Dienstag, 9. August 2016, 14:39:03 CEST schrieb Tapas Sarangi:

Hi Tapas, David,

Quoted 10 lines

Hi Stephan,

If I understand this correctly, this (CONFIG_MODULE_SIG_HASH=“sha256") tells about the key size used.
I am using “sha256”. Initially, I was using “sha512” which I thought could be causing problem, but I am getting same error when change it to “sha256”.

[root@localhost ~]# grep MODULE_SIG /boot/config-4.7.0-1.tos2_5

Quoted 10 lines

CONFIG_MODULE_SIG=y
# CONFIG_MODULE_SIG_FORCE is not set
CONFIG_MODULE_SIG_ALL=y
# CONFIG_MODULE_SIG_SHA1 is not set
# CONFIG_MODULE_SIG_SHA224 is not set
CONFIG_MODULE_SIG_SHA256=y
# CONFIG_MODULE_SIG_SHA384 is not set
# CONFIG_MODULE_SIG_SHA512 is not set
CONFIG_MODULE_SIG_HASH="sha256"
CONFIG_MODULE_SIG_KEY="certs/signing_key.pem"

It is rather the question how signing_key.pem is generated.

Do you have the file certs/x509.genkey? If yes, what is the default_bits value?

David, the x509.genkey file seems to generate a 4k RSA key per default. This will cause a panic with fips=1 as only 2k and 3k keys are allowed.

Ciao
Stephan

#5 lore raw

Embarrassing! Yes, I just saw this while you are pressing send on that replyŠ default bits were set to 4096 in x509.genkey. :-(

I am trying out with 2048 bits. I will confirm.

-Tapas

Quoted 31 lines · Stephan Mueller

Am Dienstag, 9. August 2016, 14:39:03 CEST schrieb Tapas Sarangi:

Hi Tapas, David,

Quoted 11 lines

Hi Stephan,

If I understand this correctly, this (CONFIG_MODULE_SIG_HASH=³sha256") tells about the key size used.
I am using ³sha256². Initially, I was using ³sha512² which I thought could
be causing problem, but I am getting same error when change it to ³sha256².

[root@localhost ~]# grep MODULE_SIG /boot/config-4.7.0-1.tos2_5

Quoted 10 lines

CONFIG_MODULE_SIG=y
# CONFIG_MODULE_SIG_FORCE is not set
CONFIG_MODULE_SIG_ALL=y
# CONFIG_MODULE_SIG_SHA1 is not set
# CONFIG_MODULE_SIG_SHA224 is not set
CONFIG_MODULE_SIG_SHA256=y
# CONFIG_MODULE_SIG_SHA384 is not set
# CONFIG_MODULE_SIG_SHA512 is not set
CONFIG_MODULE_SIG_HASH="sha256"
CONFIG_MODULE_SIG_KEY="certs/signing_key.pem"

It is rather the question how signing_key.pem is generated.

Do you have the file certs/x509.genkey? If yes, what is the default_bits value?

Quoted 6 lines

David, the x509.genkey file seems to generate a 4k RSA key per default. This
will cause a panic with fips=1 as only 2k and 3k keys are allowed.

Ciao
Stephan

________________________________

This transmission may contain information that is privileged, confidential, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is strictly prohibited. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format.

#6 lore raw

Hi Stephan,

Thanks for your responses. I am past this error now.

I am still NOT out of trouble. Now, test integrity fails while trying to get into FIPS mode. Here is the snippet of error messages. I will create a separate thread for this,

/boot/vmlinuz-4.7.0-1.tos2_5: OK
modprobe: ERROR: could not insert 'drbg': Unknown symbol in module, or unknown parameter (see dmesg)

[    1.193406] dracut: FATAL: FIPS integrity test failed
[    1.194086] dracut: Refusing to continue
[    1.195820] Kernel panic - not syncing: Attempted to kill init!
exitcode=0x00000100
[    1.195820]

-Tapas

Quoted 48 lines · Tapas Sarangi

Embarrassing! Yes, I just saw this while you are pressing send on that replyŠ default bits were set to 4096 in x509.genkey. :-(

I am trying out with 2048 bits. I will confirm.

-Tapas

Quoted 37 lines · Stephan Mueller

Am Dienstag, 9. August 2016, 14:39:03 CEST schrieb Tapas Sarangi:

Hi Tapas, David,

Quoted 11 lines

Hi Stephan,

If I understand this correctly, this (CONFIG_MODULE_SIG_HASH=³sha256") tells about the key size used.
I am using ³sha256². Initially, I was using ³sha512² which I thought could
be causing problem, but I am getting same error when change it to ³sha256².

[root@localhost ~]# grep MODULE_SIG /boot/config-4.7.0-1.tos2_5

Quoted 10 lines

CONFIG_MODULE_SIG=y
# CONFIG_MODULE_SIG_FORCE is not set
CONFIG_MODULE_SIG_ALL=y
# CONFIG_MODULE_SIG_SHA1 is not set
# CONFIG_MODULE_SIG_SHA224 is not set
CONFIG_MODULE_SIG_SHA256=y
# CONFIG_MODULE_SIG_SHA384 is not set
# CONFIG_MODULE_SIG_SHA512 is not set
CONFIG_MODULE_SIG_HASH="sha256"
CONFIG_MODULE_SIG_KEY="certs/signing_key.pem"

It is rather the question how signing_key.pem is generated.

Do you have the file certs/x509.genkey? If yes, what is the default_bits value?

David, the x509.genkey file seems to generate a 4k RSA key per default. This
will cause a panic with fips=1 as only 2k and 3k keys are allowed.

Ciao
Stephan

________________________________

This transmission may contain information that is privileged, confidential, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is strictly prohibited. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format.

#7 lore raw

Am Dienstag, 9. August 2016, 16:07:06 CEST schrieb Tapas Sarangi:

Hi Tapas,

Quoted 5 lines

Hi Stephan,

Thanks for your responses. I am past this error now.

Quoted 7 lines

I am still NOT out of trouble. Now, test integrity fails while trying to get into FIPS mode. Here is the snippet of error messages. I will create a separate thread for this,

/boot/vmlinuz-4.7.0-1.tos2_5: OK
modprobe: ERROR: could not insert 'drbg': Unknown symbol in module, or unknown parameter (see dmesg)

Do you see which symbol is missing?

Quoted 80 lines
[    1.193406] dracut: FATAL: FIPS integrity test failed
[    1.194086] dracut: Refusing to continue
[    1.195820] Kernel panic - not syncing: Attempted to kill init!
exitcode=0x00000100
[    1.195820]

-Tapas

Quoted 60 lines · Tapas Sarangi

Embarrassing! Yes, I just saw this while you are pressing send on that replyŠ default bits were set to 4096 in x509.genkey. :-(

I am trying out with 2048 bits. I will confirm.

-Tapas

Quoted 47 lines · Stephan Mueller

Am Dienstag, 9. August 2016, 14:39:03 CEST schrieb Tapas Sarangi:

Hi Tapas, David,

Quoted 19 lines

Hi Stephan,

If I understand this correctly, this (CONFIG_MODULE_SIG_HASH=³sha256") tells about the key size used.
I am using ³sha256². Initially, I was using ³sha512² which I thought

could

be causing problem, but I am getting same error when change it to ³sha256².

[root@localhost ~]# grep MODULE_SIG /boot/config-4.7.0-1.tos2_5

Quoted 10 lines

CONFIG_MODULE_SIG=y
# CONFIG_MODULE_SIG_FORCE is not set
CONFIG_MODULE_SIG_ALL=y
# CONFIG_MODULE_SIG_SHA1 is not set
# CONFIG_MODULE_SIG_SHA224 is not set
CONFIG_MODULE_SIG_SHA256=y
# CONFIG_MODULE_SIG_SHA384 is not set
# CONFIG_MODULE_SIG_SHA512 is not set
CONFIG_MODULE_SIG_HASH="sha256"
CONFIG_MODULE_SIG_KEY="certs/signing_key.pem"

It is rather the question how signing_key.pem is generated.

Do you have the file certs/x509.genkey? If yes, what is the default_bits value?

David, the x509.genkey file seems to generate a 4k RSA key per default. This
will cause a panic with fips=1 as only 2k and 3k keys are allowed.

Ciao
Stephan

________________________________

Quoted 7 lines

This transmission may contain information that is privileged, confidential, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is strictly prohibited. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format.

Ciao
Stephan

#8 lore raw
In reply to Stephan Mueller

Am Dienstag, 9. August 2016, 16:55:52 CEST schrieb Stephan Mueller:

Hi Tapas, David,

Quoted 3 lines

David, the x509.genkey file seems to generate a 4k RSA key per default. This will cause a panic with fips=1 as only 2k and 3k keys are allowed.

Just yesterday, a new ruling came out from NIST allowing any key size >= 2048 provided that at least either 2048 or 3072 is a usable key size to allow CAVS testing.

I will send a patch that changes this in the code.

Thanks
Stephan

#9 lore raw
In reply to Tapas Sarangi
Quoted 2 lines · Tapas Sarangi

Ps : I could not send any attachment, is it possible to send attachment to this mailing list ?

Pretty sure that's frowned upon.