forked from gadial/ECC
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cmd.h
109 lines (91 loc) · 1.99 KB
/
cmd.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
* cmd.h
*
* Created on: Feb 17, 2010
* Author: bhess
*
* This class represents the command line options
* for the Elliptic curve program
*/
#ifndef CMD_H_
#define CMD_H_
using namespace std;
#include "elgamal.h"
#include <iostream>
class Cmd {
public:
Cmd(int argc, char** argv);
/*
* Encrypts the message given by a file path 'file_name'
* Encodes the message to points on the EC
*
* Output: ciphertext-points (in compressed format), line by line
* as 'file_name'.enc
*/
void encrypt_message(string file_name);
/*
* Decrypts a given file with ciphertext-points
*
* Output: the original plaintext as 'file_name'.dec
*/
void decrypt_message(string file_name);
/*
* Generates a random keypair.
*
* The generated files include the EC definition
*
* Output (public_key_'time'.txt, private_key_'time'.txt)
*
* 1. line: prime/binary curve
* 2. line: Elliptic curve modulus
* 3. line: parameter 'a' of elliptic curve
* 4. line: parameter 'b' of elliptic curve
* 5. line: point on elliptic curve (compressed format)
* 6. line: EC order
* 7. line: public key / private key
*/
void gen_random_keypair();
/*
* Using an existing public key file
*/
void use_public_key(string file_name);
/*
* Using an existing private key file
*/
void use_private_key(string file_name);
void print_usage();
void execute();
bool do_tests;
virtual ~Cmd();
ECC_ElGamal* elg;
private:
/*
* using the definition of an elliptic curve
*
* initializes elg
*/
Ellipticcurve* use_elliptic_curve(ifstream& in);
/*
* writes the definition of the elliptic curve to the out-stream
*/
void write_elliptic_curve(ofstream& out);
bool pk;
string pk_path;
bool sk;
string sk_path;
bool gen_key;
bool enc;
string enc_path;
bool dec;
string dec_path;
bool ec_rand;
bool ec_prime;
string ec_name;
bool print_usg;
bool validate;
string validation_path;
bool use_predefined_curve;
bool use_ec;
string use_ec_path;
};
#endif /* CMD_H_ */