developer | 7043679 | 2023-05-19 09:31:20 +0800 | [diff] [blame] | 1 | #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 | |
| 21 | ENGINE *setup_engine(void); |
| 22 | void init_alog_data(void); |
| 23 | void usage(void); |
| 24 | void init_algo_data(void); |
| 25 | void do_operation(void); |
| 26 | void hex2bin(unsigned char **des, char *src, long *len); |
| 27 | void print_hex(unsigned char *str, int len); |
| 28 | void free_openssl_data(unsigned char *data); |
| 29 | |
| 30 | struct 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 | |
| 54 | struct operator { |
| 55 | int (*init)(void); |
| 56 | int (*uninit)(void); |
| 57 | int (*encrypt)(void); |
| 58 | int (*decrypt)(void); |
| 59 | int (*check)(void); |
| 60 | }; |
| 61 | |
| 62 | struct algorithm_data { |
| 63 | struct operator oper; |
| 64 | void *data; |
| 65 | } cur; |
| 66 | |
| 67 | extern struct common_data input_data; |
| 68 | |
| 69 | #endif |