In T6637#177217, @jukivili wrote:Yes, int8_t/int16_t/int32_t/uint8_t/uint16_t/uint32_t should not be used. There is size-specific integer types defined in src/types.h which can be used instead (byte/u16/u32). This header does not yet have signed integer types, but those can be added (for example, s8/s16/s32).
- Queries
- All Stories
- Search
- Advanced Search
- Transactions
- Transaction Logs
Feed Advanced Search
Advanced Search
Advanced Search
Oct 24 2023
Oct 24 2023
Oct 23 2023
Oct 23 2023
In T6637#176910, @fse wrote:OK, fine, however, in order to be able keep an overview of our tasks I would still keep track of them in our GitHub, where I can create a sub-issue from the list of tasks with one click. But we will post our comments and results here as well as far relevant for the purpose of documentation. I think most of the points Jussi raised are more or less clear to me anyway.
Yes, int8_t/int16_t/int32_t/uint8_t/uint16_t/uint32_t should not be used. There is size-specific integer types defined in src/types.h which can be used instead (byte/u16/u32). This header does not yet have signed integer types, but those can be added (for example, s8/s16/s32).
Oct 18 2023
Oct 18 2023
@jukivilli I have addressed a number of your comments now. You find my comments inline.
Oct 17 2023
Oct 17 2023
Oct 16 2023
Oct 16 2023
Yes, apparently I confused uint8_t and unsigned char here because the former appears in Simon's comments. We also kept to the use of unsigned char* in our implementations (that is even part of the GNU coding guidelines if I remember correctly).
Actually we never use uint8_t* because that is c99 and very uncommon except for some MCU projects. Instead we use unsigned char *. The use of void* is often used because this allows to pass arbitrary types to a function without requiring ugly and error-prone casting at the caller site.
You don't need a library but just one object file.
OK, fine, however, in order to be able keep an overview of our tasks I would still keep track of them in our GitHub, where I can create a sub-issue from the list of tasks with one click. But we will post our comments and results here as well as far relevant for the purpose of documentation. I think most of the points Jussi raised are more or less clear to me anyway.
With respect to the function signatures, I see the following issues with the API you reference via the provided link:
@fse: Github is not an option here. We don't use it and thus everything relevant to Libgcrypt needs to be documented here and not at some external platform.
For length information, we can find that Simon's patch (let me call it v1) has length argument:
https://gitlab.com/jas/libgcrypt/-/commit/3af635afca052a9575912b257fe7518a58bfe810
Oct 15 2023
Oct 15 2023
- There's many functions that use buffers on stack. Do those contain secrets? Should those buffers be wiped before returning from function (with wipememory())? For example, "mlkem_check_secret_key" has two buffers "shared_secret_1" and "shared_secret_2" which are not wiped.
- mlkem.c: mlkem_check_secret_key: "memcmp" is used to compare shared secrets. Should this use constant time comparison instead?
- mlkem-common.c: _gcry_mlkem_mlkem_shake256_rkprf:
- _gcry_md_hash_buffers_extract can be used here instead of _gcry_md_open&write&extract&close.
- mlkem-symmetric.c: _gcry_mlkem_shake256_prf:
- _gcry_md_hash_buffers_extract can be used here instead of _gcry_md_open&write&extract&close. Temporary buffer usage can be avoided by passing input buffers through two IOV to _gcry_md_hash_buffers_extract.
Few comments on the patches.
Oct 11 2023
Oct 11 2023
Our own internal function signatures is not necessarily a good refernce. The main objection to all what you list above is the lack of explicit length information. For each uint8_t* there should also be a size_t ...len in my opinion. Otherwise the API will be highly prone to memory access errors.
@fse Thank you for your comment (quick ! :-).
Oct 10 2023
Oct 10 2023
The API that you quote at the end is indeed what is comonly understood as how a KEM functions and is exactly what fits to ML-KEM.
Oct 9 2023
Oct 9 2023
Please send us patches (to this branch).
One question on the future cooperation: is it from now on possible to directly commit to these branches or will we continue to work with uploading patches to this task?
Oct 6 2023
Oct 6 2023
Pushed the change into kem-kyber branch.
https://dev.gnupg.org/source/libgcrypt/history/kem-kyber/
Oct 5 2023
Oct 5 2023
I'll create a branch for this work. Then, I'll incorporate changes to master.
Oct 4 2023
Oct 4 2023
Uploading two patches for review:
Oct 2 2023
Oct 2 2023
Aug 8 2023
Aug 8 2023
Jul 20 2023
Jul 20 2023
Jun 28 2023
Jun 28 2023
• gniibe changed the status of T6539: The digest&sign/verify API with SHAKE-class digests does not work from Open to Testing.
Add the check of digest algorithm for EdDSA in: rCd15fe6aac10b: cipher:ecc:fips: Only allow defined digest algo for EdDSA.
• gniibe added a comment to T6539: The digest&sign/verify API with SHAKE-class digests does not work.
No, there are use cases in GnuPG, where we specify the hash algo for signing, and our own tests/benchmark.c.
• gniibe added a comment to T6539: The digest&sign/verify API with SHAKE-class digests does not work.
For the first issue, I added a check in: rCf65c30d470f5: cipher:ecc:fips: Reject use of SHAKE when it's ECDSA with RFC6979.
Jun 27 2023
Jun 27 2023
From the FIPS 186-5 there are some limitations to use the SHAKE in FIPS Mode that we will have to reflect:
Jun 23 2023
Jun 23 2023
Pushed a change in master.
• gniibe changed the status of T6557: Support of SHAKE in MGF function of RSA, a subtask of T6539: The digest&sign/verify API with SHAKE-class digests does not work, from Open to Testing.
• gniibe renamed T6557: Support of SHAKE in MGF function of RSA from Support of SHAKE in MGF1 function of RSA to Support of SHAKE in MGF function of RSA.
Jun 22 2023
Jun 22 2023
• gniibe added a comment to T6539: The digest&sign/verify API with SHAKE-class digests does not work.
I found the case of X.509, which also uses fixed length output for RSA-PSS and ECDSA: https://www.rfc-editor.org/rfc/rfc8692.html
Jun 20 2023
Jun 20 2023
Thank you for having a look into that! The proposed patch looks good. Should we have this change also in master?
Jun 19 2023
Jun 19 2023
• gniibe added a comment to T6539: The digest&sign/verify API with SHAKE-class digests does not work.
Here is a possible change (... to master, assuming it's good to support use case of RFC 8702):
diff --git a/cipher/keccak.c b/cipher/keccak.c index 22c40302..76e08cb5 100644 --- a/cipher/keccak.c +++ b/cipher/keccak.c @@ -1630,8 +1630,8 @@ const gcry_md_spec_t _gcry_digest_spec_sha3_512 = const gcry_md_spec_t _gcry_digest_spec_shake128 = { GCRY_MD_SHAKE128, {0, 1}, - "SHAKE128", shake128_asn, DIM (shake128_asn), oid_spec_shake128, 0, - shake128_init, keccak_write, keccak_final, NULL, keccak_extract, + "SHAKE128", shake128_asn, DIM (shake128_asn), oid_spec_shake128, 32, + shake128_init, keccak_write, keccak_final, keccak_read, keccak_extract, _gcry_shake128_hash_buffers, sizeof (KECCAK_CONTEXT), run_selftests @@ -1639,8 +1639,8 @@ const gcry_md_spec_t _gcry_digest_spec_shake128 = const gcry_md_spec_t _gcry_digest_spec_shake256 = { GCRY_MD_SHAKE256, {0, 1}, - "SHAKE256", shake256_asn, DIM (shake256_asn), oid_spec_shake256, 0, - shake256_init, keccak_write, keccak_final, NULL, keccak_extract, + "SHAKE256", shake256_asn, DIM (shake256_asn), oid_spec_shake256, 64, + shake256_init, keccak_write, keccak_final, keccak_read, keccak_extract, _gcry_shake256_hash_buffers, sizeof (KECCAK_CONTEXT), run_selftests
• gniibe added a comment to T6539: The digest&sign/verify API with SHAKE-class digests does not work.
Reading RFC 8702, I realized that it defines the hash size in the use of CMS as: SHAKE128 : 32-byte SHAKE256 : 64-byte.
• gniibe added a comment to T6539: The digest&sign/verify API with SHAKE-class digests does not work.
Jun 16 2023
Jun 16 2023
• gniibe added a comment to T6539: The digest&sign/verify API with SHAKE-class digests does not work.
I found this use case: RFC 8702
"Use of the SHAKE One-Way Hash Functions in the Cryptographic Message Syntax (CMS)": https://www.rfc-editor.org/rfc/rfc8702.html
• gniibe added a comment to T6539: The digest&sign/verify API with SHAKE-class digests does not work.
Another possibility for digest&sign API: it is possible to determine the length of required hash function by the underlining field Fp of the curve in use. Then, use this length instead. It's better than to (try to) get the length by _gcry_md_get_algo_dlen (for SHAKE, it's undefined).
Fixed in both of master and 1.10 branch.
Jun 15 2023
Jun 15 2023
Jun 14 2023
Jun 14 2023
I found that for EdDSA other than pure Ed25519, it can supply context.
I changed the semantics and API for adding context and input data, as we need to support both simultaneously.
I changed the lg-input-data.diff patch not to break the ABI, reusing the published symbol of gcry_pk_random_override_new.
With this approach, if/when needed, backporting may be easier.
Drawback is debugging internal of libgcrypt will be a bit confusing.
Jun 13 2023
Jun 13 2023
Another approach would be having "non-hash" algo for gcry_md_open.
Before adding FIPS support flag and tests, we need to modify implementation:
- Adding PCT check for EdDSA
- Adding support of gcry_pk_hash_sign/verify API for EdDSA
Thanks. I think that it was the oldest one: FSF used to be there in Cambridge, then moved to Tremont St. in Boston, and now it's in Franklin St.
Jun 12 2023
Jun 12 2023
FYI, while going through the licenses again I noticed one of the pinentry files have even older address that so if you would do sed, this would not be matched:
Jun 8 2023
Jun 8 2023
I'm going to add selftest of EdDSA with test vectors from RFC 8032.
Jun 1 2023
Jun 1 2023
They re-used the same file name for the update from March and no history section. Anyway that looks promising and may solve the problem of having different algorithms allowed for restricted communication in the EU and the US.
Correct, but the last revision of FIPS 140-3 lists the EdDSA already. The same for the IG for FIPS 140-3:
My understanding is that FIPS 186-x lists more algorithms than approved for FIPS 140-y; the approved algorithms for 140-y are in the latest revisions of SP800-140. I have not checked the latter document, though.
May 31 2023
May 31 2023
May 30 2023
May 30 2023
• werner edited projects for T5964: gnupg should use the KDFs implemented in libgcrypt, added: gnupg26; removed gnupg24.
Let's schedule that for 2.6
May 16 2023
May 16 2023
Just let me note that we used to have such an API : the former gcry_ac_ functions. However, it turned out that they were more complicated to use.
May 5 2023
May 5 2023
If you experience build problems on macOS see T6442
May 2 2023
May 2 2023
I don't see a reason backing off the original commit. A fix for macOS is now available (rCfa21ddc158b5) and will be in the next release. No reason for other changes.
Apr 27 2023
Apr 27 2023
• gniibe changed the status of T6271: The old FSF address in libgcrypt source code from Open to Testing.
Fixed for libgcrypt, updating copyright notices and license files.
Apr 23 2023
Apr 23 2023
jukivili added a comment to T6451: libgcrypt | gcry_cipher_setkey: 3DES-CBC key returns GPG_ERR_WEAK even with GCRYCTL_SET_ALLOW_WEAK_KEY.
Here's fix for mode specific setkey clearing error code:
0001-cipher-restore-weak-key-error-code-after-mode-specif.patch1 KBDownload
Apr 21 2023
Apr 21 2023
• werner added a comment to T6451: libgcrypt | gcry_cipher_setkey: 3DES-CBC key returns GPG_ERR_WEAK even with GCRYCTL_SET_ALLOW_WEAK_KEY.
There is still a buglet because in some modes the weak key error can be swallowed by other errors. A fix would be something like:
• gniibe added a comment to T6451: libgcrypt | gcry_cipher_setkey: 3DES-CBC key returns GPG_ERR_WEAK even with GCRYCTL_SET_ALLOW_WEAK_KEY.
@jukivili Yes, please go ahead for both branches. Thank you.
Apr 20 2023
Apr 20 2023
jukivili added a comment to T6451: libgcrypt | gcry_cipher_setkey: 3DES-CBC key returns GPG_ERR_WEAK even with GCRYCTL_SET_ALLOW_WEAK_KEY.
About error code. You need to use gcry_err_code(error_code) to get the GPG_ERR_WEAK_KEY value.
Apr 17 2023
Apr 17 2023
Wolff17 added a comment to T6451: libgcrypt | gcry_cipher_setkey: 3DES-CBC key returns GPG_ERR_WEAK even with GCRYCTL_SET_ALLOW_WEAK_KEY.
Ok sorry, my bad, I have to use DES Keying option 2 to have 45 de ae ae e1 f4 6a 29, problem solved.
• werner added a comment to T6451: libgcrypt | gcry_cipher_setkey: 3DES-CBC key returns GPG_ERR_WEAK even with GCRYCTL_SET_ALLOW_WEAK_KEY.
In T6451#169608, @gniibe wrote:Reading the commit rC5beadf201312: Add gcry_cipher_ctl command to allow weak keys in testing use-cases,
The test code in basic.c assumes that it is an application responsibility to confirm&ignore GPG_ERR_WEAK_KEY error when using GCRYCTL_SET_ALLOW_WEAK_KEY.
Wolff17 added a comment to T6451: libgcrypt | gcry_cipher_setkey: 3DES-CBC key returns GPG_ERR_WEAK even with GCRYCTL_SET_ALLOW_WEAK_KEY.
Thank you for you responses! :)
jukivili added a comment to T6451: libgcrypt | gcry_cipher_setkey: 3DES-CBC key returns GPG_ERR_WEAK even with GCRYCTL_SET_ALLOW_WEAK_KEY.
I'll add documentation about GCRYCTL_SET_ALLOW_WEAK_KEY which was missing from be original commit.
jukivili added a comment to T6451: libgcrypt | gcry_cipher_setkey: 3DES-CBC key returns GPG_ERR_WEAK even with GCRYCTL_SET_ALLOW_WEAK_KEY.
tests/basic now actually fail because setkey not returning GPG_ERR_WEAK_KEY for weak keys with GCRYCTL_SET_ALLOW_WEAK_KEY.
jukivili added a comment to T6451: libgcrypt | gcry_cipher_setkey: 3DES-CBC key returns GPG_ERR_WEAK even with GCRYCTL_SET_ALLOW_WEAK_KEY.
That's right. With GCRYCTL_SET_ALLOW_WEAK_KEY, setkey still returns GPG_ERR_WEAK_KEY when weak key is detected. However, cipher handle can still be used as if setkey succeeded.
• gniibe added a comment to T6451: libgcrypt | gcry_cipher_setkey: 3DES-CBC key returns GPG_ERR_WEAK even with GCRYCTL_SET_ALLOW_WEAK_KEY.
Reading the commit rC5beadf201312: Add gcry_cipher_ctl command to allow weak keys in testing use-cases,
The test code in basic.c assumes that it is an application responsibility to confirm&ignore GPG_ERR_WEAK_KEY error when using GCRYCTL_SET_ALLOW_WEAK_KEY.
Apr 16 2023
Apr 16 2023
• werner triaged T6451: libgcrypt | gcry_cipher_setkey: 3DES-CBC key returns GPG_ERR_WEAK even with GCRYCTL_SET_ALLOW_WEAK_KEY as Low priority.
Thanks for the report. Fix is easy. I only wonder why you want to use a weak DES key.
Apr 14 2023
Apr 14 2023
Apr 13 2023
Apr 13 2023
• gniibe closed T5891: EOPNOTSUPP is not defined in mingw.org's MinGW, fails compilation of libgcrypt-1.10.0 as Resolved.
Fixed in 1.10.2.
Fixed in 1.10.2.
• gniibe closed T5976: libgcrypt build failure on HPPA 1.1 (./.libs/libgcrypt.so: undefined reference to `__udiv_qrnnd') as Resolved.
Fixed in 1.10.2.
Fixed in 1.10.2.
• gniibe closed T6066: gcry_pk_hash_verify() does not work with explicitly specified hash algorithm as Resolved.
Fixed in 1.10.2.
Fixed in 1.10.2.
Fixed in 1.10.2.
• gniibe closed T5975: Allow signature verification using specific RSA keys <2k in FIPS mode as Resolved.
Fixed in 1.10.2.