iotaledger / stronghold.rs

Stronghold is a secret management engine written in rust.

Home Page:https://wiki.iota.org/stronghold.rs/getting_started

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[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 KeyTypes. 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.

  1. Add a new procedure (or rewrite GenerateKey and add a KeyType::key_length method that returns the key size for the enum variants) that takes a len: usize and location: Location and writes len random bytes to location.

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.