forked from azadkuh/mbedcrypto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpk_common.hpp
48 lines (39 loc) · 1.31 KB
/
pk_common.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/** @file pk_common.hpp
*
* @copyright (C) 2016
* @date 2016.05.14
* @version 1.0.0
* @author amir zamani <[email protected]>
*
*/
#ifndef __PK_COMMON_HPP__
#define __PK_COMMON_HPP__
#include "mbedcrypto/ecp.hpp"
#include "mbedcrypto/rsa.hpp"
#include "mbedcrypto/tcodec.hpp"
#include "generator.hpp"
#include <iostream>
///////////////////////////////////////////////////////////////////////////////
namespace tests {
///////////////////////////////////////////////////////////////////////////////
inline std::ostream&
operator<<(std::ostream& s, const mbedcrypto::pk::action_flags& f) {
auto bs = [](bool b) { return b ? "true" : "false"; };
s << "encrypt: " << bs(f.encrypt) << " , "
<< "decrypt: " << bs(f.decrypt) << " , "
<< "sign: " << bs(f.sign) << " , "
<< "verify: " << bs(f.verify);
return s;
}
inline void
dumper(const char* name, const mbedcrypto::mpi& mpi) {
using namespace mbedcrypto;
std::cout << name << ": (size = "
<< mpi.size() << " , " << mpi.bitlen() << ")\n"
<< mpi.to_string(16) << "\n"
<< to_hex(mpi.dump()) << std::endl;
}
///////////////////////////////////////////////////////////////////////////////
} // namespace tests
///////////////////////////////////////////////////////////////////////////////
#endif // __PK_COMMON_HPP__