X-Git-Url: http://www.wagner.pp.ru/gitweb/?p=openssl-gost%2Fengine.git;a=blobdiff_plain;f=gost89.h;h=f8a83bbb9d47a5a03eb0ea51ab3c5483a7cc88f9;hp=59a938fa311cc69a934befbefb93ebee3c6cd625;hb=HEAD;hpb=0ee4f8fc839278672e47213549bfb152ad3d2654 diff --git a/gost89.h b/gost89.h index 59a938f..f8a83bb 100644 --- a/gost89.h +++ b/gost89.h @@ -33,7 +33,9 @@ typedef struct { /* Cipher context includes key and preprocessed substitution block */ typedef struct { - u4 k[8]; + u4 master_key[8]; + u4 key[8]; + u4 mask[8]; /* Constant s-boxes -- set up in gost_init(). */ u4 k87[256], k65[256], k43[256], k21[256]; } gost_ctx; @@ -43,9 +45,9 @@ typedef struct { * Other modes may be added easily enough. */ /* Encrypt several full blocks in ECB mode */ -void gost_enc(gost_ctx * ctx, const byte * clear, byte * cipher, int blocks); +void gost_enc(gost_ctx * c, const byte * clear, byte * cipher, int blocks); /* Decrypt several full blocks in ECB mode */ -void gost_dec(gost_ctx * ctx, const byte * cipher, byte * clear, int blocks); +void gost_dec(gost_ctx * c, const byte * cipher, byte * clear, int blocks); /* Encrypts several full blocks in CFB mode using 8byte IV */ void gost_enc_cfb(gost_ctx * ctx, const byte * iv, const byte * clear, byte * cipher, int blocks); @@ -57,29 +59,37 @@ void gost_dec_cfb(gost_ctx * ctx, const byte * iv, const byte * cipher, void gostcrypt(gost_ctx * c, const byte * in, byte * out); /* Decrypt one block */ void gostdecrypt(gost_ctx * c, const byte * in, byte * out); +/* Encrypt one block */ +void magmacrypt(gost_ctx * c, const byte * in, byte * out); +/* Decrypt one block */ +void magmadecrypt(gost_ctx * c, const byte * in, byte * out); /* Set key into context */ -void gost_key(gost_ctx * ctx, const byte * key); +void gost_key(gost_ctx * c, const byte * k); +/* Set key into context without key mask */ +void gost_key_nomask(gost_ctx * c, const byte * k); /* Set key into context */ -void magma_key(gost_ctx * ctx, const byte * key); +void magma_key(gost_ctx * c, const byte * k); +/* Set master 256-bit key to be used in TLSTREE calculation into context */ +void magma_master_key(gost_ctx *c, const byte *k); /* Get key from context */ -void gost_get_key(gost_ctx * ctx, byte * key); +void gost_get_key(gost_ctx * c, byte * k); /* Set S-blocks into context */ -void gost_init(gost_ctx * ctx, const gost_subst_block * subst_block); +void gost_init(gost_ctx * c, const gost_subst_block * b); /* Clean up context */ -void gost_destroy(gost_ctx * ctx); +void gost_destroy(gost_ctx * c); /* Intermediate function used for calculate hash */ void gost_enc_with_key(gost_ctx *, byte * key, byte * inblock, byte * outblock); /* Compute MAC of given length in bits from data */ -int gost_mac(gost_ctx * ctx, int hmac_len, const unsigned char *data, - unsigned int data_len, unsigned char *hmac); +int gost_mac(gost_ctx * ctx, int mac_len, const unsigned char *data, + unsigned int data_len, unsigned char *mac); /* * Compute MAC of given length in bits from data, using non-zero 8-byte IV * (non-standard, for use in CryptoPro key transport only */ -int gost_mac_iv(gost_ctx * ctx, int hmac_len, const unsigned char *iv, +int gost_mac_iv(gost_ctx * ctx, int mac_len, const unsigned char *iv, const unsigned char *data, unsigned int data_len, - unsigned char *hmac); + unsigned char *mac); /* Perform one step of MAC calculation like gostcrypt */ void mac_block(gost_ctx * c, byte * buffer, const byte * block); /* Extracts MAC value from mac state buffer */ @@ -97,5 +107,8 @@ extern gost_subst_block Gost28147_CryptoProParamSetD; extern gost_subst_block Gost28147_TC26ParamSetZ; extern const byte CryptoProKeyMeshingKey[]; typedef unsigned int word32; - +/* For tests. */ +void kboxinit(gost_ctx * c, const gost_subst_block * b); +void magma_get_key(gost_ctx * c, byte * k); +void acpkm_magma_key_meshing(gost_ctx * ctx); #endif