summaryrefslogtreecommitdiff
path: root/cipher/mac-internal.h
diff options
context:
space:
mode:
authorDmitry Baryshkov <dbaryshkov@gmail.com>2020-03-21 22:33:51 +0300
committerJussi Kivilinna <jussi.kivilinna@iki.fi>2020-04-19 21:57:53 +0300
commit45f21f871982753716d4a7676d948e8c7d644db5 (patch)
tree5451d3ae4d1eb6f7dd18f41d7946380be1c41f07 /cipher/mac-internal.h
parentd7fa70ed9ddc6e0189a8b59016b1f17717a26865 (diff)
downloadlibgcrypt-45f21f871982753716d4a7676d948e8c7d644db5.tar.gz
gost28147: implement special MAC mode called imitovstavka (IMIT)
* src/gcrypt.h.in (GCRY_MAC_GOST28147_IMIT): New. * cipher/gost28147.c (gost_imit_open, gost_imit_close) (gost_imit_setkey, gost_imit_setiv, gost_imit_reset, _gost_imit_block) (gost_imit_block, gost_imit_write, gost_imit_finish, gost_imit_read) (gost_imit_verify, gost_imit_get_maclen, gost_imit_get_keylen) (gost_imit_set_extra_info): New functions implementing GOST 28147-89 MAC (imitovstavka, IMIT) mode. * cipher/gost28147.c (gost_imit_ops) (_gcry_mac_type_spec_gost28147_imit): declare GOST 28147-89 IMIT handler. * cipher/mac-internal.h (gcry_mac_handle): add fields to support GOST 28147-89 IMIT mode. * cipher/mac.c (mac_list): add _gcry_mac_type_spec_gost28147_imit. (spec_from_algo): handle GCRY_MAC_GOST28147_IMIT. * tests/basic.c (check_mac): add GOST28147-89 IMIT test vector. -- GOST 28147-89 (see RFC 5830 Section 8) defines MAC construction using the same base transformation. Implement support for it: required to read some CMS files produced using GOST algorithms, see RFC 4490. Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com> [jk: cipher/mac-internal.h: moved include of gost.h to include section] Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to 'cipher/mac-internal.h')
-rw-r--r--cipher/mac-internal.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/cipher/mac-internal.h b/cipher/mac-internal.h
index 15b4dfc2..1936150c 100644
--- a/cipher/mac-internal.h
+++ b/cipher/mac-internal.h
@@ -20,6 +20,7 @@
#include <config.h>
#include "g10lib.h"
+#include "gost.h"
/* The data object used to hold a handle to an encryption object. */
@@ -95,7 +96,6 @@ typedef struct gcry_mac_spec
const gcry_mac_spec_ops_t *ops;
} gcry_mac_spec_t;
-
/* The handle structure. */
struct gcry_mac_handle
{
@@ -120,6 +120,13 @@ struct gcry_mac_handle
struct {
struct poly1305mac_context_s *ctx;
} poly1305mac;
+ struct {
+ GOST28147_context ctx;
+ u32 n1, n2;
+ unsigned int unused;
+ unsigned int count;
+ unsigned char lastiv[8]; /* IMIT blocksize */
+ } imit;
} u;
};
@@ -219,6 +226,9 @@ extern gcry_mac_spec_t _gcry_mac_type_spec_cmac_idea;
#if USE_GOST28147
extern gcry_mac_spec_t _gcry_mac_type_spec_cmac_gost28147;
#endif
+#if USE_GOST28147
+extern gcry_mac_spec_t _gcry_mac_type_spec_gost28147_imit;
+#endif
/*
* The GMAC algorithm specifications (mac-gmac.c).