Lines Matching refs:ret
90 int idx, ret = 0; in mbedtls_entropy_add_source() local
93 if ((ret = mbedtls_mutex_lock(&ctx->mutex)) != 0) { in mbedtls_entropy_add_source()
94 return ret; in mbedtls_entropy_add_source()
100 ret = MBEDTLS_ERR_ENTROPY_MAX_SOURCES; in mbedtls_entropy_add_source()
118 return ret; in mbedtls_entropy_add_source()
131 int ret = 0; in entropy_update() local
134 if ((ret = mbedtls_md(mbedtls_md_info_from_type(MBEDTLS_ENTROPY_MD), in entropy_update()
151 ret = mbedtls_md_setup(&ctx->accumulator, in entropy_update()
153 if (ret != 0) { in entropy_update()
156 ret = mbedtls_md_starts(&ctx->accumulator); in entropy_update()
157 if (ret != 0) { in entropy_update()
162 if ((ret = mbedtls_md_update(&ctx->accumulator, header, 2)) != 0) { in entropy_update()
165 ret = mbedtls_md_update(&ctx->accumulator, p, use_len); in entropy_update()
170 return ret; in entropy_update()
176 int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; in mbedtls_entropy_update_manual() local
179 if ((ret = mbedtls_mutex_lock(&ctx->mutex)) != 0) { in mbedtls_entropy_update_manual()
180 return ret; in mbedtls_entropy_update_manual()
184 ret = entropy_update(ctx, MBEDTLS_ENTROPY_SOURCE_MANUAL, data, len); in mbedtls_entropy_update_manual()
192 return ret; in mbedtls_entropy_update_manual()
200 int ret = MBEDTLS_ERR_ENTROPY_SOURCE_FAILED; in entropy_gather_internal() local
219 if ((ret = ctx->source[i].f_source(ctx->source[i].p_source, in entropy_gather_internal()
228 if ((ret = entropy_update(ctx, (unsigned char) i, in entropy_gather_internal()
230 return ret; in entropy_gather_internal()
237 ret = MBEDTLS_ERR_ENTROPY_NO_STRONG_SOURCE; in entropy_gather_internal()
243 return ret; in entropy_gather_internal()
251 int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; in mbedtls_entropy_gather() local
254 if ((ret = mbedtls_mutex_lock(&ctx->mutex)) != 0) { in mbedtls_entropy_gather()
255 return ret; in mbedtls_entropy_gather()
259 ret = entropy_gather_internal(ctx); in mbedtls_entropy_gather()
267 return ret; in mbedtls_entropy_gather()
272 int ret, count = 0, i, thresholds_reached; in mbedtls_entropy_func() local
287 if ((ret = mbedtls_entropy_update_nv_seed(ctx)) != 0) { in mbedtls_entropy_func()
288 return ret; in mbedtls_entropy_func()
294 if ((ret = mbedtls_mutex_lock(&ctx->mutex)) != 0) { in mbedtls_entropy_func()
295 return ret; in mbedtls_entropy_func()
304 ret = MBEDTLS_ERR_ENTROPY_SOURCE_FAILED; in mbedtls_entropy_func()
308 if ((ret = entropy_gather_internal(ctx)) != 0) { in mbedtls_entropy_func()
331 if ((ret = mbedtls_md_finish(&ctx->accumulator, buf)) != 0) { in mbedtls_entropy_func()
340 ret = mbedtls_md_setup(&ctx->accumulator, in mbedtls_entropy_func()
342 if (ret != 0) { in mbedtls_entropy_func()
345 ret = mbedtls_md_starts(&ctx->accumulator); 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()
368 ret = 0; in mbedtls_entropy_func()
379 return ret; in mbedtls_entropy_func()
385 int ret = MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR; in mbedtls_entropy_update_nv_seed() local
389 if ((ret = mbedtls_entropy_func(ctx, buf, MBEDTLS_ENTROPY_BLOCK_SIZE)) != 0) { in mbedtls_entropy_update_nv_seed()
390 return ret; in mbedtls_entropy_update_nv_seed()
399 ret = mbedtls_entropy_update_manual(ctx, buf, MBEDTLS_ENTROPY_BLOCK_SIZE); in mbedtls_entropy_update_nv_seed()
401 return ret; in mbedtls_entropy_update_nv_seed()
408 int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; in mbedtls_entropy_write_seed_file() local
412 if ((ret = mbedtls_entropy_func(ctx, buf, MBEDTLS_ENTROPY_BLOCK_SIZE)) != 0) { in mbedtls_entropy_write_seed_file()
413 ret = MBEDTLS_ERR_ENTROPY_SOURCE_FAILED; in mbedtls_entropy_write_seed_file()
418 ret = MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR; in mbedtls_entropy_write_seed_file()
426 ret = MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR; in mbedtls_entropy_write_seed_file()
430 ret = 0; in mbedtls_entropy_write_seed_file()
439 return ret; in mbedtls_entropy_write_seed_file()
444 int ret = 0; in mbedtls_entropy_update_seed_file() local
465 ret = MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR; in mbedtls_entropy_update_seed_file()
467 ret = mbedtls_entropy_update_manual(ctx, buf, n); in mbedtls_entropy_update_seed_file()
474 if (ret != 0) { in mbedtls_entropy_update_seed_file()
475 return ret; in mbedtls_entropy_update_seed_file()
501 int ret = 0; in mbedtls_entropy_source_self_test_gather() local
507 if ((ret = mbedtls_hardware_poll(NULL, buf + entropy_len, in mbedtls_entropy_source_self_test_gather()
509 return ret; in mbedtls_entropy_source_self_test_gather()
517 ret = 1; in mbedtls_entropy_source_self_test_gather()
520 return ret; in mbedtls_entropy_source_self_test_gather()
552 int ret = 0; in mbedtls_entropy_source_self_test() local
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()
580 ret = memcmp(buf0, buf1, sizeof(buf0)) == 0; in mbedtls_entropy_source_self_test()
584 if (ret != 0) { in mbedtls_entropy_source_self_test()
593 return ret != 0; in mbedtls_entropy_source_self_test()
605 int ret = 1; in mbedtls_entropy_self_test() local
618 if ((ret = mbedtls_entropy_gather(&ctx)) != 0) { in mbedtls_entropy_self_test()
622 ret = mbedtls_entropy_add_source(&ctx, entropy_dummy_source, NULL, 16, 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()
652 ret = 1; in mbedtls_entropy_self_test()
658 if ((ret = mbedtls_entropy_source_self_test(0)) != 0) { in mbedtls_entropy_self_test()
667 if (ret != 0) { in mbedtls_entropy_self_test()
676 return ret != 0; in mbedtls_entropy_self_test()