Lines Matching refs:ret
86 int idx, ret = 0; in mbedtls_entropy_add_source() local
89 if ((ret = mbedtls_mutex_lock(&ctx->mutex)) != 0) { in mbedtls_entropy_add_source()
90 return ret; in mbedtls_entropy_add_source()
96 ret = MBEDTLS_ERR_ENTROPY_MAX_SOURCES; in mbedtls_entropy_add_source()
114 return ret; in mbedtls_entropy_add_source()
127 int ret = 0; in entropy_update() local
130 if ((ret = mbedtls_md(mbedtls_md_info_from_type(MBEDTLS_ENTROPY_MD), in entropy_update()
147 ret = mbedtls_md_setup(&ctx->accumulator, in entropy_update()
149 if (ret != 0) { in entropy_update()
152 ret = mbedtls_md_starts(&ctx->accumulator); in entropy_update()
153 if (ret != 0) { in entropy_update()
158 if ((ret = mbedtls_md_update(&ctx->accumulator, header, 2)) != 0) { in entropy_update()
161 ret = mbedtls_md_update(&ctx->accumulator, p, use_len); in entropy_update()
166 return ret; in entropy_update()
172 int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; in mbedtls_entropy_update_manual() local
175 if ((ret = mbedtls_mutex_lock(&ctx->mutex)) != 0) { in mbedtls_entropy_update_manual()
176 return ret; in mbedtls_entropy_update_manual()
180 ret = entropy_update(ctx, MBEDTLS_ENTROPY_SOURCE_MANUAL, data, len); in mbedtls_entropy_update_manual()
188 return ret; in mbedtls_entropy_update_manual()
196 int ret = MBEDTLS_ERR_ENTROPY_SOURCE_FAILED; in entropy_gather_internal() local
215 if ((ret = ctx->source[i].f_source(ctx->source[i].p_source, in entropy_gather_internal()
224 if ((ret = entropy_update(ctx, (unsigned char) i, in entropy_gather_internal()
226 return ret; in entropy_gather_internal()
233 ret = MBEDTLS_ERR_ENTROPY_NO_STRONG_SOURCE; in entropy_gather_internal()
239 return ret; in entropy_gather_internal()
247 int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; in mbedtls_entropy_gather() local
250 if ((ret = mbedtls_mutex_lock(&ctx->mutex)) != 0) { in mbedtls_entropy_gather()
251 return ret; in mbedtls_entropy_gather()
255 ret = entropy_gather_internal(ctx); in mbedtls_entropy_gather()
263 return ret; in mbedtls_entropy_gather()
268 int ret, count = 0, i, thresholds_reached; in mbedtls_entropy_func() local
283 if ((ret = mbedtls_entropy_update_nv_seed(ctx)) != 0) { in mbedtls_entropy_func()
284 return ret; in mbedtls_entropy_func()
290 if ((ret = mbedtls_mutex_lock(&ctx->mutex)) != 0) { in mbedtls_entropy_func()
291 return ret; in mbedtls_entropy_func()
300 ret = MBEDTLS_ERR_ENTROPY_SOURCE_FAILED; in mbedtls_entropy_func()
304 if ((ret = entropy_gather_internal(ctx)) != 0) { in mbedtls_entropy_func()
327 if ((ret = mbedtls_md_finish(&ctx->accumulator, buf)) != 0) { in mbedtls_entropy_func()
336 ret = mbedtls_md_setup(&ctx->accumulator, in mbedtls_entropy_func()
338 if (ret != 0) { in mbedtls_entropy_func()
341 ret = mbedtls_md_starts(&ctx->accumulator); in mbedtls_entropy_func()
342 if (ret != 0) { in mbedtls_entropy_func()
345 if ((ret = mbedtls_md_update(&ctx->accumulator, buf, in mbedtls_entropy_func()
353 if ((ret = mbedtls_md(mbedtls_md_info_from_type(MBEDTLS_ENTROPY_MD), in mbedtls_entropy_func()
364 ret = 0; in mbedtls_entropy_func()
375 return ret; in mbedtls_entropy_func()
381 int ret = MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR; in mbedtls_entropy_update_nv_seed() local
385 if ((ret = mbedtls_entropy_func(ctx, buf, MBEDTLS_ENTROPY_BLOCK_SIZE)) != 0) { in mbedtls_entropy_update_nv_seed()
386 return ret; in mbedtls_entropy_update_nv_seed()
395 ret = mbedtls_entropy_update_manual(ctx, buf, MBEDTLS_ENTROPY_BLOCK_SIZE); in mbedtls_entropy_update_nv_seed()
397 return ret; in mbedtls_entropy_update_nv_seed()
404 int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; in mbedtls_entropy_write_seed_file() local
408 if ((ret = mbedtls_entropy_func(ctx, buf, MBEDTLS_ENTROPY_BLOCK_SIZE)) != 0) { in mbedtls_entropy_write_seed_file()
409 ret = MBEDTLS_ERR_ENTROPY_SOURCE_FAILED; in mbedtls_entropy_write_seed_file()
414 ret = MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR; in mbedtls_entropy_write_seed_file()
422 ret = MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR; in mbedtls_entropy_write_seed_file()
426 ret = 0; in mbedtls_entropy_write_seed_file()
435 return ret; in mbedtls_entropy_write_seed_file()
440 int ret = 0; in mbedtls_entropy_update_seed_file() local
461 ret = MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR; in mbedtls_entropy_update_seed_file()
463 ret = mbedtls_entropy_update_manual(ctx, buf, n); in mbedtls_entropy_update_seed_file()
470 if (ret != 0) { in mbedtls_entropy_update_seed_file()
471 return ret; in mbedtls_entropy_update_seed_file()
497 int ret = 0; in mbedtls_entropy_source_self_test_gather() local
503 if ((ret = mbedtls_hardware_poll(NULL, buf + entropy_len, in mbedtls_entropy_source_self_test_gather()
505 return ret; in mbedtls_entropy_source_self_test_gather()
513 ret = 1; in mbedtls_entropy_source_self_test_gather()
516 return ret; in mbedtls_entropy_source_self_test_gather()
548 int ret = 0; in mbedtls_entropy_source_self_test() local
559 if ((ret = mbedtls_entropy_source_self_test_gather(buf0, sizeof(buf0))) != 0) { in mbedtls_entropy_source_self_test()
562 if ((ret = mbedtls_entropy_source_self_test_gather(buf1, sizeof(buf1))) != 0) { in mbedtls_entropy_source_self_test()
567 if ((ret = mbedtls_entropy_source_self_test_check_bits(buf0, sizeof(buf0))) != 0) { in mbedtls_entropy_source_self_test()
570 if ((ret = mbedtls_entropy_source_self_test_check_bits(buf1, sizeof(buf1))) != 0) { in mbedtls_entropy_source_self_test()
576 ret = memcmp(buf0, buf1, sizeof(buf0)) == 0; in mbedtls_entropy_source_self_test()
580 if (ret != 0) { in mbedtls_entropy_source_self_test()
589 return ret != 0; in mbedtls_entropy_source_self_test()
601 int ret = 1; in mbedtls_entropy_self_test() local
614 if ((ret = mbedtls_entropy_gather(&ctx)) != 0) { in mbedtls_entropy_self_test()
618 ret = mbedtls_entropy_add_source(&ctx, entropy_dummy_source, NULL, 16, in mbedtls_entropy_self_test()
620 if (ret != 0) { in mbedtls_entropy_self_test()
624 if ((ret = mbedtls_entropy_update_manual(&ctx, buf, sizeof(buf))) != 0) { in mbedtls_entropy_self_test()
637 if ((ret = mbedtls_entropy_func(&ctx, buf, sizeof(buf))) != 0) { in mbedtls_entropy_self_test()
648 ret = 1; in mbedtls_entropy_self_test()
654 if ((ret = mbedtls_entropy_source_self_test(0)) != 0) { in mbedtls_entropy_self_test()
663 if (ret != 0) { in mbedtls_entropy_self_test()
672 return ret != 0; in mbedtls_entropy_self_test()