-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
PSA: implement key derivation for ECC keys #3260
Comments
I read a about elliptic curves and Diffie-Hellman key exchange algorithm to get some background for this task. I understand that the algorithm provided in this task is to define The algorithm is quite simple, but I don't know where
Unclear to me is also where the implementation should be added. |
So conceptually, key derivation consists of two independent parts:
Currently, part 2 in
The goal of this task is to implement part 2 for ECC key types, where there's extra work to do on the output from part 1, and the total number of bytes to grab from the stream is not known in advance (which is not a problem: just call Random key generation works somewhat similarly, but part 1 is a random generator instead of processing from some inputs. In principle, derivation could be implemented by taking the code for random generation and using the derivation byte stream instead of the random generator. However, for derivation, part 2 needs to be reproducible, so it needs to consume the output of the stream in a specific way, whereas for generation it doesn't matter exactly how the output of the RNG is consumed. For ECC, the private key is indeed |
Implement
psa_key_derivation_output_key
for elliptic curve keys.The PSA specification describes exactly how to do this: draw a byte string from the stream, convert it to the target type of private key, and discard the top bits that must be 0 in the result. If it the resulting value is not in the correct range, discard and try again.
(Note that there was a change between versions 1.0.0 and 1.0.1 of the specification. Version 1.0.0 did not have a step of discarding the always-0 top bits, which made it inefficient for key sizes that are not a multiple of 8.)
The text was updated successfully, but these errors were encountered: