Lines Matching full:if

10 #if defined(MBEDTLS_ENTROPY_C)
19 #if defined(MBEDTLS_FS_IO)
32 #if defined(MBEDTLS_THREADING_C) in mbedtls_entropy_init()
42 #if !defined(MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES) in mbedtls_entropy_init()
43 #if !defined(MBEDTLS_NO_PLATFORM_ENTROPY) in mbedtls_entropy_init()
48 #if defined(MBEDTLS_ENTROPY_HARDWARE_ALT) in mbedtls_entropy_init()
53 #if defined(MBEDTLS_ENTROPY_NV_SEED) in mbedtls_entropy_init()
64 if (ctx == NULL) { in mbedtls_entropy_free()
68 /* If the context was already free, don't call free() again. in mbedtls_entropy_free()
70 if (ctx->accumulator_started == -1) { in mbedtls_entropy_free()
74 #if defined(MBEDTLS_THREADING_C) in mbedtls_entropy_free()
78 #if defined(MBEDTLS_ENTROPY_NV_SEED) in mbedtls_entropy_free()
92 #if defined(MBEDTLS_THREADING_C) in mbedtls_entropy_add_source()
93 if ((ret = mbedtls_mutex_lock(&ctx->mutex)) != 0) { in mbedtls_entropy_add_source()
99 if (idx >= MBEDTLS_ENTROPY_MAX_SOURCES) { in mbedtls_entropy_add_source()
112 #if defined(MBEDTLS_THREADING_C) in mbedtls_entropy_add_source()
113 if (mbedtls_mutex_unlock(&ctx->mutex) != 0) { in mbedtls_entropy_add_source()
133 if (use_len > MBEDTLS_ENTROPY_BLOCK_SIZE) { in entropy_update()
134 if ((ret = mbedtls_md(mbedtls_md_info_from_type(MBEDTLS_ENTROPY_MD), in entropy_update()
146 * Start the accumulator if this has not already happened. Note that in entropy_update()
150 if (ctx->accumulator_started == 0) { in entropy_update()
153 if (ret != 0) { in entropy_update()
157 if (ret != 0) { in entropy_update()
162 if ((ret = mbedtls_md_update(&ctx->accumulator, header, 2)) != 0) { in entropy_update()
178 #if defined(MBEDTLS_THREADING_C) in mbedtls_entropy_update_manual()
179 if ((ret = mbedtls_mutex_lock(&ctx->mutex)) != 0) { in mbedtls_entropy_update_manual()
186 #if defined(MBEDTLS_THREADING_C) in mbedtls_entropy_update_manual()
187 if (mbedtls_mutex_unlock(&ctx->mutex) != 0) { in mbedtls_entropy_update_manual()
206 if (ctx->source_count == 0) { in entropy_gather_internal()
214 if (ctx->source[i].strong == MBEDTLS_ENTROPY_SOURCE_STRONG) { in entropy_gather_internal()
219 if ((ret = ctx->source[i].f_source(ctx->source[i].p_source, in entropy_gather_internal()
225 * Add if we actually gathered something in entropy_gather_internal()
227 if (olen > 0) { in entropy_gather_internal()
228 if ((ret = entropy_update(ctx, (unsigned char) i, in entropy_gather_internal()
236 if (have_one_strong == 0) { in entropy_gather_internal()
253 #if defined(MBEDTLS_THREADING_C) in mbedtls_entropy_gather()
254 if ((ret = mbedtls_mutex_lock(&ctx->mutex)) != 0) { in mbedtls_entropy_gather()
261 #if defined(MBEDTLS_THREADING_C) in mbedtls_entropy_gather()
262 if (mbedtls_mutex_unlock(&ctx->mutex) != 0) { in mbedtls_entropy_gather()
277 if (len > MBEDTLS_ENTROPY_BLOCK_SIZE) { in mbedtls_entropy_func()
281 #if defined(MBEDTLS_ENTROPY_NV_SEED) in mbedtls_entropy_func()
285 if (ctx->initial_entropy_run == 0) { in mbedtls_entropy_func()
287 if ((ret = mbedtls_entropy_update_nv_seed(ctx)) != 0) { in mbedtls_entropy_func()
293 #if defined(MBEDTLS_THREADING_C) in mbedtls_entropy_func()
294 if ((ret = mbedtls_mutex_lock(&ctx->mutex)) != 0) { in mbedtls_entropy_func()
303 if (count++ > ENTROPY_MAX_LOOP) { in mbedtls_entropy_func()
308 if ((ret = entropy_gather_internal(ctx)) != 0) { in mbedtls_entropy_func()
315 if (ctx->source[i].size < ctx->source[i].threshold) { in mbedtls_entropy_func()
318 if (ctx->source[i].strong == MBEDTLS_ENTROPY_SOURCE_STRONG) { in mbedtls_entropy_func()
328 * in a previous call to entropy_update(). If this is not guaranteed, the in mbedtls_entropy_func()
331 if ((ret = mbedtls_md_finish(&ctx->accumulator, buf)) != 0) { in mbedtls_entropy_func()
342 if (ret != 0) { in mbedtls_entropy_func()
346 if (ret != 0) { in mbedtls_entropy_func()
349 if ((ret = mbedtls_md_update(&ctx->accumulator, buf, in mbedtls_entropy_func()
357 if ((ret = mbedtls_md(mbedtls_md_info_from_type(MBEDTLS_ENTROPY_MD), in mbedtls_entropy_func()
373 #if defined(MBEDTLS_THREADING_C) in mbedtls_entropy_func()
374 if (mbedtls_mutex_unlock(&ctx->mutex) != 0) { in mbedtls_entropy_func()
382 #if defined(MBEDTLS_ENTROPY_NV_SEED)
389 if ((ret = mbedtls_entropy_func(ctx, buf, MBEDTLS_ENTROPY_BLOCK_SIZE)) != 0) { in mbedtls_entropy_update_nv_seed()
393 if (mbedtls_nv_seed_write(buf, MBEDTLS_ENTROPY_BLOCK_SIZE) < 0) { in mbedtls_entropy_update_nv_seed()
405 #if defined(MBEDTLS_FS_IO)
412 if ((ret = mbedtls_entropy_func(ctx, buf, MBEDTLS_ENTROPY_BLOCK_SIZE)) != 0) { in mbedtls_entropy_write_seed_file()
417 if ((f = fopen(path, "wb")) == NULL) { in mbedtls_entropy_write_seed_file()
425 if (fwrite(buf, 1, MBEDTLS_ENTROPY_BLOCK_SIZE, f) != MBEDTLS_ENTROPY_BLOCK_SIZE) { in mbedtls_entropy_write_seed_file()
435 if (f != NULL) { in mbedtls_entropy_write_seed_file()
449 if ((f = fopen(path, "rb")) == NULL) { in mbedtls_entropy_update_seed_file()
460 if (n > MBEDTLS_ENTROPY_MAX_SEED_SIZE) { in mbedtls_entropy_update_seed_file()
464 if (fread(buf, 1, n, f) != n) { in mbedtls_entropy_update_seed_file()
474 if (ret != 0) { in mbedtls_entropy_update_seed_file()
482 #if defined(MBEDTLS_SELF_TEST)
497 #if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
507 if ((ret = mbedtls_hardware_poll(NULL, buf + entropy_len, in mbedtls_entropy_source_self_test_gather()
516 if (entropy_len < buf_len) { in mbedtls_entropy_source_self_test_gather()
556 if (verbose != 0) { in mbedtls_entropy_source_self_test()
563 if ((ret = mbedtls_entropy_source_self_test_gather(buf0, sizeof(buf0))) != 0) { in mbedtls_entropy_source_self_test()
566 if ((ret = mbedtls_entropy_source_self_test_gather(buf1, sizeof(buf1))) != 0) { in mbedtls_entropy_source_self_test()
571 if ((ret = mbedtls_entropy_source_self_test_check_bits(buf0, sizeof(buf0))) != 0) { in mbedtls_entropy_source_self_test()
574 if ((ret = mbedtls_entropy_source_self_test_check_bits(buf1, sizeof(buf1))) != 0) { in mbedtls_entropy_source_self_test()
583 if (verbose != 0) { in mbedtls_entropy_source_self_test()
584 if (ret != 0) { in mbedtls_entropy_source_self_test()
611 if (verbose != 0) { in mbedtls_entropy_self_test()
618 if ((ret = mbedtls_entropy_gather(&ctx)) != 0) { in mbedtls_entropy_self_test()
624 if (ret != 0) { in mbedtls_entropy_self_test()
628 if ((ret = mbedtls_entropy_update_manual(&ctx, buf, sizeof(buf))) != 0) { in mbedtls_entropy_self_test()
641 if ((ret = mbedtls_entropy_func(&ctx, buf, sizeof(buf))) != 0) { in mbedtls_entropy_self_test()
651 if (acc[j] == 0) { in mbedtls_entropy_self_test()
657 #if defined(MBEDTLS_ENTROPY_HARDWARE_ALT) in mbedtls_entropy_self_test()
658 if ((ret = mbedtls_entropy_source_self_test(0)) != 0) { in mbedtls_entropy_self_test()
666 if (verbose != 0) { in mbedtls_entropy_self_test()
667 if (ret != 0) { in mbedtls_entropy_self_test()