]> www.wagner.pp.ru Git - openssl-gost/engine.git/commitdiff
Replace RAND_bytes with RAND_priv_bytes
authorVitaly Chikunov <vt@altlinux.org>
Mon, 17 Feb 2020 23:53:14 +0000 (02:53 +0300)
committerDmitry Belyavskiy <beldmit@users.noreply.github.com>
Tue, 25 Feb 2020 21:14:25 +0000 (00:14 +0300)
`RAND_priv_bytes' is supposed to be used for private data.

gost89.c
gost_crypt.c
gost_grasshopper_cipher.c

index f940dab384b57cd0ca3ca76400077a498cb49ac5..953c6ec7788e96a45141dd6f0f03ea34ebdd9af0 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] <<
index 7e733df7e581168ef2fd57cc9d78a0d2f333b509..a649e72ded26c111cb5d92154b01dd3a525439e0 100644 (file)
@@ -876,7 +876,7 @@ int gost_cipher_ctl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
 #endif
     case EVP_CTRL_RAND_KEY:
         {
-            if (RAND_bytes
+            if (RAND_priv_bytes
                 ((unsigned char *)ptr, EVP_CIPHER_CTX_key_length(ctx)) <= 0) {
                 GOSTerr(GOST_F_GOST_CIPHER_CTL, GOST_R_RNG_ERROR);
                 return -1;
index 70c9f17a354d4e4150fa2bca29b11135a7eb6d3d..2955534cb58fca1bad3b417ec106507a87785b62 100644 (file)
@@ -729,7 +729,7 @@ int gost_grasshopper_cipher_ctl(EVP_CIPHER_CTX *ctx, int type, int arg,
 {
     switch (type) {
     case EVP_CTRL_RAND_KEY:{
-            if (RAND_bytes
+            if (RAND_priv_bytes
                 ((unsigned char *)ptr, EVP_CIPHER_CTX_key_length(ctx)) <= 0) {
                 GOSTerr(GOST_F_GOST_GRASSHOPPER_CIPHER_CTL, GOST_R_RNG_ERROR);
                 return -1;