-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compatible reworking of asymmetric key type encoding #109
Comments
Paying more attention to what we have in the specification today:
This contradicts my analysis above, which was based on the Appendix B write-up of the key encoding. However, the result of this is that ECC and FFDH keys now have two vendor bits: bit 15 and bit 7. It is not clear that this is necessary. Would it be acceptable to now make an incompatible change and reclaim bit 7, and require that vendor-specific ECC and FFDH keys use bit15==1 to indicate a non-standard key type encoding (including family), and do not use bit 7 to indicate a non-standard family? I wonder if any implementations are providing custom key encodings for ECC or FFDH? - and if so, are they using bit7==1 in those encodings? |
Here's one in mbedtls: https://github.com/Mbed-TLS/mbedtls/blob/fc31cb28eeda7fafef1bd392fccee3b99035105b/include/psa/crypto_extra.h#L428. This is reproduced in projects that are forks of mbedtls.... |
Although Mbed TLS declares |
Thank you for the clarification. I suspect that its presence in forks of mbedtls are unlikely to indicate that this is used by these other implementations of the API... |
In version 1.1, the Crypto API encodes key types according to Appendix B.2.
For asymmetric keys, this allocates 4 bits for an 'ASYM-TYPE' value, and 7 bits for a 'FAMILY' value.
In v1.1, the ASYM-TYPE only has 3 values (RSA:0, EC:1, and FFDH:2); and the largest set of FAMILY values is for EC keys, with 10 distinct values (but utilising the 6 least significant bits of the field).
Looking ahead, we are likely to need additional asymmetric key encodings:
This would begin to place significant pressure on the ASYM-TYPE field, consuming half of the available values.
Proposal
I propose two changes, that do not affect the values of existing key types, which will provide a better balance of encoding space, and extend the life of the encoding scheme:
Split the bits differently: allocating 5 bits for ASYM-TYPE (bits[7:11]) and 6 for FAMILY (bits [1:6]). Currently bit 7 is zero in all specified key type encodings, so reallocating this bit will change, but not complicate macros that operate with key types.
Implementations that have internal macros, or other code, that use the ASYM-TYPE values literally (as in 0, 1, and 2) will need to be reviewed and reworked if this change was made.
For key types that do not require FAMILY parameterization, (currently just RSA, but the above list adds ML-KEM and ML-DSA), we could improve use of the encoding space by allocating ASYM-TYPE:0 for key types that are not parameterized. Then use the FAMILY field to specify the specific key type.
This would be worth implementing for v1.2, and adopted by the PAKE extension when adding support for SPAKE2+.
Review
Does this conflict with any vendor-specific key types that have been introduced in implementations of the specification?
The text was updated successfully, but these errors were encountered: