Lines Matching refs:params

94 static int create_merkle_leaf_value(const mbedtls_lms_parameters_t *params,  in create_merkle_leaf_value()  argument
105 memset(out, 0, MBEDTLS_LMS_M_NODE_BYTES(params->type)); in create_merkle_leaf_value()
113 status = psa_hash_update(&op, params->I_key_identifier, in create_merkle_leaf_value()
131 MBEDTLS_LMOTS_N_HASH_LEN(params->otstype)); in create_merkle_leaf_value()
136 status = psa_hash_finish(&op, out, MBEDTLS_LMS_M_NODE_BYTES(params->type), in create_merkle_leaf_value()
170 static int create_merkle_internal_value(const mbedtls_lms_parameters_t *params, in create_merkle_internal_value() argument
187 status = psa_hash_update(&op, params->I_key_identifier, in create_merkle_internal_value()
205 MBEDTLS_LMS_M_NODE_BYTES(params->type)); in create_merkle_internal_value()
211 MBEDTLS_LMS_M_NODE_BYTES(params->type)); in create_merkle_internal_value()
216 status = psa_hash_finish(&op, out, MBEDTLS_LMS_M_NODE_BYTES(params->type), in create_merkle_internal_value()
253 ctx->params.type = (mbedtls_lms_algorithm_type_t) type; in mbedtls_lms_import_public_key()
255 if (key_size != MBEDTLS_LMS_PUBLIC_KEY_LEN(ctx->params.type)) { in mbedtls_lms_import_public_key()
263 ctx->params.otstype = (mbedtls_lmots_algorithm_type_t) otstype; in mbedtls_lms_import_public_key()
265 memcpy(ctx->params.I_key_identifier, in mbedtls_lms_import_public_key()
269 MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type)); in mbedtls_lms_import_public_key()
280 if (key_size < MBEDTLS_LMS_PUBLIC_KEY_LEN(ctx->params.type)) { in mbedtls_lms_export_public_key()
288 MBEDTLS_PUT_UINT32_BE(ctx->params.type, key, PUBLIC_KEY_TYPE_OFFSET); in mbedtls_lms_export_public_key()
289 MBEDTLS_PUT_UINT32_BE(ctx->params.otstype, key, PUBLIC_KEY_OTSTYPE_OFFSET); in mbedtls_lms_export_public_key()
291 ctx->params.I_key_identifier, in mbedtls_lms_export_public_key()
295 MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type)); in mbedtls_lms_export_public_key()
298 *key_len = MBEDTLS_LMS_PUBLIC_KEY_LEN(ctx->params.type); in mbedtls_lms_export_public_key()
323 if (ctx->params.type in mbedtls_lms_verify()
328 if (ctx->params.otstype in mbedtls_lms_verify()
333 if (sig_size != MBEDTLS_LMS_SIG_LEN(ctx->params.type, ctx->params.otstype)) { in mbedtls_lms_verify()
346 if (sig_size < SIG_TYPE_OFFSET(ctx->params.otstype) + MBEDTLS_LMS_TYPE_LEN) { in mbedtls_lms_verify()
350 if (MBEDTLS_GET_UINT32_BE(sig, SIG_TYPE_OFFSET(ctx->params.otstype)) in mbedtls_lms_verify()
358 if (q_leaf_identifier >= MERKLE_TREE_LEAF_NODE_AM(ctx->params.type)) { in mbedtls_lms_verify()
363 ctx->params.I_key_identifier, in mbedtls_lms_verify()
366 ots_params.type = ctx->params.otstype; in mbedtls_lms_verify()
372 MBEDTLS_LMOTS_SIG_LEN(ctx->params.otstype), in mbedtls_lms_verify()
381 &ctx->params, in mbedtls_lms_verify()
383 MERKLE_TREE_INTERNAL_NODE_AM(ctx->params.type) + q_leaf_identifier, in mbedtls_lms_verify()
390 curr_node_id = MERKLE_TREE_INTERNAL_NODE_AM(ctx->params.type) + in mbedtls_lms_verify()
393 for (height = 0; height < MBEDTLS_LMS_H_TREE_HEIGHT(ctx->params.type); in mbedtls_lms_verify()
399 left_node = sig + SIG_PATH_OFFSET(ctx->params.otstype) + in mbedtls_lms_verify()
400 height * MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type); in mbedtls_lms_verify()
404 right_node = sig + SIG_PATH_OFFSET(ctx->params.otstype) + in mbedtls_lms_verify()
405 height * MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type); in mbedtls_lms_verify()
408 ret = create_merkle_internal_value(&ctx->params, left_node, right_node, in mbedtls_lms_verify()
417 MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type))) { in mbedtls_lms_verify()
449 priv_key_idx < MERKLE_TREE_INTERNAL_NODE_AM(ctx->params.type); in calculate_merkle_tree()
451 r_node_idx = MERKLE_TREE_INTERNAL_NODE_AM(ctx->params.type) + priv_key_idx; in calculate_merkle_tree()
453 ret = create_merkle_leaf_value(&ctx->params, in calculate_merkle_tree()
457 ctx->params.type)]); in calculate_merkle_tree()
465 for (r_node_idx = MERKLE_TREE_INTERNAL_NODE_AM(ctx->params.type) - 1; in calculate_merkle_tree()
468 ret = create_merkle_internal_value(&ctx->params, in calculate_merkle_tree()
470 MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type)], in calculate_merkle_tree()
472 MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type)], in calculate_merkle_tree()
475 MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type)]); in calculate_merkle_tree()
500 const size_t node_bytes = MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type); in get_merkle_path()
507 tree = mbedtls_calloc((size_t) MERKLE_TREE_NODE_AM(ctx->params.type), in get_merkle_path()
518 for (height = 0; height < MBEDTLS_LMS_H_TREE_HEIGHT(ctx->params.type); in get_merkle_path()
532 (size_t) MERKLE_TREE_NODE_AM(ctx->params.type)); in get_merkle_path()
552 for (idx = 0; idx < MERKLE_TREE_LEAF_NODE_AM(ctx->params.type); idx++) { in mbedtls_lms_private_free()
558 for (idx = 0; idx < MERKLE_TREE_LEAF_NODE_AM(ctx->params.type); idx++) { in mbedtls_lms_private_free()
593 ctx->params.type = type; in mbedtls_lms_generate_private_key()
594 ctx->params.otstype = otstype; in mbedtls_lms_generate_private_key()
598 ctx->params.I_key_identifier, in mbedtls_lms_generate_private_key()
606 ctx->ots_private_keys = mbedtls_calloc((size_t) MERKLE_TREE_LEAF_NODE_AM(ctx->params.type), in mbedtls_lms_generate_private_key()
615 ctx->ots_public_keys = mbedtls_calloc((size_t) MERKLE_TREE_LEAF_NODE_AM(ctx->params.type), in mbedtls_lms_generate_private_key()
622 for (idx = 0; idx < MERKLE_TREE_LEAF_NODE_AM(ctx->params.type); idx++) { in mbedtls_lms_generate_private_key()
628 for (idx = 0; idx < MERKLE_TREE_LEAF_NODE_AM(ctx->params.type); idx++) { in mbedtls_lms_generate_private_key()
631 ctx->params.I_key_identifier, in mbedtls_lms_generate_private_key()
657 const size_t node_bytes = MBEDTLS_LMS_M_NODE_BYTES(priv_ctx->params.type); in mbedtls_lms_calculate_public_key()
665 if (priv_ctx->params.type in mbedtls_lms_calculate_public_key()
670 if (priv_ctx->params.otstype in mbedtls_lms_calculate_public_key()
675 tree = mbedtls_calloc((size_t) MERKLE_TREE_NODE_AM(priv_ctx->params.type), in mbedtls_lms_calculate_public_key()
681 memcpy(&ctx->params, &priv_ctx->params, in mbedtls_lms_calculate_public_key()
698 (size_t) MERKLE_TREE_NODE_AM(priv_ctx->params.type)); in mbedtls_lms_calculate_public_key()
717 if (sig_size < MBEDTLS_LMS_SIG_LEN(ctx->params.type, ctx->params.otstype)) { in mbedtls_lms_sign()
721 if (ctx->params.type != MBEDTLS_LMS_SHA256_M32_H10) { in mbedtls_lms_sign()
725 if (ctx->params.otstype in mbedtls_lms_sign()
730 if (ctx->q_next_usable_key >= MERKLE_TREE_LEAF_NODE_AM(ctx->params.type)) { in mbedtls_lms_sign()
741 if (MBEDTLS_LMS_SIG_LEN(ctx->params.type, ctx->params.otstype) in mbedtls_lms_sign()
752 MBEDTLS_LMS_SIG_LEN(ctx->params.type, in mbedtls_lms_sign()
753 ctx->params.otstype) - SIG_OTS_SIG_OFFSET, in mbedtls_lms_sign()
759 MBEDTLS_PUT_UINT32_BE(ctx->params.type, sig, SIG_TYPE_OFFSET(ctx->params.otstype)); in mbedtls_lms_sign()
763 MERKLE_TREE_INTERNAL_NODE_AM(ctx->params.type) + q_leaf_identifier, in mbedtls_lms_sign()
764 sig + SIG_PATH_OFFSET(ctx->params.otstype)); in mbedtls_lms_sign()
770 *sig_len = MBEDTLS_LMS_SIG_LEN(ctx->params.type, ctx->params.otstype); in mbedtls_lms_sign()