]> www.wagner.pp.ru Git - openssl-gost/engine.git/blobdiff - gost_crypt.c
Ensure that CMAC_ACPKM_CTX_copy works with 2 non-NULL pointers - fixup
[openssl-gost/engine.git] / gost_crypt.c
index f60dd0629c763239ef2e49cf113a9977ec094b7f..8f8e0d382ff05bd340f504b34e29f5a49830454b 100644 (file)
@@ -74,7 +74,7 @@ static int magma_cipher_ctl_acpkm_omac(EVP_CIPHER_CTX *ctx, int type, int arg, v
  * Note: that you cannot template 0 value.
  */
 #define TPL(st,field) ( \
-    ((st)->field) ?: TPL_VAL(st,field) \
+    ((st)->field) ? ((st)->field) : TPL_VAL(st,field) \
 )
 
 #define TPL_VAL(st,field) ( \
@@ -649,7 +649,7 @@ static void ctr64_inc(unsigned char *counter)
 static inline void apply_acpkm_magma(struct ossl_gost_cipher_ctx *
                                            ctx, unsigned int *num)
 {
-    if (!ctx->key_meshing || (*num < ctx->key_meshing))
+    if (!ctx->key_meshing || (*num < (unsigned int)ctx->key_meshing))
         return;
     acpkm_magma_key_meshing(&ctx->cctx);
     *num &= MAGMA_BLOCK_MASK;
@@ -767,7 +767,7 @@ static int gost_cipher_do_cfb(EVP_CIPHER_CTX *ctx, unsigned char *out,
         }
     }
 
-    for (; i + 8 < inl; i += 8, in_ptr += 8, out_ptr += 8) {
+    for (; (inl - i) >= 8; i += 8, in_ptr += 8, out_ptr += 8) {
         /*
          * block cipher current iv
          */
@@ -828,7 +828,7 @@ static int gost_cipher_do_cnt(EVP_CIPHER_CTX *ctx, unsigned char *out,
         }
     }
 
-    for (; i + 8 < inl; i += 8, in_ptr += 8, out_ptr += 8) {
+    for (; (inl - i) >= 8; i += 8, in_ptr += 8, out_ptr += 8) {
         /*
          * block cipher current iv
          */