]> www.wagner.pp.ru Git - openssl-gost/engine.git/blob - gost_grasshopper_cipher.h
Remove unneeded declarations after registration rework
[openssl-gost/engine.git] / gost_grasshopper_cipher.h
1 /*
2  * Maxim Tishkov 2016
3  * This file is distributed under the same license as OpenSSL
4  */
5
6 #ifndef GOST_GRASSHOPPER_CIPHER_H
7 #define GOST_GRASSHOPPER_CIPHER_H
8
9 #if defined(__cplusplus)
10 extern "C" {
11 #endif
12
13 #include "gost_grasshopper_defines.h"
14
15 #include <openssl/evp.h>
16
17 // not thread safe
18 // because of buffers
19 typedef struct {
20     uint8_t type;
21     grasshopper_key_t master_key;
22     grasshopper_key_t key;
23     grasshopper_round_keys_t encrypt_round_keys;
24     grasshopper_round_keys_t decrypt_round_keys;
25     grasshopper_w128_t buffer;
26 } gost_grasshopper_cipher_ctx;
27
28 typedef struct {
29     gost_grasshopper_cipher_ctx c;
30     grasshopper_w128_t partial_buffer;
31     unsigned int section_size;  /* After how much bytes mesh the key,
32                                    if 0 never mesh and work like plain ctr. */
33     unsigned char kdf_seed[8];
34                 unsigned char tag[16];
35                 EVP_MD_CTX *omac_ctx;
36 } gost_grasshopper_cipher_ctx_ctr;
37
38 void gost_grasshopper_cipher_key(gost_grasshopper_cipher_ctx* c, const uint8_t* k);
39
40 void gost_grasshopper_cipher_destroy(gost_grasshopper_cipher_ctx* c);
41
42 int gost_grasshopper_cipher_init_ecb(EVP_CIPHER_CTX* ctx, const unsigned char* key, const unsigned char* iv, int enc);
43
44 int gost_grasshopper_cipher_init_cbc(EVP_CIPHER_CTX* ctx, const unsigned char* key, const unsigned char* iv, int enc);
45
46 int gost_grasshopper_cipher_init_ofb(EVP_CIPHER_CTX* ctx, const unsigned char* key, const unsigned char* iv, int enc);
47
48 int gost_grasshopper_cipher_init_cfb(EVP_CIPHER_CTX* ctx, const unsigned char* key, const unsigned char* iv, int enc);
49
50 int gost_grasshopper_cipher_init_ctr(EVP_CIPHER_CTX* ctx, const unsigned char* key, const unsigned char* iv, int enc);
51
52 int gost_grasshopper_cipher_init_ctracpkm(EVP_CIPHER_CTX* ctx, const unsigned char* key, const unsigned char* iv, int enc);
53
54 int gost_grasshopper_cipher_init_ctracpkm_omac(EVP_CIPHER_CTX* ctx, const unsigned char* key, const unsigned char* iv, int enc);
55
56 int gost_grasshopper_cipher_init(EVP_CIPHER_CTX* ctx, const unsigned char* key,
57                                  const unsigned char* iv, int enc);
58
59 int gost_grasshopper_cipher_do(EVP_CIPHER_CTX* ctx, unsigned char* out,
60                                const unsigned char* in, size_t inl);
61
62 int gost_grasshopper_cipher_do_ecb(EVP_CIPHER_CTX* ctx, unsigned char* out,
63                                    const unsigned char* in, size_t inl);
64
65 int gost_grasshopper_cipher_do_cbc(EVP_CIPHER_CTX* ctx, unsigned char* out,
66                                    const unsigned char* in, size_t inl);
67
68 int gost_grasshopper_cipher_do_ofb(EVP_CIPHER_CTX* ctx, unsigned char* out,
69                                    const unsigned char* in, size_t inl);
70
71 int gost_grasshopper_cipher_do_cfb(EVP_CIPHER_CTX* ctx, unsigned char* out,
72                                    const unsigned char* in, size_t inl);
73
74 int gost_grasshopper_cipher_do_ctr(EVP_CIPHER_CTX* ctx, unsigned char* out,
75                                    const unsigned char* in, size_t inl);
76 int gost_grasshopper_cipher_do_ctracpkm(EVP_CIPHER_CTX* ctx, unsigned char* out,
77                                    const unsigned char* in, size_t inl);
78 int gost_grasshopper_cipher_do_ctracpkm_omac(EVP_CIPHER_CTX* ctx, unsigned char* out,
79                                    const unsigned char* in, size_t inl);
80
81 int gost_grasshopper_cipher_cleanup(EVP_CIPHER_CTX* ctx);
82
83 int gost_grasshopper_set_asn1_parameters(EVP_CIPHER_CTX* ctx, ASN1_TYPE* params);
84
85 int gost_grasshopper_get_asn1_parameters(EVP_CIPHER_CTX* ctx, ASN1_TYPE* params);
86
87 int gost_grasshopper_cipher_ctl(EVP_CIPHER_CTX* ctx, int type, int arg, void* ptr);
88
89 const EVP_CIPHER* cipher_gost_grasshopper_ctracpkm();
90
91 #if defined(__cplusplus)
92 }
93 #endif
94
95 #endif