]> www.wagner.pp.ru Git - openssl-gost/engine.git/blobdiff - gost_crypt.c
Let's search the default paramset and not hardcode its position
[openssl-gost/engine.git] / gost_crypt.c
index d1e8113b4159fb63d37d4d4d511a5bf23b6e20e1..3523b3873fa796d95854d98c6e8f8a19645a0e37 100644 (file)
@@ -205,8 +205,13 @@ const struct gost_cipher_info *get_encryption_params(ASN1_OBJECT *obj)
     struct gost_cipher_info *param;
     if (!obj) {
         const char *params = get_gost_engine_param(GOST_PARAM_CRYPT_PARAMS);
-        if (!params || !strlen(params))
-            return &gost_cipher_list[4];
+        if (!params || !strlen(params)) {
+            int i;
+            for (i = 0; gost_cipher_list[i].nid != NID_undef; i++)
+                if (gost_cipher_list[i].nid == NID_id_tc26_gost_28147_param_Z)
+                    return &gost_cipher_list[i];
+            return &gost_cipher_list[0];
+        }
 
         nid = OBJ_txt2nid(params);
         if (nid == NID_undef) {
@@ -537,8 +542,7 @@ int gost_cipher_ctl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
     case EVP_CTRL_RAND_KEY:
         {
             if (RAND_bytes((unsigned char *)ptr, ctx->key_len) <= 0) {
-                GOSTerr(GOST_F_GOST_CIPHER_CTL,
-                        GOST_R_RANDOM_GENERATOR_ERROR);
+                GOSTerr(GOST_F_GOST_CIPHER_CTL, GOST_R_RNG_ERROR);
                 return -1;
             }
             break;