[Request] Allow generation of secrets of arbitrary size
PhilippGackstatter opened this issue · comments
Description
Provide a procedure that can generate secrets of arbitrary size.
Motivation
Currently, procedures::GenerateKey
takes a KeyType
and generates a key of appropriate size. However, for some encryption operations, a key of some other length might be required that is not covered by those KeyType
s. For instance, when generating a random encryption key for use with Aes256Gcm
, then a key of length crypto::ciphers::aes::Aes256Gcm::KEY_LENGTH
is required. This happens to be the same as the size of an X25519
private key, so we can currently hack around it that way. But a proper solution would be to offer a procedure that takes a len: usize
or extend the KeyType
enum to cover all possible use cases stronghold currently offers.
Requirements
Write a list of what you want this feature to do.
- Add a new procedure (or rewrite
GenerateKey
and add aKeyType::key_length
method that returns the key size for the enum variants) that takes alen: usize
andlocation: Location
and writeslen
random bytes tolocation
.
Open questions (optional)
Unclear if rewriting GenerateKey
is the way to go, or if another procedure should be added.
Are you planning to do it yourself in a pull request?
Possibly.