forked from FISCO-BCOS/FISCO-BCOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCryptoPP.h
69 lines (53 loc) · 2.05 KB
/
CryptoPP.h
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
This file is part of FISCO-BCOS.
FISCO-BCOS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
FISCO-BCOS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FISCO-BCOS. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file CryptoPP.h
* @author Alex Leverington <nessence@gmail.com> Asherli
* @date 2018
*
* CryptoPP headers and primitive helper methods
*/
#pragma once
#include "Common.h"
namespace dev
{
namespace crypto
{
/// Amount of bytes added when encrypting with encryptECIES.
static const unsigned c_eciesOverhead = 113;
/**
* CryptoPP secp256k1 algorithms.
* @todo Collect ECIES methods into class.
*/
class Secp256k1PP
{
public:
static Secp256k1PP* get();
/// Encrypts text (replace input). (ECIES w/XOR-SHA1)
void encrypt(Public const& _k, bytes& io_cipher);
/// Decrypts text (replace input). (ECIES w/XOR-SHA1)
void decrypt(Secret const& _k, bytes& io_text);
/// Encrypts text (replace input). (ECIES w/AES128-CTR-SHA256)
void encryptECIES(Public const& _k, bytes& io_cipher);
/// Encrypts text (replace input). (ECIES w/AES128-CTR-SHA256)
void encryptECIES(Public const& _k, bytesConstRef _sharedMacData, bytes& io_cipher);
/// Decrypts text (replace input). (ECIES w/AES128-CTR-SHA256)
bool decryptECIES(Secret const& _k, bytes& io_text);
/// Decrypts text (replace input). (ECIES w/AES128-CTR-SHA256)
bool decryptECIES(Secret const& _k, bytesConstRef _sharedMacData, bytes& io_text);
bool agree(Secret const& _s, Public const& _r, Secret& o_s);
private:
Secp256k1PP() = default;
};
} // namespace crypto
} // namespace dev