This commit is contained in:
		| @@ -133,19 +133,7 @@ struct kdf_config final { | ||||
|   [[nodiscard]] auto create_subkey(kdf_context ctx, std::size_t unique_id_, | ||||
|                                    const hash_t &master_key) const | ||||
|       -> std::pair<hash_t, kdf_config> { | ||||
|     REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|     hash_t sub_key; | ||||
|     auto res = crypto_kdf_derive_from_key( | ||||
|         sub_key.data(), sub_key.size(), unique_id_, | ||||
|         get_kdf_context_name(ctx).data(), master_key.data()); | ||||
|     if (res != 0) { | ||||
|       throw repertory::utils::error::create_exception( | ||||
|           function_name, { | ||||
|                              "failed to create sub-key", | ||||
|                              std::to_string(res), | ||||
|                          }); | ||||
|     } | ||||
|     auto sub_key = derive_subkey<hash_t>(ctx, unique_id_, master_key); | ||||
|  | ||||
|     auto cfg = *this; | ||||
|     cfg.unique_id = unique_id_; | ||||
| @@ -154,18 +142,19 @@ struct kdf_config final { | ||||
|   } | ||||
|  | ||||
|   template <typename hash_t> | ||||
|   [[nodiscard]] auto recreate_subkey(kdf_context ctx, | ||||
|                                      const hash_t &master_key) const -> hash_t { | ||||
|   [[nodiscard]] static auto derive_subkey(kdf_context ctx, | ||||
|                                           std::size_t unique_id_, | ||||
|                                           const hash_t &master_key) -> hash_t { | ||||
|     REPERTORY_USES_FUNCTION_NAME(); | ||||
|  | ||||
|     hash_t sub_key; | ||||
|     hash_t sub_key{}; | ||||
|     auto res = crypto_kdf_derive_from_key( | ||||
|         sub_key.data(), sub_key.size(), unique_id, | ||||
|         sub_key.data(), sub_key.size(), unique_id_, | ||||
|         get_kdf_context_name(ctx).data(), master_key.data()); | ||||
|     if (res != 0) { | ||||
|       throw repertory::utils::error::create_exception( | ||||
|           function_name, { | ||||
|                              "failed to recreate sub-key", | ||||
|                              "failed to derive sub-key", | ||||
|                              std::to_string(res), | ||||
|                          }); | ||||
|     } | ||||
| @@ -173,6 +162,12 @@ struct kdf_config final { | ||||
|     return sub_key; | ||||
|   } | ||||
|  | ||||
|   template <typename hash_t> | ||||
|   [[nodiscard]] auto recreate_subkey(kdf_context ctx, | ||||
|                                      const hash_t &master_key) const -> hash_t { | ||||
|     return derive_subkey<hash_t>(ctx, unique_id, master_key); | ||||
|   } | ||||
|  | ||||
|   [[nodiscard]] static auto from_header(data_cspan data, kdf_config &cfg, | ||||
|                                         bool ignore_checksum = false) -> bool; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user