]> www.wagner.pp.ru Git - openssl-gost/engine.git/blobdiff - gost89.c
Delete .travis.yml
[openssl-gost/engine.git] / gost89.c
index f940dab384b57cd0ca3ca76400077a498cb49ac5..08c90f33fb9567f7ecb5daa5badf386de06722af 100644 (file)
--- a/gost89.c
+++ b/gost89.c
@@ -452,7 +452,7 @@ void gost_enc_with_key(gost_ctx * c, byte * key, byte * inblock,
 void gost_key(gost_ctx * c, const byte * k)
 {
     int i, j;
-    RAND_bytes((unsigned char *)c->mask, sizeof(c->mask));
+    RAND_priv_bytes((unsigned char *)c->mask, sizeof(c->mask));
     for (i = 0, j = 0; i < 8; ++i, j += 4) {
         c->key[i] =
             (k[j] | (k[j + 1] << 8) | (k[j + 2] << 16) | ((word32) k[j + 3] <<
@@ -464,7 +464,7 @@ void gost_key(gost_ctx * c, const byte * k)
 void magma_key(gost_ctx * c, const byte * k)
 {
     int i, j;
-    RAND_bytes((unsigned char *)c->mask, sizeof(c->mask));
+    RAND_priv_bytes((unsigned char *)c->mask, sizeof(c->mask));
     for (i = 0, j = 0; i < 8; ++i, j += 4) {
         c->key[i] =
             (k[j + 3] | (k[j + 2] << 8) | (k[j + 1] << 16) | ((word32) k[j] <<
@@ -472,6 +472,10 @@ void magma_key(gost_ctx * c, const byte * k)
     }
 }
 
+void magma_master_key(gost_ctx *c, const byte *k) {
+    memcpy(c->master_key, k, sizeof(c->master_key));
+}
+
 /* Retrieve 256-bit gost89 key from context */
 void gost_get_key(gost_ctx * c, byte * k)
 {
@@ -508,6 +512,7 @@ void gost_init(gost_ctx * c, const gost_subst_block * b)
 /* Cleans up key from context */
 void gost_destroy(gost_ctx * c)
 {
+    OPENSSL_cleanse(c->master_key, sizeof(c->master_key));
     OPENSSL_cleanse(c->key, sizeof(c->key));
     OPENSSL_cleanse(c->mask, sizeof(c->mask));
 }