[git] GCRYPT - branch, master, updated. libgcrypt-1.5.0-245-g2ad7ea9

by Jussi Kivilinna cvs at cvs.gnupg.org
Wed Sep 18 17:50:58 CEST 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU crypto library".

The branch, master has been updated
       via  2ad7ea9cb388fd31e4b0852b68d77f599ef4adce (commit)
      from  fd84b63ddd825431f557c002608a6c8d1bcc54c8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 2ad7ea9cb388fd31e4b0852b68d77f599ef4adce
Author: Jussi Kivilinna <jussi.kivilinna at iki.fi>
Date:   Wed Sep 18 17:13:53 2013 +0300

    Fix encryption/decryption return type for GOST28147
    
    * cipher/gost.h (_gcry_gost_enc_one): Change return type to
    'unsigned int'.
    * cipher/gost28147.c (max): New macro.
    (gost_encrypt_block, gost_decrypt_block): Return burn stack depth.
    (_gcry_gost_enc_one): Return burn stack depth from gost_encrypt_block.
    --
    
    Return type for block cipher functions was lately changed from 'void' to
    'unsigned int' to pass burn stack depth to cipher mode code. Patch fixes
    gost28147 to return stack burn value.
    
    Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>

diff --git a/cipher/gost.h b/cipher/gost.h
index e1cf033..42021aa 100644
--- a/cipher/gost.h
+++ b/cipher/gost.h
@@ -27,7 +27,7 @@ typedef struct {
 } GOST28147_context;
 
 /* This is a simple interface that will be used by GOST R 34.11-94 */
-extern void _gcry_gost_enc_one (GOST28147_context *c, const byte *key,
+extern unsigned int _gcry_gost_enc_one (GOST28147_context *c, const byte *key,
     byte *out, byte *in);
 
 #endif
diff --git a/cipher/gost28147.c b/cipher/gost28147.c
index 5d6d1e7..862e7d6 100644
--- a/cipher/gost28147.c
+++ b/cipher/gost28147.c
@@ -35,6 +35,9 @@
 #include "cipher.h"
 
 
+#define max(a, b) (((a) > (b)) ? (a) : (b))
+
+
 /* This is an s-box from RFC4357, named GostR3411-94-TestParamSet
  * For now it is the only s-box supported, as libgcrypt lacks mechanism
  * for passing parameters to cipher in a usefull way. */
@@ -107,7 +110,7 @@ gost_val (GOST28147_context *ctx, u32 cm1, int subkey)
   return (cm1 << 11) | (cm1 >> 21);
 }
 
-static void
+static unsigned int
 gost_encrypt_block (void *c, byte *outbuf, const byte *inbuf)
 {
   GOST28147_context *ctx = c;
@@ -153,16 +156,22 @@ gost_encrypt_block (void *c, byte *outbuf, const byte *inbuf)
   outbuf[1 + 4] = (n1 >> (1 * 8)) & 0xff;
   outbuf[2 + 4] = (n1 >> (2 * 8)) & 0xff;
   outbuf[3 + 4] = (n1 >> (3 * 8)) & 0xff;
+
+  return /* burn_stack */ 4*sizeof(void*) /* func call */ +
+                          3*sizeof(void*) /* stack */ +
+                          max( 4*sizeof(void*) /* gost_val call */,
+                               3*sizeof(void*) /* gost_set_subst call */ +
+                               2*sizeof(void*) /* gost_set subst stack*/ );
 }
 
-void _gcry_gost_enc_one (GOST28147_context *c, const byte *key,
+unsigned int _gcry_gost_enc_one (GOST28147_context *c, const byte *key,
     byte *out, byte *in)
 {
   gost_setkey (c, key, 32);
-  gost_encrypt_block (c, out, in);
+  return gost_encrypt_block (c, out, in);
 }
 
-static void
+static unsigned int
 gost_decrypt_block (void *c, byte *outbuf, const byte *inbuf)
 {
   GOST28147_context *ctx = c;
@@ -208,6 +217,12 @@ gost_decrypt_block (void *c, byte *outbuf, const byte *inbuf)
   outbuf[1 + 4] = (n1 >> (1 * 8)) & 0xff;
   outbuf[2 + 4] = (n1 >> (2 * 8)) & 0xff;
   outbuf[3 + 4] = (n1 >> (3 * 8)) & 0xff;
+
+  return /* burn_stack */ 4*sizeof(void*) /* func call */ +
+                          3*sizeof(void*) /* stack */ +
+                          max( 4*sizeof(void*) /* gost_val call */,
+                               3*sizeof(void*) /* gost_set_subst call */ +
+                               2*sizeof(void*) /* gost_set subst stack*/ );
 }
 
 gcry_cipher_spec_t _gcry_cipher_spec_gost28147 =

-----------------------------------------------------------------------

Summary of changes:
 cipher/gost.h      |    2 +-
 cipher/gost28147.c |   23 +++++++++++++++++++----
 2 files changed, 20 insertions(+), 5 deletions(-)


hooks/post-receive
-- 
The GNU crypto library
http://git.gnupg.org




More information about the Gnupg-commits mailing list