1 /* 2 Copyright (c) 2021 Fraunhofer AISEC. See the COPYRIGHT 3 file at the top-level directory of this distribution. 4 5 Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or 6 http://www.apache.org/licenses/LICENSE-2.0> or the MIT license 7 <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your 8 option. This file may not be copied, modified, or distributed 9 except according to those terms. 10 */ 11 #ifndef TH_H 12 #define TH_H 13 14 #include "suites.h" 15 16 #include "common/byte_array.h" 17 #include "common/oscore_edhoc_error.h" 18 19 /** 20 * @brief Calculates transcript hash TH2 21 * TH_2 = H( G_Y, H(message_1) ). 22 * 23 * @param alg Hash algorithm to be used. 24 * @param[in] msg1_hash Hash of Message 1. 25 * @param[in] g_y Public DH parameter. 26 * @param[out] th2 The result. 27 * @retval Ok or error. 28 */ 29 enum err th2_calculate(enum hash_alg alg, struct byte_array *msg1_hash, 30 struct byte_array *g_y, 31 struct byte_array *th2); 32 33 /** 34 * @brief Calculates transcript hash th3/th4 35 * TH_3 = H(TH_2, PLAINTEXT_2) 36 * TH_4 = H(TH_3, PLAINTEXT_3) 37 * 38 * @param alg Hash algorithm to be used. 39 * @param[in] th23 th2 ot th3. 40 * @param[in] plaintext_23 Plaintext 2 or plaintext 3. 41 * @param[in] cred The credential. 42 * @param[out] th34 The result. 43 */ 44 enum err th34_calculate(enum hash_alg alg, struct byte_array *th23, 45 struct byte_array *plaintext_23, 46 const struct byte_array *cred, struct byte_array *th34); 47 48 #endif 49