RabbitCommon v2.3.3
Loading...
Searching...
No Matches
EvpAES.h
1// Copyright Copyright (c) Kang Lin studio, All Rights Reserved
2// Author Kang Lin <kl222@126.com>
3// https://gitee.com/bailiyang/cdemo/tree/master/Qt/49OpenSSL/OpenSSL/Cipher
4// DES加密算法中,ECB和CBC模式有什么区别 https://blog.51cto.com/u_15060462/4692785
5
6#ifndef EVPAES_H
7#define EVPAES_H
8
9#include <QByteArray>
10
11struct evp_cipher_ctx_st;
12typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX;
13
14struct evp_cipher_st;
15typedef struct evp_cipher_st EVP_CIPHER;
16
22class EvpAES
23{
24public:
25 EvpAES();
26 ~EvpAES();
27
28 bool ecb_encrypt(const QByteArray& in, QByteArray& out,
29 const QByteArray &key, bool enc = true);
30 bool cbc_encrypt(const QByteArray& in, QByteArray& out,
31 const QByteArray &key, const QByteArray& ivec,
32 bool enc = true);
33 bool cfb1_encrypt(const QByteArray& in, QByteArray& out,
34 const QByteArray &key, const QByteArray& ivec,
35 bool enc = true);
36 bool cfb8_encrypt(const QByteArray& in, QByteArray& out,
37 const QByteArray &key, const QByteArray& ivec,
38 bool enc = true);
39 bool cfb128_encrypt(const QByteArray& in, QByteArray& out,
40 const QByteArray &key, const QByteArray& ivec,
41 bool enc = true);
42 bool ofb128_encrypt(const QByteArray& in, QByteArray& out,
43 const QByteArray &key, const QByteArray& ivec,
44 bool enc = true);
45 bool ctr_encrypt(const QByteArray& in, QByteArray& out,
46 const QByteArray &key, const QByteArray& ivec,
47 bool enc = true);
48 bool gcm_encrypt(const QByteArray& in, QByteArray& out,
49 const QByteArray &key, const QByteArray& ivec,
50 bool enc = true);
51 bool xts_encrypt(const QByteArray& in, QByteArray& out,
52 const QByteArray &key, const QByteArray& ivec,
53 bool enc = true);
54 bool ocb_encrypt(const QByteArray& in, QByteArray& out,
55 const QByteArray &key, const QByteArray& ivec,
56 bool enc = true);
57
58private:
59 bool encrypt(const QByteArray& in, QByteArray& out,
60 const QByteArray& key, const QByteArray& ivec,
61 const EVP_CIPHER *cipher, bool enc = true);
62
63 //TODO: only install the dependencies libraries(libssl)
64 int testSSL();
65
66private:
67 EVP_CIPHER_CTX *ctx;
68};
69
70#endif // EVPAES_H
The EvpAES class.
Definition EvpAES.h:23