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 PLAINTEXT_H 12 #define PLAINTEXT_H 13 14 #include <stdint.h> 15 16 #include "common/oscore_edhoc_error.h" 17 18 /** 19 * @brief Decodes id_cred to kid 20 * @param id_cred ID_CRED_x 21 * @param id_cred_len length of id_cred 22 * @param _kid output pointer 23 * @param kid_len length of the kid 24 */ 25 enum err id_cred2kid(const uint8_t *id_cred, uint32_t id_cred_len, 26 uint8_t *_kid, uint32_t *kid_len); 27 28 /** 29 * @brief Splits a the plaintext of message 2 to its subfields 30 * @param ptxt pointer to the paintext 31 * @param ptxt_len length of ptxt 32 * @param id_cred_x ID_CRED_x 33 * @param id_cred_x_len length of id_cred_x_len 34 * @param sign_or_mac signature or mac 35 * @param sign_or_mac_len length of sign_or_mac 36 * @param ad axillary data 37 * @param ad_len length of ad 38 */ 39 enum err plaintext_split(uint8_t *ptxt, const uint32_t ptxt_len, 40 uint8_t *id_cred_x, uint32_t *id_cred_x_len, 41 uint8_t *sign_or_mac, uint32_t *sign_or_mac_len, 42 uint8_t *ad, uint32_t *ad_len); 43 44 /** 45 * @brief Encodes a plaintext 46 * @param id_cred ID_CRED_x 47 * @param id_cred_len length of id_cred 48 * @param sign_or_mac signature or mac 49 * @param sign_or_mac_len length of sign_or_mac 50 * @param ad axillary data 51 * @param ad_len length of ad 52 * @param paintext pointer to the paintext 53 * @param paintext_len length of paintext 54 */ 55 enum err plaintext_encode(const uint8_t *id_cred, uint32_t id_cred_len, 56 const uint8_t *sgn_or_mac, uint32_t sgn_or_mac_len, 57 const uint8_t *ad, uint32_t ad_len, 58 uint8_t *plaintext, uint32_t *plaintext_len); 59 60 #endif 61