crypto/ec/curve448/eddsa.c:320: error: MEMORY_LEAK
  memory dynamically allocated by call to `EVP_MD_CTX_new()` at line 308, column 31 is not reachable after line 320, column 13.
Showing all 52 steps of the trace


crypto/ec/curve448/eddsa.c:286:1: start of procedure decaf_ed448_verify()
284.   }
285.   
286. > decaf_error_t decaf_ed448_verify (
287.       const uint8_t signature[DECAF_EDDSA_448_SIGNATURE_BYTES],
288.       const uint8_t pubkey[DECAF_EDDSA_448_PUBLIC_BYTES],

crypto/ec/curve448/eddsa.c:296:5: Skipping curve448_point_decode_like_eddsa_and_mul_by_ratio(): empty list of specs
294.   ) { 
295.       curve448_point_t pk_point, r_point;
296.       decaf_error_t error = curve448_point_decode_like_eddsa_and_mul_by_ratio(pk_point,pubkey);
           ^
297.       curve448_scalar_t challenge_scalar;
298.       curve448_scalar_t response_scalar;

crypto/ec/curve448/eddsa.c:301:9: Taking false branch
299.       unsigned int c;
300.   
301.       if (DECAF_SUCCESS != error) { return error; }
               ^
302.       
303.       error = curve448_point_decode_like_eddsa_and_mul_by_ratio(r_point,signature);

crypto/ec/curve448/eddsa.c:303:5: Skipping curve448_point_decode_like_eddsa_and_mul_by_ratio(): empty list of specs
301.       if (DECAF_SUCCESS != error) { return error; }
302.       
303.       error = curve448_point_decode_like_eddsa_and_mul_by_ratio(r_point,signature);
           ^
304.       if (DECAF_SUCCESS != error) { return error; }
305.       

crypto/ec/curve448/eddsa.c:304:9: Taking false branch
302.       
303.       error = curve448_point_decode_like_eddsa_and_mul_by_ratio(r_point,signature);
304.       if (DECAF_SUCCESS != error) { return error; }
               ^
305.       
306.       {

crypto/ec/curve448/eddsa.c:308:9: 
306.       {
307.           /* Compute the challenge */
308. >         EVP_MD_CTX *hashctx = EVP_MD_CTX_new();
309.           uint8_t challenge[2*DECAF_EDDSA_448_PRIVATE_BYTES];
310.   

crypto/evp/digest.c:44:1: start of procedure EVP_MD_CTX_new()
  42.   }
  43.   
  44. > EVP_MD_CTX *EVP_MD_CTX_new(void)
  45.   {
  46.       return OPENSSL_zalloc(sizeof(EVP_MD_CTX));

crypto/evp/digest.c:46:5: 
  44.   EVP_MD_CTX *EVP_MD_CTX_new(void)
  45.   {
  46. >     return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
  47.   }
  48.   

crypto/mem.c:221:1: start of procedure CRYPTO_zalloc()
    219.   }
    220.   
    221. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    222.   {
    223.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:223:5: 
    221.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    222.   {
    223. >     void *ret = CRYPTO_malloc(num, file, line);
    224.   
    225.       FAILTEST();

crypto/mem.c:192:1: start of procedure CRYPTO_malloc()
      190.   #endif
      191.   
      192. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      193.   {
      194.       void *ret = NULL;

crypto/mem.c:194:5: 
      192.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      193.   {
      194. >     void *ret = NULL;
      195.   
      196.       INCREMENT(malloc_count);

crypto/mem.c:197:9: Taking false branch
      195.   
      196.       INCREMENT(malloc_count);
      197.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                     ^
      198.           return malloc_impl(num, file, line);
      199.   

crypto/mem.c:200:9: Taking false branch
      198.           return malloc_impl(num, file, line);
      199.   
      200.       if (num == 0)
                     ^
      201.           return NULL;
      202.   

crypto/mem.c:204:5: 
      202.   
      203.       FAILTEST();
      204. >     allow_customize = 0;
      205.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      206.       if (call_malloc_debug) {

crypto/mem.c:214:5: 
      212.       }
      213.   #else
      214. >     (void)(file); (void)(line);
      215.       ret = malloc(num);
      216.   #endif

crypto/mem.c:214:19: 
      212.       }
      213.   #else
      214. >     (void)(file); (void)(line);
      215.       ret = malloc(num);
      216.   #endif

crypto/mem.c:215:5: 
      213.   #else
      214.       (void)(file); (void)(line);
      215. >     ret = malloc(num);
      216.   #endif
      217.   

crypto/mem.c:218:5: 
      216.   #endif
      217.   
      218. >     return ret;
      219.   }
      220.   

crypto/mem.c:219:1: return from a call to CRYPTO_malloc
      217.   
      218.       return ret;
      219. > }
      220.   
      221.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:226:9: Taking true branch
    224.   
    225.       FAILTEST();
    226.       if (ret != NULL)
                   ^
    227.           memset(ret, 0, num);
    228.       return ret;

crypto/mem.c:227:9: 
    225.       FAILTEST();
    226.       if (ret != NULL)
    227. >         memset(ret, 0, num);
    228.       return ret;
    229.   }

crypto/mem.c:228:5: 
    226.       if (ret != NULL)
    227.           memset(ret, 0, num);
    228. >     return ret;
    229.   }
    230.   

crypto/mem.c:229:1: return from a call to CRYPTO_zalloc
    227.           memset(ret, 0, num);
    228.       return ret;
    229. > }
    230.   
    231.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/evp/digest.c:47:1: return from a call to EVP_MD_CTX_new
  45.   {
  46.       return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
  47. > }
  48.   
  49.   void EVP_MD_CTX_free(EVP_MD_CTX *ctx)

crypto/ec/curve448/eddsa.c:311:13: Taking false branch
309.           uint8_t challenge[2*DECAF_EDDSA_448_PRIVATE_BYTES];
310.   
311.           if (hashctx == NULL
                   ^
312.                   || !hash_init_with_dom(hashctx, prehashed, 0, context,
313.                                          context_len)

crypto/ec/curve448/eddsa.c:312:21: 
310.   
311.           if (hashctx == NULL
312. >                 || !hash_init_with_dom(hashctx, prehashed, 0, context,
313.                                          context_len)
314.                   || !EVP_DigestUpdate(hashctx, signature,

crypto/ec/curve448/eddsa.c:78:1: start of procedure hash_init_with_dom()
  76.   }
  77.   
  78. > static decaf_error_t hash_init_with_dom(
  79.       EVP_MD_CTX *hashctx,
  80.       uint8_t prehashed,

crypto/ec/curve448/eddsa.c:85:5: 
  83.       size_t context_len
  84.   ) {
  85. >     const char *dom_s = "SigEd448";
  86.       uint8_t dom[2];
  87.   

crypto/ec/curve448/eddsa.c:88:5: 
  86.       uint8_t dom[2];
  87.   
  88. >     dom[0] = 2 + word_is_zero(prehashed) + word_is_zero(for_prehash);
  89.       dom[1] = (uint8_t)context_len;
  90.   

crypto/ec/curve448/arch_32/arch_intrinsics.h:10:1: start of procedure word_is_zero()
    8.   #define ARCH_WORD_BITS 32
    9.   
    10. > static __inline__ __attribute((always_inline,unused))
    11.   uint32_t word_is_zero(uint32_t a) {
    12.       /* let's hope the compiler isn't clever enough to optimize this. */

crypto/ec/curve448/arch_32/arch_intrinsics.h:13:5: 
    11.   uint32_t word_is_zero(uint32_t a) {
    12.       /* let's hope the compiler isn't clever enough to optimize this. */
    13. >     return (((uint64_t)a)-1)>>32;
    14.   }
    15.   

crypto/ec/curve448/arch_32/arch_intrinsics.h:14:1: return from a call to word_is_zero
    12.       /* let's hope the compiler isn't clever enough to optimize this. */
    13.       return (((uint64_t)a)-1)>>32;
    14. > }
    15.   
    16.   static __inline__ __attribute((always_inline,unused))

crypto/ec/curve448/arch_32/arch_intrinsics.h:10:1: start of procedure word_is_zero()
    8.   #define ARCH_WORD_BITS 32
    9.   
    10. > static __inline__ __attribute((always_inline,unused))
    11.   uint32_t word_is_zero(uint32_t a) {
    12.       /* let's hope the compiler isn't clever enough to optimize this. */

crypto/ec/curve448/arch_32/arch_intrinsics.h:13:5: 
    11.   uint32_t word_is_zero(uint32_t a) {
    12.       /* let's hope the compiler isn't clever enough to optimize this. */
    13. >     return (((uint64_t)a)-1)>>32;
    14.   }
    15.   

crypto/ec/curve448/arch_32/arch_intrinsics.h:14:1: return from a call to word_is_zero
    12.       /* let's hope the compiler isn't clever enough to optimize this. */
    13.       return (((uint64_t)a)-1)>>32;
    14. > }
    15.   
    16.   static __inline__ __attribute((always_inline,unused))

crypto/ec/curve448/eddsa.c:89:5: 
  87.   
  88.       dom[0] = 2 + word_is_zero(prehashed) + word_is_zero(for_prehash);
  89. >     dom[1] = (uint8_t)context_len;
  90.   
  91.       if (context_len > UINT8_MAX)

crypto/ec/curve448/eddsa.c:91:9: Taking true branch
  89.       dom[1] = (uint8_t)context_len;
  90.   
  91.       if (context_len > UINT8_MAX)
                ^
  92.           return DECAF_FAILURE;
  93.   

crypto/ec/curve448/eddsa.c:92:9: 
  90.   
  91.       if (context_len > UINT8_MAX)
  92. >         return DECAF_FAILURE;
  93.   
  94.   #if NO_CONTEXT

crypto/ec/curve448/eddsa.c:111:1: return from a call to hash_init_with_dom
  109.   
  110.       return DECAF_SUCCESS;
  111. > }
  112.   
  113.   /* In this file because it uses the hash */

crypto/ec/curve448/eddsa.c:312:21: Taking true branch
310.   
311.           if (hashctx == NULL
312.                   || !hash_init_with_dom(hashctx, prehashed, 0, context,
                           ^
313.                                          context_len)
314.                   || !EVP_DigestUpdate(hashctx, signature,

crypto/ec/curve448/eddsa.c:320:13: 
318.                   || !EVP_DigestUpdate(hashctx, message, message_len)
319.                   || !EVP_DigestFinalXOF(hashctx, challenge, sizeof(challenge))) {
320. >             EVP_MD_CTX_free(hashctx);
321.               return DECAF_FAILURE;
322.           }

crypto/evp/digest.c:49:1: start of procedure EVP_MD_CTX_free()
  47.   }
  48.   
  49. > void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
  50.   {
  51.       EVP_MD_CTX_reset(ctx);

crypto/evp/digest.c:51:5: Skipping EVP_MD_CTX_reset(): empty list of specs
  49.   void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
  50.   {
  51.       EVP_MD_CTX_reset(ctx);
            ^
  52.       OPENSSL_free(ctx);
  53.   }

crypto/evp/digest.c:52:5: 
  50.   {
  51.       EVP_MD_CTX_reset(ctx);
  52. >     OPENSSL_free(ctx);
  53.   }
  54.   

crypto/mem.c:289:1: start of procedure CRYPTO_free()
    287.   }
    288.   
    289. > void CRYPTO_free(void *str, const char *file, int line)
    290.   {
    291.       INCREMENT(free_count);

crypto/mem.c:292:9: Taking true branch
    290.   {
    291.       INCREMENT(free_count);
    292.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    293.           free_impl(str, file, line);
    294.           return;

crypto/mem.c:292:30: Taking true branch
    290.   {
    291.       INCREMENT(free_count);
    292.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    293.           free_impl(str, file, line);
    294.           return;

crypto/mem.c:293:9: Skipping __function_pointer__(): unresolved function pointer
    291.       INCREMENT(free_count);
    292.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    293.           free_impl(str, file, line);
                   ^
    294.           return;
    295.       }

crypto/mem.c:294:9: 
    292.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    293.           free_impl(str, file, line);
    294. >         return;
    295.       }
    296.   

crypto/mem.c:308:1: return from a call to CRYPTO_free
    306.       free(str);
    307.   #endif
    308. > }
    309.   
    310.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/evp/digest.c:53:1: return from a call to EVP_MD_CTX_free
  51.       EVP_MD_CTX_reset(ctx);
  52.       OPENSSL_free(ctx);
  53. > }
  54.   
  55.   int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type)

decaf_error_t decaf_ed448_verify (
    const uint8_t signature[DECAF_EDDSA_448_SIGNATURE_BYTES],
    const uint8_t pubkey[DECAF_EDDSA_448_PUBLIC_BYTES],
    const uint8_t *message,
    size_t message_len,
    uint8_t prehashed,
    const uint8_t *context,
    uint8_t context_len
) {
    curve448_point_t pk_point, r_point;
    decaf_error_t error = curve448_point_decode_like_eddsa_and_mul_by_ratio(pk_point,pubkey);
    curve448_scalar_t challenge_scalar;
    curve448_scalar_t response_scalar;
    unsigned int c;
    if (DECAF_SUCCESS != error) { return error; }
    error = curve448_point_decode_like_eddsa_and_mul_by_ratio(r_point,signature);
    if (DECAF_SUCCESS != error) { return error; }
    {
        EVP_MD_CTX *hashctx = EVP_MD_CTX_new();
        uint8_t challenge[2*DECAF_EDDSA_448_PRIVATE_BYTES];
        if (hashctx == NULL
                || !hash_init_with_dom(hashctx, prehashed, 0, context,
                                       context_len)
                || !EVP_DigestUpdate(hashctx, signature,
                                     DECAF_EDDSA_448_PUBLIC_BYTES)
                || !EVP_DigestUpdate(hashctx, pubkey,
                                     DECAF_EDDSA_448_PUBLIC_BYTES)
                || !EVP_DigestUpdate(hashctx, message, message_len)
                || !EVP_DigestFinalXOF(hashctx, challenge, sizeof(challenge))) {
            EVP_MD_CTX_free(hashctx);
            return DECAF_FAILURE;
        }
        EVP_MD_CTX_free(hashctx);
        curve448_scalar_decode_long(challenge_scalar,challenge,sizeof(challenge));
        OPENSSL_cleanse(challenge,sizeof(challenge));
    }
    curve448_scalar_sub(challenge_scalar, curve448_scalar_zero, challenge_scalar);
    curve448_scalar_decode_long(
        response_scalar,
        &signature[DECAF_EDDSA_448_PUBLIC_BYTES],
        DECAF_EDDSA_448_PRIVATE_BYTES
    );
    for (c=1; c<DECAF_448_EDDSA_DECODE_RATIO; c<<=1) {
        curve448_scalar_add(response_scalar,response_scalar,response_scalar);
    }
    curve448_base_double_scalarmul_non_secret(
        pk_point,
        response_scalar,
        pk_point,
        challenge_scalar
    );
    return decaf_succeed_if(curve448_point_eq(pk_point,r_point));
}
['decaf_error_t decaf_ed448_verify (\n    const uint8_t signature[DECAF_EDDSA_448_SIGNATURE_BYTES],\n    const uint8_t pubkey[DECAF_EDDSA_448_PUBLIC_BYTES],\n    const uint8_t *message,\n    size_t message_len,\n    uint8_t prehashed,\n    const uint8_t *context,\n    uint8_t context_len\n) {\n    curve448_point_t pk_point, r_point;\n    decaf_error_t error = curve448_point_decode_like_eddsa_and_mul_by_ratio(pk_point,pubkey);\n    curve448_scalar_t challenge_scalar;\n    curve448_scalar_t response_scalar;\n    unsigned int c;\n    if (DECAF_SUCCESS != error) { return error; }\n    error = curve448_point_decode_like_eddsa_and_mul_by_ratio(r_point,signature);\n    if (DECAF_SUCCESS != error) { return error; }\n    {\n        EVP_MD_CTX *hashctx = EVP_MD_CTX_new();\n        uint8_t challenge[2*DECAF_EDDSA_448_PRIVATE_BYTES];\n        if (hashctx == NULL\n                || !hash_init_with_dom(hashctx, prehashed, 0, context,\n                                       context_len)\n                || !EVP_DigestUpdate(hashctx, signature,\n                                     DECAF_EDDSA_448_PUBLIC_BYTES)\n                || !EVP_DigestUpdate(hashctx, pubkey,\n                                     DECAF_EDDSA_448_PUBLIC_BYTES)\n                || !EVP_DigestUpdate(hashctx, message, message_len)\n                || !EVP_DigestFinalXOF(hashctx, challenge, sizeof(challenge))) {\n            EVP_MD_CTX_free(hashctx);\n            return DECAF_FAILURE;\n        }\n        EVP_MD_CTX_free(hashctx);\n        curve448_scalar_decode_long(challenge_scalar,challenge,sizeof(challenge));\n        OPENSSL_cleanse(challenge,sizeof(challenge));\n    }\n    curve448_scalar_sub(challenge_scalar, curve448_scalar_zero, challenge_scalar);\n    curve448_scalar_decode_long(\n        response_scalar,\n        &signature[DECAF_EDDSA_448_PUBLIC_BYTES],\n        DECAF_EDDSA_448_PRIVATE_BYTES\n    );\n    for (c=1; c<DECAF_448_EDDSA_DECODE_RATIO; c<<=1) {\n        curve448_scalar_add(response_scalar,response_scalar,response_scalar);\n    }\n    curve448_base_double_scalarmul_non_secret(\n        pk_point,\n        response_scalar,\n        pk_point,\n        challenge_scalar\n    );\n    return decaf_succeed_if(curve448_point_eq(pk_point,r_point));\n}', 'EVP_MD_CTX *EVP_MD_CTX_new(void)\n{\n    return OPENSSL_zalloc(sizeof(EVP_MD_CTX));\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\n    FAILTEST();\n    if (ret != NULL)\n        memset(ret, 0, num);\n    return ret;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    INCREMENT(malloc_count);\n    if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\n    if (num == 0)\n        return NULL;\n    FAILTEST();\n    allow_customize = 0;\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    (void)(file); (void)(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}', 'static decaf_error_t hash_init_with_dom(\n    EVP_MD_CTX *hashctx,\n    uint8_t prehashed,\n    uint8_t for_prehash,\n    const uint8_t *context,\n    size_t context_len\n) {\n    const char *dom_s = "SigEd448";\n    uint8_t dom[2];\n    dom[0] = 2 + word_is_zero(prehashed) + word_is_zero(for_prehash);\n    dom[1] = (uint8_t)context_len;\n    if (context_len > UINT8_MAX)\n        return DECAF_FAILURE;\n#if NO_CONTEXT\n    if (context_len == 0 && context == DECAF_ED448_NO_CONTEXT) {\n        (void)prehashed;\n        (void)for_prehash;\n        (void)context;\n        (void)context_len;\n        return DECAF_SUCCESS;\n    }\n#endif\n    if (!EVP_DigestInit_ex(hashctx, EVP_shake256(), NULL)\n            || !EVP_DigestUpdate(hashctx, dom_s, strlen(dom_s))\n            || !EVP_DigestUpdate(hashctx, dom, sizeof(dom))\n            || !EVP_DigestUpdate(hashctx, context, context_len))\n        return DECAF_FAILURE;\n    return DECAF_SUCCESS;\n}', 'static __inline__ __attribute((always_inline,unused))\nuint32_t word_is_zero(uint32_t a) {\n    return (((uint64_t)a)-1)>>32;\n}', 'void EVP_MD_CTX_free(EVP_MD_CTX *ctx)\n{\n    EVP_MD_CTX_reset(ctx);\n    OPENSSL_free(ctx);\n}', 'void CRYPTO_free(void *str, const char *file, int line)\n{\n    INCREMENT(free_count);\n    if (free_impl != NULL && free_impl != &CRYPTO_free) {\n        free_impl(str, file, line);\n        return;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0, file, line);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1, file, line);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}']