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 
12 #ifndef CIPHERTEXT_H
13 #define CIPHERTEXT_H
14 enum ciphertext { CIPHERTEXT2, CIPHERTEXT3, CIPHERTEXT4 };
15 
16 /**
17  * @brief 			Generates a ciphertext.
18  *
19  * @param ctxt 			CIPHERTEXT2, CIPHERTEXT3 or CIPHERTEXT4.
20  * @param suite 		Cipher suite.
21  * @param[in] id_cred 		Id of the credential.
22  * @param[in] signature_or_mac 	Signature or a mac byte_array.
23  * @param[in] ead 		External authorization data.
24  * @param[in] prk 		Pseudo random key.
25  * @param[in] th 		Transcript hash.
26  * @param[out] ciphertext 	The ciphertext.
27  * @param[out] plaintext 	The plaintext.
28  * @return 			Ok or error code.
29  */
30 enum err ciphertext_gen(enum ciphertext ctxt, struct suite *suite,
31 			const struct byte_array *c_r,
32                         const struct byte_array *id_cred,
33 			struct byte_array *signature_or_mac,
34 			const struct byte_array *ead, struct byte_array *prk,
35 			struct byte_array *th, struct byte_array *ciphertext,
36 			struct byte_array *plaintext);
37 
38 /**
39  * @brief 			Decrypts a ciphertext and splits the resulting
40  * 				plaintext into its components.
41  *
42  * @param ctxt 			CIPHERTEXT2, CIPHERTEXT3 or CIPHERTEXT4
43  * @param suite 		cipher suite
44  * @param c_r                   Connection identifier of the responder.
45  *                              Set this to NULL when using with CIPHERTEXT3
46  *                              or CIPHERTEXT4
47  * @param[out] id_cred 		Id of the credential.
48  * @param[out] signature_or_mac Signature or a mac byte_array.
49  * @param[out] ead 		External authorization data.
50  * @param[in] prk 		Pseudo random key.
51  * @param[in] th 		Transcript hash.
52  * @param[in] ciphertext 	The input.
53  * @param[out] plaintext 	The plaintext.
54  * @return 			Ok or error code.
55  */
56 enum err ciphertext_decrypt_split(
57 	enum ciphertext ctxt, struct suite *suite, struct byte_array *c_r,
58 	struct byte_array *id_cred, struct byte_array *sig_or_mac,
59 	struct byte_array *ead, struct byte_array *prk, struct byte_array *th,
60 	struct byte_array *ciphertext, struct byte_array *plaintext);
61 
62 #endif
63