-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcryptopp.cpp
More file actions
39 lines (28 loc) · 1.08 KB
/
Copy pathcryptopp.cpp
File metadata and controls
39 lines (28 loc) · 1.08 KB
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
#include "cryptopp.h"
#include <iostream>
void CryptoppTest::encrypt_round()
{
byte iv[CryptoPP::CIPHER::BLOCKSIZE];
::memset( key, 0x01, CryptoPP::CIPHER::DEFAULT_KEYLENGTH );
::memset( iv, 0x01, CryptoPP::CIPHER::BLOCKSIZE );
std::string cipher((const char*)out);
CBC_Mode< CAST128 >::Encryption e;
e.SetKeyWithIV(key, sizeof(key), iv, sizeof(iv));
StringSource s(in, sizeof(in), true,
new StreamTransformationFilter(e, new StringSink(cipher),
StreamTransformationFilter::NO_PADDING));
out_sz = cipher.size();
}
void CryptoppTest::decrypt_round()
{
byte iv[CryptoPP::CIPHER::BLOCKSIZE];
::memset( key, 0x01, CryptoPP::CIPHER::DEFAULT_KEYLENGTH );
::memset( iv, 0x01, CryptoPP::CIPHER::BLOCKSIZE );
std::string cipher((const char*)out, out_sz);
std::string dec((const char*)decrypted);
CBC_Mode< CAST128 >::Decryption d;
d.SetKeyWithIV(key, sizeof(key), iv, sizeof(iv));
StringSource s(cipher, true,
new StreamTransformationFilter(d, new StringSink(dec),
StreamTransformationFilter::NO_PADDING));
}