Zero Trust IoT library
Loading...
Searching...
No Matches
zt-encryption-utils.h
Go to the documentation of this file.
1// zt-encryption-utils.h
2#ifndef ZT_ENCRYPTION_UTILS_H
3#define ZT_ENCRYPTION_UTILS_H
4
5#include <string>
6#include <cryptopp/aes.h>
7#include <cryptopp/modes.h>
8#include <cryptopp/filters.h>
9#include <cryptopp/osrng.h>
10#include <cryptopp/hex.h>
11#include <cryptopp/secblock.h>
12#include <cryptopp/config.h>
13
14namespace ns3 {
15
24std::string EncryptPayload(const std::string& data, const CryptoPP::byte* key, std::string& ivOut);
25
33std::string DecryptPayload(const std::string& cipher, const CryptoPP::byte* key);
34
41CryptoPP::SecByteBlock HexDecodeKey(const std::string& hex);
42
49std::vector<CryptoPP::byte> HexToBytes(const std::string& hex);
50
51} // namespace ns3
52
53#endif // ZT_ENCRYPTION_UTILS_H
54
std::string EncryptPayload(const std::string &data, const byte *key, std::string &ivOut)
Encrypts a plaintext string using AES-CBC mode with a randomly generated IV.
std::vector< CryptoPP::byte > HexToBytes(const std::string &hex)
Converts a hexadecimal string into a byte vector.
std::string DecryptPayload(const std::string &cipher, const byte *key)
Decrypts a ciphertext string encrypted with EncryptPayload.
SecByteBlock HexDecodeKey(const std::string &hex)
Decodes a hex-encoded AES key string into a raw key byte block.