Lines Matching refs:params

94 static int create_merkle_leaf_value(const mbedtls_lms_parameters_t *params,  in create_merkle_leaf_value()  argument
110 status = psa_hash_update(&op, params->I_key_identifier, in create_merkle_leaf_value()
128 MBEDTLS_LMOTS_N_HASH_LEN(params->otstype)); in create_merkle_leaf_value()
133 status = psa_hash_finish(&op, out, MBEDTLS_LMS_M_NODE_BYTES(params->type), in create_merkle_leaf_value()
167 static int create_merkle_internal_value(const mbedtls_lms_parameters_t *params, in create_merkle_internal_value() argument
184 status = psa_hash_update(&op, params->I_key_identifier, in create_merkle_internal_value()
202 MBEDTLS_LMS_M_NODE_BYTES(params->type)); in create_merkle_internal_value()
208 MBEDTLS_LMS_M_NODE_BYTES(params->type)); in create_merkle_internal_value()
213 status = psa_hash_finish(&op, out, MBEDTLS_LMS_M_NODE_BYTES(params->type), in create_merkle_internal_value()
249 ctx->params.type = type; in mbedtls_lms_import_public_key()
251 if (key_size != MBEDTLS_LMS_PUBLIC_KEY_LEN(ctx->params.type)) { in mbedtls_lms_import_public_key()
260 ctx->params.otstype = otstype; in mbedtls_lms_import_public_key()
262 memcpy(ctx->params.I_key_identifier, in mbedtls_lms_import_public_key()
266 MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type)); in mbedtls_lms_import_public_key()
277 if (key_size < MBEDTLS_LMS_PUBLIC_KEY_LEN(ctx->params.type)) { in mbedtls_lms_export_public_key()
285 MBEDTLS_PUT_UINT32_BE(ctx->params.type, key, PUBLIC_KEY_TYPE_OFFSET); in mbedtls_lms_export_public_key()
286 MBEDTLS_PUT_UINT32_BE(ctx->params.otstype, key, PUBLIC_KEY_OTSTYPE_OFFSET); in mbedtls_lms_export_public_key()
288 ctx->params.I_key_identifier, in mbedtls_lms_export_public_key()
292 MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type)); in mbedtls_lms_export_public_key()
295 *key_len = MBEDTLS_LMS_PUBLIC_KEY_LEN(ctx->params.type); in mbedtls_lms_export_public_key()
320 if (ctx->params.type in mbedtls_lms_verify()
325 if (ctx->params.otstype in mbedtls_lms_verify()
330 if (sig_size != MBEDTLS_LMS_SIG_LEN(ctx->params.type, ctx->params.otstype)) { in mbedtls_lms_verify()
343 if (sig_size < SIG_TYPE_OFFSET(ctx->params.otstype) + MBEDTLS_LMS_TYPE_LEN) { in mbedtls_lms_verify()
347 if (MBEDTLS_GET_UINT32_BE(sig, SIG_TYPE_OFFSET(ctx->params.otstype)) in mbedtls_lms_verify()
355 if (q_leaf_identifier >= MERKLE_TREE_LEAF_NODE_AM(ctx->params.type)) { in mbedtls_lms_verify()
360 ctx->params.I_key_identifier, in mbedtls_lms_verify()
363 ots_params.type = ctx->params.otstype; in mbedtls_lms_verify()
369 MBEDTLS_LMOTS_SIG_LEN(ctx->params.otstype), in mbedtls_lms_verify()
378 &ctx->params, in mbedtls_lms_verify()
380 MERKLE_TREE_INTERNAL_NODE_AM(ctx->params.type) + q_leaf_identifier, in mbedtls_lms_verify()
383 curr_node_id = MERKLE_TREE_INTERNAL_NODE_AM(ctx->params.type) + in mbedtls_lms_verify()
386 for (height = 0; height < MBEDTLS_LMS_H_TREE_HEIGHT(ctx->params.type); in mbedtls_lms_verify()
392 left_node = sig + SIG_PATH_OFFSET(ctx->params.otstype) + in mbedtls_lms_verify()
393 height * MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type); in mbedtls_lms_verify()
397 right_node = sig + SIG_PATH_OFFSET(ctx->params.otstype) + in mbedtls_lms_verify()
398 height * MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type); in mbedtls_lms_verify()
401 create_merkle_internal_value(&ctx->params, left_node, right_node, in mbedtls_lms_verify()
408 MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type))) { in mbedtls_lms_verify()
440 priv_key_idx < MERKLE_TREE_INTERNAL_NODE_AM(ctx->params.type); in calculate_merkle_tree()
442 r_node_idx = MERKLE_TREE_INTERNAL_NODE_AM(ctx->params.type) + priv_key_idx; in calculate_merkle_tree()
444 ret = create_merkle_leaf_value(&ctx->params, in calculate_merkle_tree()
448 ctx->params.type)]); in calculate_merkle_tree()
456 for (r_node_idx = MERKLE_TREE_INTERNAL_NODE_AM(ctx->params.type) - 1; in calculate_merkle_tree()
459 ret = create_merkle_internal_value(&ctx->params, in calculate_merkle_tree()
461 MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type)], in calculate_merkle_tree()
463 MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type)], in calculate_merkle_tree()
466 MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type)]); in calculate_merkle_tree()
491 const size_t node_bytes = MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type); in get_merkle_path()
498 tree = mbedtls_calloc((size_t) MERKLE_TREE_NODE_AM(ctx->params.type), in get_merkle_path()
509 for (height = 0; height < MBEDTLS_LMS_H_TREE_HEIGHT(ctx->params.type); in get_merkle_path()
523 (size_t) MERKLE_TREE_NODE_AM(ctx->params.type)); in get_merkle_path()
543 for (idx = 0; idx < MERKLE_TREE_LEAF_NODE_AM(ctx->params.type); idx++) { in mbedtls_lms_private_free()
549 for (idx = 0; idx < MERKLE_TREE_LEAF_NODE_AM(ctx->params.type); idx++) { in mbedtls_lms_private_free()
584 ctx->params.type = type; in mbedtls_lms_generate_private_key()
585 ctx->params.otstype = otstype; in mbedtls_lms_generate_private_key()
589 ctx->params.I_key_identifier, in mbedtls_lms_generate_private_key()
597 ctx->ots_private_keys = mbedtls_calloc((size_t) MERKLE_TREE_LEAF_NODE_AM(ctx->params.type), in mbedtls_lms_generate_private_key()
606 ctx->ots_public_keys = mbedtls_calloc((size_t) MERKLE_TREE_LEAF_NODE_AM(ctx->params.type), in mbedtls_lms_generate_private_key()
613 for (idx = 0; idx < MERKLE_TREE_LEAF_NODE_AM(ctx->params.type); idx++) { in mbedtls_lms_generate_private_key()
619 for (idx = 0; idx < MERKLE_TREE_LEAF_NODE_AM(ctx->params.type); idx++) { in mbedtls_lms_generate_private_key()
622 ctx->params.I_key_identifier, in mbedtls_lms_generate_private_key()
648 const size_t node_bytes = MBEDTLS_LMS_M_NODE_BYTES(priv_ctx->params.type); in mbedtls_lms_calculate_public_key()
656 if (priv_ctx->params.type in mbedtls_lms_calculate_public_key()
661 if (priv_ctx->params.otstype in mbedtls_lms_calculate_public_key()
666 tree = mbedtls_calloc((size_t) MERKLE_TREE_NODE_AM(priv_ctx->params.type), in mbedtls_lms_calculate_public_key()
672 memcpy(&ctx->params, &priv_ctx->params, in mbedtls_lms_calculate_public_key()
689 (size_t) MERKLE_TREE_NODE_AM(priv_ctx->params.type)); in mbedtls_lms_calculate_public_key()
708 if (sig_size < MBEDTLS_LMS_SIG_LEN(ctx->params.type, ctx->params.otstype)) { in mbedtls_lms_sign()
712 if (ctx->params.type != MBEDTLS_LMS_SHA256_M32_H10) { in mbedtls_lms_sign()
716 if (ctx->params.otstype in mbedtls_lms_sign()
721 if (ctx->q_next_usable_key >= MERKLE_TREE_LEAF_NODE_AM(ctx->params.type)) { in mbedtls_lms_sign()
732 if (MBEDTLS_LMS_SIG_LEN(ctx->params.type, ctx->params.otstype) in mbedtls_lms_sign()
743 MBEDTLS_LMS_SIG_LEN(ctx->params.type, in mbedtls_lms_sign()
744 ctx->params.otstype) - SIG_OTS_SIG_OFFSET, in mbedtls_lms_sign()
750 MBEDTLS_PUT_UINT32_BE(ctx->params.type, sig, SIG_TYPE_OFFSET(ctx->params.otstype)); in mbedtls_lms_sign()
754 MERKLE_TREE_INTERNAL_NODE_AM(ctx->params.type) + q_leaf_identifier, in mbedtls_lms_sign()
755 sig + SIG_PATH_OFFSET(ctx->params.otstype)); in mbedtls_lms_sign()
761 *sig_len = MBEDTLS_LMS_SIG_LEN(ctx->params.type, ctx->params.otstype); in mbedtls_lms_sign()