This class parses a recipe string on construction and then exposes the Recipe JSON Universal Fields as fields of this class.
More...
#include <recipe.hpp>
This class parses a recipe string on construction and then exposes the Recipe JSON Universal Fields as fields of this class.
◆ Recipe()
| Recipe::Recipe |
( |
const std::string & |
recipe, |
|
|
const RecipeJson::type |
typeRequired = RecipeJson::type::_INVALID_TYPE_ |
|
) |
| |
Create a Recipe class from the JSON representation of the key generation options.
- Parameters
-
| recipe | The JSON formatted recipe object to parse as specified by JSON Format for Recipes |
| typeRequired | The required type, which will be the default if the JSON doesn't contain a type field and which will cause an exception to be thrown if the JSON has a conflicting type. If not set (default: RecipeJson::type::INVALID_TYPE) there is no required type and any type is allowed. |
- Exceptions
-
◆ derivePrimarySecret() [1/2]
| const SodiumBuffer Recipe::derivePrimarySecret |
( |
const std::string & |
seedString, |
|
|
const RecipeJson::type |
defaultType = RecipeJson::type::_INVALID_TYPE_ |
|
) |
| const |
This function derives the master secrets for SymmetricKey, for the SealingKey and UnsealingKey pair, for the SignatureVerificationKey and SigningKey pair, and for the general-purpose Secret class.
It applies the hash function specified in the recipe to a preimage of the following form:
where type is converted to a string in ["Secret", "SymmetricKey", "UnsealingKey", "SigningKey"], based on the value of the type parameter, defaultType if type is not set (INVALID_TYPE), or "" if neither is set (both are INVALID_TYPE).
- For "Secret" and "Password", the generated secret is placed directly into the
secretBytes field of the Secret class.
- For "SymmetricKey", the generated secret becomes the
keyBytes field of the SymmetricKey class.
- For "UnsealingKey", the generated secret is the final parameter (input) to libsodium's
crypto_box_seed_keypair function, which generates the key bytes for the UnsealingKey and SealingKey.
- For "SigningKey", the generated secret is the final parameter (input) to libsodium's
crypto_sign_seed_keypair function, which generates the key bytes for the SigningKey and SignatureVerificationKey..
- Parameters
-
| seedString | A seed value that is the primary salt for the hash function |
| defaultType | If the recipe has a type field, and that field specifies a value other than this typeRequired value, this function will throw an InvalidRecipeValueException. |
- Returns
- const SodiumBuffer The derived secret, set to always be a const so that it is never modified directly.
- Exceptions
-
◆ derivePrimarySecret() [2/2]
| const SodiumBuffer Recipe::derivePrimarySecret |
( |
const std::string & |
seedString, |
|
|
const std::string & |
recipe, |
|
|
const RecipeJson::type |
typeRequired = RecipeJson::type::_INVALID_TYPE_, |
|
|
const size_t |
lengthInBytesRequired = 0 |
|
) |
| |
|
static |
This function derives the master secrets for SymmetricKey, for the SealingKey and UnsealingKey pair, for the SignatureVerificationKey and SigningKey pair, and for the general-purpose Secret class.
It applies the hash function specified in the recipe to a preimage of the following form:
<seedString> +
'\0' + <typeRequired> + <
recipe>
where typeRequired is converted to a string in ["Secret", "SymmetricKey", "UnsealingKey", "SigningKey"], based on the value of the typeRequired parameter.
- For "Secret", the generated secret is placed directly into the
secretBytes field of the Secret class.
- For "SymmetricKey", the generated secret becomes the
keyBytes field of the SymmetricKey class.
- For "UnsealingKey", the generated secret is the final parameter (input) to libsodium's
crypto_box_seed_keypair function, which generates the key bytes for the UnsealingKey and SealingKey.
- For "SigningKey", the generated secret is the final parameter (input) to libsodium's
crypto_sign_seed_keypair function, which generates the key bytes for the SigningKey and SignatureVerificationKey..
- Parameters
-
| seedString | A seed value that is the primary salt for the hash function |
| recipe | The recipe in JSON Format for Recipes. |
| typeRequired | If the recipe has a type field, and that field specifies a value other than this typeRequired value, this function will throw an InvalidRecipeValueException. |
| lengthInBytesRequired | If the recipe does not specify a lengthInBytes, generate a secret of this length. Throw an InvalidRecipeValueException is the lengthInBytes it specifies does not match this value. |
- Returns
- const SodiumBuffer The derived secret, set to always be a const so that it is never modified directly.
- Exceptions
-
◆ recipeWithAllOptionalParametersSpecified()
| const std::string Recipe::recipeWithAllOptionalParametersSpecified |
( |
int |
indent = -1, |
|
|
const char |
indent_char = ' ' |
|
) |
| const |
Return JSON with default parameters filled in.
- Parameters
-
| indent | JSON indent depth |
| indent_char | The char used for JSON indenting |
The documentation for this class was generated from the following files:
- C:/Users/stuar/git/dicekeys-seeded-crypto/lib-seeded/recipe.hpp
- C:/Users/stuar/git/dicekeys-seeded-crypto/lib-seeded/recipe.cpp