Debian Codegraph @

tests/aes.cpp

raw
1 /*
2 * Copyright © 2018 Simon Désaulniers
3 * Author: Simon Désaulniers <[email protected]>
4 *
5 * This file is part of dpaste.
6 *
7 * dpaste is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * dpaste is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with dpaste. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include <memory>
22
23 #include <catch.hpp>
24
25 #include "cipher.h"
26 #include "aescrypto.h"
27
28 namespace dpaste {
29 namespace tests {
30
31 TEST_CASE("AES process plain/cipher text", "[AES][processPlainText][processCipherText]") {
32 crypto::AES aes {};
33 std::vector<uint8_t> data {0,1,2,3,4};
34 auto pwd = "this_is_a_really_good_pwd";
35 auto p = std::make_shared<crypto::Parameters>();
36 auto pp = p;
37 p->emplace<crypto::AESParameters>(pwd);
38
39 auto ct = aes.processPlainText(data, std::move(p));
40 REQUIRE ( not ct.empty() );
41
42 auto pt = aes.processCipherText(ct, std::move(pp));
43 REQUIRE ( pt == data );
44 }
45
46 } /* tests */
47 } /* dpaste */
48
49 /* vim: set ts=4 sw=4 tw=120 et :*/
50