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 *id_cred,
32 			struct byte_array *signature_or_mac,
33 			const struct byte_array *ead, struct byte_array *prk,
34 			struct byte_array *th, struct byte_array *ciphertext,
35 			struct byte_array *plaintext);
36 
37 /**
38  * @brief 			Decrypts a ciphertext and splits the resulting
39  * 				plaintext into its components.
40  *
41  * @param ctxt 			CIPHERTEXT2, CIPHERTEXT3 or CIPHERTEXT4
42  * @param suite 		cipher suite
43  * @param[out] id_cred 		Id of the credential.
44  * @param[out] signature_or_mac Signature or a mac byte_array.
45  * @param[out] ead 		External authorization data.
46  * @param[in] prk 		Pseudo random key.
47  * @param[in] th 		Transcript hash.
48  * @param[in] ciphertext 	The input.
49  * @param[out] plaintext 	The plaintext.
50  * @return 			Ok or error code.
51  */
52 enum err ciphertext_decrypt_split(enum ciphertext ctxt, struct suite *suite,
53 				  struct byte_array *id_cred,
54 				  struct byte_array *sig_or_mac,
55 				  struct byte_array *ead,
56 				  struct byte_array *prk, struct byte_array *th,
57 				  struct byte_array *ciphertext,
58 				  struct byte_array *plaintext);
59 
60 #endif
61