-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCipherCore.cpp
More file actions
28 lines (25 loc) · 855 Bytes
/
CipherCore.cpp
File metadata and controls
28 lines (25 loc) · 855 Bytes
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
/*
* CipherCore.cpp
*
* Created on: Oct 15, 2015
* Author: nissassin17
*/
#include "CipherCore.hpp"
#include "RSAPublicKey.h"
#include "BigNum.h"
#include "Log.h"
std::vector<uint8_t> CipherCore::rsaep(const rsa::RSAPublicKey& publicKey,
const std::vector<uint8_t>& message) {
Log::info << "Rsa exponent: " << publicKey.getExponent() << endl;
Log::info << "Rsa public key (first 16 bytes): "
<< vector<uint8_t>(publicKey.getModulus().begin(),
publicKey.getModulus().begin() + 16) << endl;
Log::info << "Plain random message: " << message << endl;
vector<uint8_t> encrypted(
BigNum(message).exponent(publicKey.getExponent(),
publicKey.getModulus()).toVector());
Log::info << "Encrypted random message (first 32 bytes): "
<< vector<uint8_t>(encrypted.begin(), encrypted.begin() + 32)
<< endl;
return encrypted;
}