Skip to contentSkip to conversation

Need help with failling gcm_base(ctr,ghash-generic) selftest

DISCUSSION Corentin Labbe 2 participants 4 messages Aug 1, 2019 – Aug 2, 2019 Crypto API

lore
Share & tools
lore
#0 lore raw

Hello

I am writing the Allwinner sun8i-ce driver and when running tcrypt I got

[   30.201739] alg: aead: gcm_base(ctr-aes-sun8i-ce,ghash-generic) decryption failed on test vector 3; expected_error=0, actual_error=-74, cfg=\"random: may_sleep use_digest src_divs=[100.0%@+2614] dst_divs=[5.90%@alignmask+3015, 60.56%@+3996, 17.92%@+865, 15.62%@+10]\"
or
[  148.613537] alg: aead: gcm_base(ctr-aes-sun8i-ce,ghash-generic) encryption test failed (wrong result) on test vector 2, cfg=\"random: may_sleep use_final src_divs=[100.0%@+0] iv_offset=20\"

Since ctr-aes-sun8i-ce is passing the ctr(aes) selftest, I dont understand what could be wrong.

Thanks
Regards

#1 lore raw
Quoted 8 lines

-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Corentin Labbe
Sent: Thursday, August 1, 2019 9:43 PM
To: [email protected]; [email protected]
Cc: [email protected]
Subject: Need help with failling gcm_base(ctr,ghash-generic) selftest

Quoted 9 lines

Hello

I am writing the Allwinner sun8i-ce driver and when running tcrypt I got

[   30.201739] alg: aead: gcm_base(ctr-aes-sun8i-ce,ghash-generic) decryption failed on test

vector 3; expected_error=0, actual_error=-74, cfg=\"random: may_sleep use_digest src_divs=[100.0%@+2614] dst_divs=[5.90%@alignmask+3015, 60.56%@+3996, 17.92%@+865, 15.62%@+10]\"
or

The decryption reports only an -EBADMSG here, which means the decryption itself went fine, but the authentication tag mismatched.

Quoted 4 lines
[  148.613537] alg: aead: gcm_base(ctr-aes-sun8i-ce,ghash-generic) encryption test failed

(wrong result) on test vector 2, cfg=\"random: may_sleep use_final src_divs=[100.0%@+0] iv_offset=20\"

Can't say for sure, but considering the decrypt error, this is most likely just a mismatch on the appended authentication tag.

Quoted 3 lines

Since ctr-aes-sun8i-ce is passing the ctr(aes) selftest, I dont understand what could be wrong.

That is possible, as this appears to be a problem with the authentication part, not the encryption part. So possibly a problem with the way you setup the authentication key (which is actually derived from the encryption key, but I don't know if your hardware does this autonomously, mine doesn't) and/or operation?

Quoted 2 lines

Thanks
Regards

Regards,
Pascal van Leeuwen
Silicon IP Architect, Multi-Protocol Engines @ Verimatrix www.insidesecure.com

#2 lore raw
Quoted 28 lines · Pascal Van Leeuwen
Quoted 8 lines

-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Corentin Labbe
Sent: Thursday, August 1, 2019 9:43 PM
To: [email protected]; [email protected]
Cc: [email protected]
Subject: Need help with failling gcm_base(ctr,ghash-generic) selftest

Quoted 9 lines

Hello

I am writing the Allwinner sun8i-ce driver and when running tcrypt I got

[   30.201739] alg: aead: gcm_base(ctr-aes-sun8i-ce,ghash-generic) decryption failed on test

vector 3; expected_error=0, actual_error=-74, cfg=\"random: may_sleep use_digest src_divs=[100.0%@+2614] dst_divs=[5.90%@alignmask+3015, 60.56%@+3996, 17.92%@+865, 15.62%@+10]\"
or

The decryption reports only an -EBADMSG here, which means the decryption itself went fine, but the authentication tag mismatched.

Quoted 4 lines
[  148.613537] alg: aead: gcm_base(ctr-aes-sun8i-ce,ghash-generic) encryption test failed

(wrong result) on test vector 2, cfg=\"random: may_sleep use_final src_divs=[100.0%@+0] iv_offset=20\"

Can't say for sure, but considering the decrypt error, this is most likely just a mismatch on the appended authentication tag.

Quoted 8 lines
Quoted 3 lines

Since ctr-aes-sun8i-ce is passing the ctr(aes) selftest, I dont understand what could be wrong.

That is possible, as this appears to be a problem with the authentication part, not the encryption part. So possibly a problem with the way you setup the authentication key (which is actually derived from the encryption key, but I don't know if your hardware does this autonomously, mine doesn't) and/or operation?

But since my driver is just a skcipher, I dont understand why I should care about any aead part, right ?

#3 lore raw
Quoted 46 lines

-----Original Message-----
From: Corentin Labbe <[email protected]>
Sent: Friday, August 2, 2019 7:19 AM
To: Pascal Van Leeuwen <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]
Subject: Re: Need help with failling gcm_base(ctr,ghash-generic) selftest

Quoted 2 lines · Pascal Van Leeuwen
Quoted 2 lines

-----Original Message-----
From: [email protected] <[email protected]> On

Behalf Of

Quoted 10 lines
Quoted 10 lines

Corentin Labbe
Sent: Thursday, August 1, 2019 9:43 PM
To: [email protected]; [email protected]
Cc: [email protected]
Subject: Need help with failling gcm_base(ctr,ghash-generic) selftest

Hello

I am writing the Allwinner sun8i-ce driver and when running tcrypt I got

[   30.201739] alg: aead: gcm_base(ctr-aes-sun8i-ce,ghash-generic) decryption failed

on test

Quoted 10 lines
Quoted 5 lines

vector 3; expected_error=0, actual_error=-74, cfg=\"random: may_sleep use_digest src_divs=[100.0%@+2614] dst_divs=[5.90%@alignmask+3015, 60.56%@+3996, 17.92%@+865, 15.62%@+10]\"
or

The decryption reports only an -EBADMSG here, which means the decryption itself went fine, but the authentication tag mismatched.

Quoted 1 line
[  148.613537] alg: aead: gcm_base(ctr-aes-sun8i-ce,ghash-generic) encryption test

failed

Quoted 1 line
Quoted 1 line

(wrong result) on test vector 2, cfg=\"random: may_sleep use_final

src_divs=[100.0%@+0]

Quoted 6 lines
Quoted 2 lines

iv_offset=20\"

Can't say for sure, but considering the decrypt error, this is most likely just a mismatch on the appended authentication tag.

Quoted 1 line

Since ctr-aes-sun8i-ce is passing the ctr(aes) selftest, I dont understand what could

be

Quoted 2 lines
Quoted 2 lines

wrong.

Quoted 9 lines
Quoted 5 lines

That is possible, as this appears to be a problem with the authentication part, not the encryption part. So possibly a problem with the way you setup the authentication key (which is actually derived from the encryption key, but I don't know if your hardware does this autonomously, mine doesn't) and/or operation?

But since my driver is just a skcipher, I dont understand why I should care about any aead part, right ?

Ah, my bad ... your aes-ctr skcipher is being wrapped by the generic gcm_base template here, I missed that detail ... wish I could help you further, but I can't think of anything obvious that could cause this (decrypt fails on auth as I remarked earlier but only with a specific scatter buffer layout??).

Regards,
Pascal van Leeuwen
Silicon IP Architect, Multi-Protocol Engines @ Verimatrix www.insidesecure.com