blob: d0d3979fb6a039cc5b1098a9c927ce3900f772e2 [file] [log] [blame]
developer70436792023-05-19 09:31:20 +08001#ifndef COMMON_H
2#define COMMON_H
3#include <stddef.h>
4#define DECRYPT 0
5#define ENCRYPT 1
6#define GCM 0
7#define CCM 1
8
9#include <openssl/bio.h>
10#include <openssl/evp.h>
11#include <openssl/engine.h>
12#include <openssl/x509.h>
13#include <openssl/x509v3.h>
14#include <openssl/pem.h>
15#include <openssl/pkcs12.h>
16#include <openssl/safestack.h>
17#include <openssl/err.h>
18#include <openssl/bn.h>
19#include <openssl/ssl.h>
20
21ENGINE *setup_engine(void);
22void init_alog_data(void);
23void usage(void);
24void init_algo_data(void);
25void do_operation(void);
26void hex2bin(unsigned char **des, char *src, long *len);
27void print_hex(unsigned char *str, int len);
28void free_openssl_data(unsigned char *data);
29
30struct common_data {
31 char *key;
32 char *iv;
33 char *pt;
34 char *add;
35 char *ct;
36 char *tag;
37 char *nonce;
38 char *adata;
39 char *payload;
40 int key_len;
41 int iv_len;
42 int pt_len;
43 int add_len;
44 int ct_len;
45 int tag_len;
46 int nonce_len;
47 int adata_len;
48 int payload_len;
49 int algo;
50 int oper;
51 int tag_output_size;
52};
53
54struct operator {
55 int (*init)(void);
56 int (*uninit)(void);
57 int (*encrypt)(void);
58 int (*decrypt)(void);
59 int (*check)(void);
60};
61
62struct algorithm_data {
63 struct operator oper;
64 void *data;
65} cur;
66
67extern struct common_data input_data;
68
69#endif