]> www.wagner.pp.ru Git - openssl-gost/engine.git/commitdiff
Ensure proper cipher type for EVP_CTRL_KEY_MESH
authorVitaly Chikunov <vt@altlinux.org>
Thu, 26 Jul 2018 09:23:55 +0000 (12:23 +0300)
committerVitaly Chikunov <vt@altlinux.org>
Thu, 26 Jul 2018 15:52:32 +0000 (18:52 +0300)
gost_grasshopper_cipher.c

index 07dfd91a88d937da446844c823dd78e87886e505..528a7ee6c5a35fcb5c376c8949191664eda9a1e5 100644 (file)
@@ -659,13 +659,16 @@ int gost_grasshopper_cipher_ctl(EVP_CIPHER_CTX* ctx, int type, int arg, void* pt
             }
             break;
         }
-        case EVP_CTRL_KEY_MESH:
-            if (arg <= 1 || ((arg - 1) & arg))
-                return -1;
+        case EVP_CTRL_KEY_MESH: {
             gost_grasshopper_cipher_ctx_ctr *c = EVP_CIPHER_CTX_get_cipher_data(ctx);
+            if (c->c.type != GRASSHOPPER_CIPHER_CTRACPKM ||
+                arg <= 1 ||
+                ((arg - 1) & arg))
+                return -1;
             c->section_size = arg;
             c->skip_sections = 1;
             break;
+        }
         default:
             GOSTerr(GOST_F_GOST_GRASSHOPPER_CIPHER_CTL, GOST_R_UNSUPPORTED_CIPHER_CTL_COMMAND);
             return -1;