Some improvements #699
Labels
No labels
bug
duplicate
enhancement
feature
help wanted
improve API
invalid
needs documentation
not-planned
rtfm
stale
support
wishlist
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-libtom/libtomcrypt!699
Loading…
Reference in a new issue
No description provided.
Delete branch "some-improvements"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I've reordered and refactored some of the commits of #697 in order to limit its scope and simplify the merge and a potential faster release of 2.0
With these changes merged I currently don't see any planned ABI or API breakage (besides #515, but that's an entirely different discussion).
This should be the last PR with intentional changes before a v2.0.0-rc1, c.f. #568
I have just quickly changed the libtomcrypt in my CryptX perl bindings for the branch "some-improvements" from this PR.
It failed to build (which is probably expected) https://github.com/DCIT/perl-CryptX/actions/runs/18219248768/job/51875345151
I will try to adopt CryptX to the new changes (after that we will see whether CryptX test suite reveals something).
Cool, thanks!
If I'm not mistaken there are two errors
[148] ff. is already caused by #524
[187] ff. is indeed caused by the API change of
rsa_verify_hash_ex()in this PRBoth are expected, so thanks already in advance for fixing this in CryptX and testing those changes ☺️
[148] https://github.com/DCIT/perl-CryptX/actions/runs/18219248768/job/51875345151#step:7:149
[187] https://github.com/DCIT/perl-CryptX/actions/runs/18219248768/job/51875345151#step:7:188
I have updated my perl bindings and it seems to work fine.
Just one minor suggestion: please add
@param mgf_hash_idx .....to description of rsa_sign_hash_ex + rsa_verify_hash_exI am not sure about having: type = LTC_ECCSIG_RFC5656 (as I understand the "type" is rather a format specification not a flag defining whether to use deterministic signing) e.g. one might want LTC_ECCSIG_RFC5656 + LTC_ECCSIG_ETH27 at the same time.
ad
struct ltc_ecc_sig_optscould we simplifyint *recid;toint recid;?Yeah, we could, but that would mean that it must be initialized to -1 if one is not interested in it (which is nearly always the case). With the current implementation via a pointer, it is disabled by default, so it'd be easier to use for the majority of users. But if you think it'd be better as
int recidfeel free to say so! I don't really have a hard opinion on that.I guess you're confusing RFC5656 and RFC6979 :)
Oh, yes. Sorry for the noise.
FYI current branch
some-improvementsseems to fail on arm and cywin (will investigate later)it is a segfault (memory corruption) related to
ecc_sign_hash_v2(still not sure if in libtomcrypt or in C code of my perl bindings)hmm
At least the tests can't reproduce it for AARCH64 with Qemu ...
on cywin it fails inside
ecc_rfc6979_keyin the firsthmac_memory_multi(which is strange)The fix
github.com/DCIT/perl-CryptX@cccc52bb62now passes tests also on cygwin + arm
Thanks for triaging it and proposing the fix. Seeing it like that it's obvious now ...
The last patch should be an equivalent solution to your proposed fix, could you please check again?
checked, it is good
If you're fine with those latest changes [0] I'll add the same macro trickery for the deprecated RSA APIs as well, properly deprecate all the remaining APIS, and then we'll only have to update the docs...
[0] https://github.com/libtom/libtomcrypt/pull/699/files/baf71ad0544d1b1f03b5b644203b6afbe43b9feb..b78da6e65607c23f852ce78583e90025cd2817d9
This would allow us to extend functionality without breaking API&ABI in the future.
Is this really necessary for RSA?
Should some ECC struct get something like that?
The old RSA style let you pass two values separately:
int mgf_hashandint lparam_hash. But the new style has only one value: inthash_idx(seersa_args_to_op_params).True. That second parameter was only introduced in #612 and in order to make the API backwards compatible again I've limited the new functionality to the v2 API.
I thought if we already introduce new APIs, we can also do the full deprecation dance. We're not going to be ABI compatible, but the API's would stay the same.
After few hours I am still unable to switch my perl bindings to the new RSA API. I make it to compile but it fails during some operations (enc/dec, sign/verify) and it is not easy for me to debug why.
I have chosen a way like this:
but still getting errors like "Invalid PK key or key type specified for function" + on other places errors like "Invalid hash specified" etc.
Maybe I still did not fully understand the new concept (it has definitely much steeper learning curve than the old one).
ugh, sorry! The tests seem to work fine for me.
I've just pushed my WIP state with the updated macros etc.
It could absolutely be that the generic validity checks don't handle everything correctly, I've only tested against the built-in set of tests... 😬
shouldn't the
s_rsa_key_valid_pss_algsbe rathers_rsa_key_valid_pss_oaep_algsand allow also paddingLTC_PKCS_1_OAEP?The simple example I am not able to implement in the new RSA API (sorry for just a code fragment extracted from my perl bindings):
I'll have a look into it later, but please remove
.params.pss_oaep = 1,and it works ... 🙈It worked. But IMO a bit surprising to me (as the whole concept of key->params / check->params / ltc_rsa_op_parameters ...)
Anyway, still bunch of other failures (will investigate later).
Yeah, a bit, but not really. The
key->paramsexist because there's the possibility to restrict the PKCS#1 version via X.509 certificates. The re-use ofltc_rsa_parametersinsideltc_rsa_op_parameters, came out of laziness because it's kind of shared details (minus thepss_oaepfield with isn't required there).Regular RSA keys can be used with all PKCS#1 versions.
Restricted RSA keys ("PSS-keys") must only be used with PKCS#1 versions > 1.5, and come with a set of parameters. There's already
rsa_import_x509.c::rsa_decode_parameters(), but that one isn't used yet, resp. I'll have to check whether it should be. I've other stuff to finish before continuing on this.