]> www.wagner.pp.ru Git - openssl-gost/engine.git/blobdiff - gost_grasshopper_cipher.c
Magma CTR (no meshing), compile-only version.
[openssl-gost/engine.git] / gost_grasshopper_cipher.c
index 20c04b0d7f5e12de1925ac6cc219851ed5e23a0f..e7c8dd6299de4e93001e53b08370dda259ee1c3d 100644 (file)
@@ -17,6 +17,7 @@ extern "C" {
 #include <openssl/err.h>
 #include <string.h>
 
+#include "gost_lcl.h"
 #include "e_gost_err.h"
 
 enum GRASSHOPPER_CIPHER_TYPE {
@@ -279,11 +280,10 @@ int gost_grasshopper_cipher_do_cbc(EVP_CIPHER_CTX* ctx, unsigned char* out,
     return 1;
 }
 
-/* increment counter (128-bit int) by 1 */
-static void ctr128_inc(unsigned char *counter)
+void inc_counter(unsigned char* counter, size_t counter_bytes)
 {
-    unsigned int n = 16;
     unsigned char c;
+    unsigned int n = counter_bytes;
 
     do {
         --n;
@@ -294,6 +294,12 @@ static void ctr128_inc(unsigned char *counter)
     } while (n);
 }
 
+/* increment counter (128-bit int) by 1 */
+static void ctr128_inc(unsigned char *counter)
+{
+       inc_counter(counter, 16);
+}
+
 int gost_grasshopper_cipher_do_ctr(EVP_CIPHER_CTX* ctx, unsigned char* out,
                                           const unsigned char* in, size_t inl) {
     gost_grasshopper_cipher_ctx_ctr* c = (gost_grasshopper_cipher_ctx_ctr*) EVP_CIPHER_CTX_get_cipher_data(ctx);