-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.h
More file actions
137 lines (103 loc) · 3.47 KB
/
Copy pathmainwindow.h
File metadata and controls
137 lines (103 loc) · 3.47 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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QFileDialog>
#include <QMessageBox>
#include <QProcess>
#include <openssl/conf.h>
#include <openssl/evp.h>
#include <openssl/err.h>
#include <openssl/rsa.h>
#include <openssl/pem.h>
#include <math.h>
#include <string.h>
#include <stdio.h>
//#include <stdlib.h>
#include "crypto.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private slots:
void on_pushButtonRsaPublicKey_clicked();
void on_pushButtonRsaPrivateKey_clicked();
void on_pushButtonInputFile_clicked();
void on_pushButtonOutputFile_clicked();
void on_radioButtonRsaPrivateKey_clicked();
void on_radioButtonRsaPublicKey_clicked();
void on_pushButtonRsaEncrypt_clicked();
void on_pushButtonRsaDecrypt_clicked();
void on_pushButtonGenerateKey_clicked();
void on_pushButtonGenerateIV_clicked();
void on_pushButtonSymmetricEncrypt_clicked();
void on_comboBoxMode_currentIndexChanged(int index);
void on_pushButtonSymmetricDecrypt_clicked();
void on_pushButtonGenerateIV_2_clicked();
void on_pushButtonRsaPublicKey_2_clicked();
void on_pushButtonSymmetricEncrypt_2_clicked();
void on_pushButtonSelectKey_clicked();
void on_pushButtonSaveKey_clicked();
void on_pushButtonSymmetricDecrypt_2_clicked();
void on_comboBoxMode_2_currentIndexChanged(int index);
private:
void initOpenSsl();
void handleErrors();
int encrypt(unsigned char *plaintext, int plaintext_len, unsigned char *key,
unsigned char *iv, unsigned char *ciphertext);
int decrypt(unsigned char *ciphertext, int ciphertext_len, unsigned char *key,
unsigned char *iv, unsigned char *plaintext);
void updateRsaKeyMode();
void runRsaOperation(int operation, int key_type);
void prepareSymmetricOperation(int operation);
void runSymmetricOperation(int operation,
int cipher, int mode, unsigned char *key,
unsigned char *iv);
void encryptSymmetric(int operation, int cipher, int mode, unsigned char *key,
unsigned char *iv);
void decryptSymmetric(int operation, int cipher, int mode, unsigned char *key,
unsigned char *iv);
int getKeyLength(int cipher);
int getIvLength(int cipher);
int getCipherFromUi();
int getModeFromUi();
int getCipherFromUi2();
int getModeFromUi2();
EVP_CIPHER* getEvpCipher(int cipher, int mode);
int envelope_seal(EVP_PKEY **pub_key, unsigned char *plaintext, int plaintext_len,
unsigned char **encrypted_key, int *encrypted_key_len, unsigned char *iv,
unsigned char *ciphertext);
int envelope_open(EVP_PKEY *priv_key, unsigned char *ciphertext, int ciphertext_len,
unsigned char *encrypted_key, int encrypted_key_len, unsigned char *iv,
unsigned char *plaintext);
Ui::MainWindow *ui;
int mRSAKeyType;
enum Cipher {
CIPHER_DES = 1,
CIPHER_3DES2,
CIPHER_3DES3,
CIPHER_AES128,
CIPHER_AES192,
CIPHER_AES256,
CIPHER_RSA
};
enum BlockMode {
MODE_CBC = 1,
MODE_ECB,
MODE_CFB,
MODE_OFB
};
enum Operation {
ENCRYPT = 1,
DECRYPT
};
enum RsaKeyType {
RSA_PUBLIC_KEY = 1,
RSA_PRIVATE_KEY
};
};
#endif // MAINWINDOW_H