blob: 71921f7cb5f44758a4a93c00992669732fbe2095 [file] [log] [blame]
Raef Coles8ff6df52021-07-21 12:42:15 +01001/*
2 * The LMS stateful-hash public-key signature scheme
3 *
4 * Copyright The Mbed TLS Contributors
5 * SPDX-License-Identifier: Apache-2.0
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may
8 * not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19
20/*
21 * The following sources were referenced in the design of this implementation
22 * of the LMS algorithm:
23 *
24 * [1] IETF RFC8554
25 * D. McGrew, M. Curcio, S.Fluhrer
26 * https://datatracker.ietf.org/doc/html/rfc8554
27 *
28 * [2] NIST Special Publication 800-208
29 * David A. Cooper et. al.
30 * https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-208.pdf
31 */
32
33#include "common.h"
34
35#ifdef MBEDTLS_LMS_C
36
37#include <string.h>
38
Raef Coles7dce69a2022-08-24 14:07:06 +010039#include "lmots.h"
40
Raef Colesc8f96042022-08-25 13:49:54 +010041#include "psa/crypto.h"
42
Raef Coles8ff6df52021-07-21 12:42:15 +010043#include "mbedtls/lms.h"
Raef Coles8ff6df52021-07-21 12:42:15 +010044#include "mbedtls/error.h"
45#include "mbedtls/platform_util.h"
46
47#if defined(MBEDTLS_PLATFORM_C)
48#include "mbedtls/platform.h"
49#else
50#include <stdlib.h>
51#include <stdio.h>
52#define mbedtls_printf printf
53#define mbedtls_calloc calloc
54#define mbedtls_free free
55#endif
56
Raef Colese9479a02022-09-01 16:06:35 +010057#define MBEDTLS_LMS_SIG_Q_LEAF_ID_OFFSET (0)
58#define MBEDTLS_LMS_SIG_OTS_SIG_OFFSET (MBEDTLS_LMS_SIG_Q_LEAF_ID_OFFSET + MBEDTLS_LMOTS_Q_LEAF_ID_LEN)
59#define MBEDTLS_LMS_SIG_TYPE_OFFSET(otstype) (MBEDTLS_LMS_SIG_OTS_SIG_OFFSET + MBEDTLS_LMOTS_SIG_LEN(otstype))
60#define MBEDTLS_LMS_SIG_PATH_OFFSET(otstype) (MBEDTLS_LMS_SIG_TYPE_OFFSET(otstype) + MBEDTLS_LMS_TYPE_LEN)
Raef Coles01c71a12022-08-31 15:55:00 +010061
62#define MBEDTLS_LMS_PUBLIC_KEY_TYPE_OFFSET (0)
63#define MBEDTLS_LMS_PUBLIC_KEY_OTSTYPE_OFFSET (MBEDTLS_LMS_PUBLIC_KEY_TYPE_OFFSET + MBEDTLS_LMS_TYPE_LEN)
64#define MBEDTLS_LMS_PUBLIC_KEY_I_KEY_ID_OFFSET (MBEDTLS_LMS_PUBLIC_KEY_OTSTYPE_OFFSET + MBEDTLS_LMOTS_TYPE_LEN)
65#define MBEDTLS_LMS_PUBLIC_KEY_ROOT_NODE_OFFSET (MBEDTLS_LMS_PUBLIC_KEY_I_KEY_ID_OFFSET + MBEDTLS_LMOTS_I_KEY_ID_LEN)
66
67
Raef Colese9479a02022-09-01 16:06:35 +010068/* Currently only support H=10 */
69#define MBEDTLS_LMS_H_TREE_HEIGHT_MAX 10
70#define MERKLE_TREE_NODE_AM_MAX (1u << (MBEDTLS_LMS_H_TREE_HEIGHT_MAX + 1u))
71#define MERKLE_TREE_NODE_AM(type) (1u << (MBEDTLS_LMS_H_TREE_HEIGHT(type) + 1u))
72#define MERKLE_TREE_LEAF_NODE_AM(type) (1u << MBEDTLS_LMS_H_TREE_HEIGHT(type))
73#define MERKLE_TREE_INTERNAL_NODE_AM(type) (1u << MBEDTLS_LMS_H_TREE_HEIGHT(type))
Raef Coles8ff6df52021-07-21 12:42:15 +010074
75#define D_CONST_LEN (2)
Raef Coles01c71a12022-08-31 15:55:00 +010076static const unsigned char D_LEAF_CONSTANT_BYTES[D_CONST_LEN] = {0x82, 0x82};
77static const unsigned char D_INTERNAL_CONSTANT_BYTES[D_CONST_LEN] = {0x83, 0x83};
Raef Coles8ff6df52021-07-21 12:42:15 +010078
Raef Colese9479a02022-09-01 16:06:35 +010079static int create_merkle_leaf_value( const mbedtls_lms_parameters_t *params,
80 unsigned char *pub_key,
Raef Colesebd35b52022-09-01 11:52:17 +010081 unsigned int r_node_idx,
Raef Colese9479a02022-09-01 16:06:35 +010082 unsigned char *out )
Raef Coles8ff6df52021-07-21 12:42:15 +010083{
Raef Colesc8f96042022-08-25 13:49:54 +010084 psa_hash_operation_t op;
85 psa_status_t status;
86 size_t output_hash_len;
Raef Coles8ff6df52021-07-21 12:42:15 +010087 unsigned char r_node_idx_bytes[4];
88 int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
89
Raef Colesc8f96042022-08-25 13:49:54 +010090 op = psa_hash_operation_init( );
91 status = psa_hash_setup( &op, PSA_ALG_SHA_256 );
92 ret = mbedtls_lms_error_from_psa( status );
93 if ( ret != 0 )
Raef Coles01c71a12022-08-31 15:55:00 +010094 goto exit;
Raef Coles8ff6df52021-07-21 12:42:15 +010095
Raef Colese9479a02022-09-01 16:06:35 +010096 status = psa_hash_update( &op, params->I_key_identifier,
97 MBEDTLS_LMOTS_I_KEY_ID_LEN );
Raef Colesc8f96042022-08-25 13:49:54 +010098 ret = mbedtls_lms_error_from_psa( status );
Raef Coles8ff6df52021-07-21 12:42:15 +010099 if( ret )
Raef Coles01c71a12022-08-31 15:55:00 +0100100 goto exit;
Raef Coles8ff6df52021-07-21 12:42:15 +0100101
Raef Coles01c71a12022-08-31 15:55:00 +0100102 unsigned_int_to_network_bytes( r_node_idx, 4, r_node_idx_bytes );
Raef Colesc8f96042022-08-25 13:49:54 +0100103 status = psa_hash_update( &op, r_node_idx_bytes, 4 );
104 ret = mbedtls_lms_error_from_psa( status );
Raef Coles8ff6df52021-07-21 12:42:15 +0100105 if( ret )
Raef Coles01c71a12022-08-31 15:55:00 +0100106 goto exit;
Raef Coles8ff6df52021-07-21 12:42:15 +0100107
Raef Coles01c71a12022-08-31 15:55:00 +0100108 status = psa_hash_update( &op, D_LEAF_CONSTANT_BYTES, D_CONST_LEN );
Raef Colesc8f96042022-08-25 13:49:54 +0100109 ret = mbedtls_lms_error_from_psa( status );
Raef Coles8ff6df52021-07-21 12:42:15 +0100110 if( ret )
Raef Coles01c71a12022-08-31 15:55:00 +0100111 goto exit;
Raef Coles8ff6df52021-07-21 12:42:15 +0100112
Raef Colese9479a02022-09-01 16:06:35 +0100113 status = psa_hash_update( &op, pub_key,
114 MBEDTLS_LMOTS_N_HASH_LEN(params->otstype) );
Raef Colesc8f96042022-08-25 13:49:54 +0100115 ret = mbedtls_lms_error_from_psa( status );
Raef Coles8ff6df52021-07-21 12:42:15 +0100116 if( ret )
Raef Coles01c71a12022-08-31 15:55:00 +0100117 goto exit;
Raef Coles8ff6df52021-07-21 12:42:15 +0100118
Raef Colese9479a02022-09-01 16:06:35 +0100119 status = psa_hash_finish( &op, out, MBEDTLS_LMS_M_NODE_BYTES(params->type),
120 &output_hash_len);
Raef Colesc8f96042022-08-25 13:49:54 +0100121 ret = mbedtls_lms_error_from_psa( status );
Raef Coles8ff6df52021-07-21 12:42:15 +0100122 if( ret )
Raef Coles01c71a12022-08-31 15:55:00 +0100123 goto exit;
Raef Coles8ff6df52021-07-21 12:42:15 +0100124
Raef Coles01c71a12022-08-31 15:55:00 +0100125exit:
Raef Colesc8f96042022-08-25 13:49:54 +0100126 psa_hash_abort( &op );
Raef Coles8ff6df52021-07-21 12:42:15 +0100127
128 return( ret );
129}
130
Raef Colese9479a02022-09-01 16:06:35 +0100131static int create_merkle_internal_value( const mbedtls_lms_parameters_t *params,
132 const unsigned char *left_node,
133 const unsigned char *right_node,
Raef Colesebd35b52022-09-01 11:52:17 +0100134 unsigned int r_node_idx,
Raef Colese9479a02022-09-01 16:06:35 +0100135 unsigned char *out )
Raef Coles8ff6df52021-07-21 12:42:15 +0100136{
Raef Colesc8f96042022-08-25 13:49:54 +0100137 psa_hash_operation_t op;
138 psa_status_t status;
139 size_t output_hash_len;
Raef Coles8ff6df52021-07-21 12:42:15 +0100140 unsigned char r_node_idx_bytes[4];
141 int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
142
Raef Colesc8f96042022-08-25 13:49:54 +0100143 op = psa_hash_operation_init( );
144 status = psa_hash_setup( &op, PSA_ALG_SHA_256 );
145 ret = mbedtls_lms_error_from_psa( status );
146 if ( ret != 0 )
Raef Coles01c71a12022-08-31 15:55:00 +0100147 goto exit;
Raef Coles8ff6df52021-07-21 12:42:15 +0100148
Raef Colese9479a02022-09-01 16:06:35 +0100149 status = psa_hash_update( &op, params->I_key_identifier,
150 MBEDTLS_LMOTS_I_KEY_ID_LEN );
Raef Colesc8f96042022-08-25 13:49:54 +0100151 ret = mbedtls_lms_error_from_psa( status );
Raef Coles8ff6df52021-07-21 12:42:15 +0100152 if( ret )
Raef Coles01c71a12022-08-31 15:55:00 +0100153 goto exit;
Raef Coles8ff6df52021-07-21 12:42:15 +0100154
Raef Coles01c71a12022-08-31 15:55:00 +0100155 unsigned_int_to_network_bytes( r_node_idx, 4, r_node_idx_bytes );
Raef Colesc8f96042022-08-25 13:49:54 +0100156 status = psa_hash_update( &op, r_node_idx_bytes, 4 );
157 ret = mbedtls_lms_error_from_psa( status );
Raef Coles8ff6df52021-07-21 12:42:15 +0100158 if( ret )
Raef Coles01c71a12022-08-31 15:55:00 +0100159 goto exit;
Raef Coles8ff6df52021-07-21 12:42:15 +0100160
Raef Coles01c71a12022-08-31 15:55:00 +0100161 status = psa_hash_update( &op, D_INTERNAL_CONSTANT_BYTES, D_CONST_LEN );
Raef Colesc8f96042022-08-25 13:49:54 +0100162 ret = mbedtls_lms_error_from_psa( status );
Raef Coles8ff6df52021-07-21 12:42:15 +0100163 if( ret )
Raef Coles01c71a12022-08-31 15:55:00 +0100164 goto exit;
Raef Coles8ff6df52021-07-21 12:42:15 +0100165
Raef Colese9479a02022-09-01 16:06:35 +0100166 status = psa_hash_update( &op, left_node,
167 MBEDTLS_LMS_M_NODE_BYTES(params->type) );
Raef Colesc8f96042022-08-25 13:49:54 +0100168 ret = mbedtls_lms_error_from_psa( status );
Raef Coles8ff6df52021-07-21 12:42:15 +0100169 if( ret )
Raef Coles01c71a12022-08-31 15:55:00 +0100170 goto exit;
Raef Coles8ff6df52021-07-21 12:42:15 +0100171
Raef Colese9479a02022-09-01 16:06:35 +0100172 status = psa_hash_update( &op, right_node,
173 MBEDTLS_LMS_M_NODE_BYTES(params->type) );
Raef Colesc8f96042022-08-25 13:49:54 +0100174 ret = mbedtls_lms_error_from_psa( status );
Raef Coles8ff6df52021-07-21 12:42:15 +0100175 if( ret )
Raef Coles01c71a12022-08-31 15:55:00 +0100176 goto exit;
Raef Coles8ff6df52021-07-21 12:42:15 +0100177
Raef Colese9479a02022-09-01 16:06:35 +0100178 ret = psa_hash_finish( &op, out, MBEDTLS_LMS_M_NODE_BYTES(params->type),
179 &output_hash_len);
Raef Colesc8f96042022-08-25 13:49:54 +0100180 ret = mbedtls_lms_error_from_psa( status );
Raef Coles8ff6df52021-07-21 12:42:15 +0100181 if( ret )
Raef Coles01c71a12022-08-31 15:55:00 +0100182 goto exit;
Raef Coles8ff6df52021-07-21 12:42:15 +0100183
Raef Coles01c71a12022-08-31 15:55:00 +0100184exit:
Raef Colesc8f96042022-08-25 13:49:54 +0100185 psa_hash_abort( &op );
Raef Coles8ff6df52021-07-21 12:42:15 +0100186
187 return ret;
188}
189
Raef Coles01c71a12022-08-31 15:55:00 +0100190void mbedtls_lms_init_public( mbedtls_lms_public_t *ctx )
Raef Coles8ff6df52021-07-21 12:42:15 +0100191{
Raef Coles01c71a12022-08-31 15:55:00 +0100192 mbedtls_platform_zeroize( ctx, sizeof( mbedtls_lms_public_t ) ) ;
Raef Coles8ff6df52021-07-21 12:42:15 +0100193}
194
Raef Coles01c71a12022-08-31 15:55:00 +0100195void mbedtls_lms_free_public( mbedtls_lms_public_t *ctx )
Raef Coles8ff6df52021-07-21 12:42:15 +0100196{
Raef Coles01c71a12022-08-31 15:55:00 +0100197 mbedtls_platform_zeroize( ctx, sizeof( mbedtls_lms_public_t ) );
Raef Coles8ff6df52021-07-21 12:42:15 +0100198}
199
Raef Coles01c71a12022-08-31 15:55:00 +0100200int mbedtls_lms_import_public_key( mbedtls_lms_public_t *ctx,
201 const unsigned char *key, size_t key_size )
Raef Coles8ff6df52021-07-21 12:42:15 +0100202{
Raef Coles01c71a12022-08-31 15:55:00 +0100203 mbedtls_lms_algorithm_type_t type;
204 mbedtls_lmots_algorithm_type_t otstype;
205
Raef Colese9479a02022-09-01 16:06:35 +0100206 if( key_size < MBEDTLS_LMS_PUBLIC_KEY_LEN(ctx->params.type) )
Raef Coles01c71a12022-08-31 15:55:00 +0100207 {
208 return( MBEDTLS_ERR_LMS_BUFFER_TOO_SMALL );
209 }
210
211 type = network_bytes_to_unsigned_int( MBEDTLS_LMS_TYPE_LEN, key + MBEDTLS_LMS_PUBLIC_KEY_TYPE_OFFSET );
212 if( type != MBEDTLS_LMS_SHA256_M32_H10 )
Raef Coles8ff6df52021-07-21 12:42:15 +0100213 {
214 return( MBEDTLS_ERR_LMS_BAD_INPUT_DATA );
215 }
Raef Colesf5632d32022-09-01 09:56:52 +0100216 ctx->params.type = type;
Raef Coles8ff6df52021-07-21 12:42:15 +0100217
Raef Coles01c71a12022-08-31 15:55:00 +0100218 otstype = network_bytes_to_unsigned_int( MBEDTLS_LMOTS_TYPE_LEN,
219 key + MBEDTLS_LMS_PUBLIC_KEY_OTSTYPE_OFFSET );
220 if( otstype != MBEDTLS_LMOTS_SHA256_N32_W8 )
221 {
222 return( MBEDTLS_ERR_LMS_BAD_INPUT_DATA );
223 }
Raef Colesf5632d32022-09-01 09:56:52 +0100224 ctx->params.otstype = otstype;
Raef Coles01c71a12022-08-31 15:55:00 +0100225
Raef Colesf5632d32022-09-01 09:56:52 +0100226 memcpy( ctx->params.I_key_identifier,
Raef Coles01c71a12022-08-31 15:55:00 +0100227 key + MBEDTLS_LMS_PUBLIC_KEY_I_KEY_ID_OFFSET,
228 MBEDTLS_LMOTS_I_KEY_ID_LEN );
Raef Colesf5632d32022-09-01 09:56:52 +0100229 memcpy( ctx->T_1_pub_key, key + MBEDTLS_LMS_PUBLIC_KEY_ROOT_NODE_OFFSET,
Raef Colese9479a02022-09-01 16:06:35 +0100230 MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type) );
Raef Coles01c71a12022-08-31 15:55:00 +0100231
Raef Colesf5632d32022-09-01 09:56:52 +0100232 ctx->have_public_key = 1;
Raef Coles8ff6df52021-07-21 12:42:15 +0100233
234 return( 0 );
235}
236
Raef Coles01c71a12022-08-31 15:55:00 +0100237int mbedtls_lms_verify( const mbedtls_lms_public_t *ctx,
238 const unsigned char *msg, size_t msg_size,
239 const unsigned char *sig, size_t sig_size )
Raef Coles8ff6df52021-07-21 12:42:15 +0100240{
241 unsigned int q_leaf_identifier;
Raef Colese9479a02022-09-01 16:06:35 +0100242 unsigned char Kc_candidate_ots_pub_key[MBEDTLS_LMOTS_N_HASH_LEN_MAX];
243 unsigned char Tc_candidate_root_node[MBEDTLS_LMS_M_NODE_BYTES_MAX];
Raef Coles8ff6df52021-07-21 12:42:15 +0100244 unsigned int height;
245 unsigned int curr_node_id;
246 unsigned int parent_node_id;
247 const unsigned char* left_node;
Raef Coles01c71a12022-08-31 15:55:00 +0100248 const unsigned char* right_node;
249 mbedtls_lmots_parameters_t ots_params;
Raef Coles8ff6df52021-07-21 12:42:15 +0100250 int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
251
Raef Colesf5632d32022-09-01 09:56:52 +0100252 if( ! ctx->have_public_key )
Raef Coles8ff6df52021-07-21 12:42:15 +0100253 {
254 return( MBEDTLS_ERR_LMS_BAD_INPUT_DATA );
255 }
256
Raef Colese9479a02022-09-01 16:06:35 +0100257 if( sig_size != MBEDTLS_LMS_SIG_LEN(ctx->params.type, ctx->params.otstype) )
Raef Coles8ff6df52021-07-21 12:42:15 +0100258 {
259 return( MBEDTLS_ERR_LMS_BAD_INPUT_DATA );
260 }
261
Raef Colesf5632d32022-09-01 09:56:52 +0100262 if( ctx->params.type
Raef Coles01c71a12022-08-31 15:55:00 +0100263 != MBEDTLS_LMS_SHA256_M32_H10 )
Raef Coles8ff6df52021-07-21 12:42:15 +0100264 {
265 return( MBEDTLS_ERR_LMS_BAD_INPUT_DATA );
266 }
267
Raef Colesf5632d32022-09-01 09:56:52 +0100268 if( ctx->params.otstype
Raef Coles01c71a12022-08-31 15:55:00 +0100269 != MBEDTLS_LMOTS_SHA256_N32_W8 )
Raef Coles8ff6df52021-07-21 12:42:15 +0100270 {
271 return( MBEDTLS_ERR_LMS_BAD_INPUT_DATA );
272 }
273
Raef Colese9479a02022-09-01 16:06:35 +0100274 if( network_bytes_to_unsigned_int( MBEDTLS_LMOTS_TYPE_LEN,
275 sig + MBEDTLS_LMS_SIG_OTS_SIG_OFFSET + MBEDTLS_LMOTS_SIG_TYPE_OFFSET)
276 != MBEDTLS_LMOTS_SHA256_N32_W8 )
Raef Coles8ff6df52021-07-21 12:42:15 +0100277 {
278 return( MBEDTLS_ERR_LMS_VERIFY_FAILED );
279 }
280
Raef Colese9479a02022-09-01 16:06:35 +0100281 if( network_bytes_to_unsigned_int( MBEDTLS_LMS_TYPE_LEN,
282 sig + MBEDTLS_LMS_SIG_TYPE_OFFSET(ctx->params.otstype))
283 != MBEDTLS_LMS_SHA256_M32_H10 )
Raef Coles8ff6df52021-07-21 12:42:15 +0100284 {
285 return( MBEDTLS_ERR_LMS_VERIFY_FAILED );
286 }
287
288
Raef Coles01c71a12022-08-31 15:55:00 +0100289 q_leaf_identifier = network_bytes_to_unsigned_int( MBEDTLS_LMOTS_Q_LEAF_ID_LEN,
Raef Coles8ff6df52021-07-21 12:42:15 +0100290 sig + MBEDTLS_LMS_SIG_Q_LEAF_ID_OFFSET );
291
Raef Colese9479a02022-09-01 16:06:35 +0100292 if( q_leaf_identifier >= MERKLE_TREE_LEAF_NODE_AM(ctx->params.type) )
Raef Coles8ff6df52021-07-21 12:42:15 +0100293 {
294 return( MBEDTLS_ERR_LMS_VERIFY_FAILED );
295 }
296
Raef Colesf5632d32022-09-01 09:56:52 +0100297 memcpy(ots_params.I_key_identifier,
298 ctx->params.I_key_identifier,
Raef Coles01c71a12022-08-31 15:55:00 +0100299 MBEDTLS_LMOTS_I_KEY_ID_LEN);
300 unsigned_int_to_network_bytes( q_leaf_identifier,
301 MBEDTLS_LMOTS_Q_LEAF_ID_LEN,
Raef Colesf5632d32022-09-01 09:56:52 +0100302 ots_params.q_leaf_identifier );
303 ots_params.type = ctx->params.otstype;
Raef Coles01c71a12022-08-31 15:55:00 +0100304
305 ret = mbedtls_lmots_calculate_public_key_candidate( &ots_params, msg, msg_size,
306 sig + MBEDTLS_LMS_SIG_OTS_SIG_OFFSET,
Raef Colese9479a02022-09-01 16:06:35 +0100307 MBEDTLS_LMOTS_SIG_LEN(ctx->params.otstype),
Raef Coles01c71a12022-08-31 15:55:00 +0100308 Kc_candidate_ots_pub_key,
309 sizeof(Kc_candidate_ots_pub_key),
310 NULL );
Raef Coles8ff6df52021-07-21 12:42:15 +0100311 if( ret )
312 {
313 return( ret );
314 }
315
Raef Colesebd35b52022-09-01 11:52:17 +0100316 create_merkle_leaf_value(
Raef Colese9479a02022-09-01 16:06:35 +0100317 &ctx->params,
318 Kc_candidate_ots_pub_key,
319 MERKLE_TREE_INTERNAL_NODE_AM(ctx->params.type) + q_leaf_identifier,
Raef Coles01c71a12022-08-31 15:55:00 +0100320 Tc_candidate_root_node );
Raef Coles8ff6df52021-07-21 12:42:15 +0100321
Raef Colese9479a02022-09-01 16:06:35 +0100322 curr_node_id = MERKLE_TREE_INTERNAL_NODE_AM(ctx->params.type) + q_leaf_identifier;
Raef Coles8ff6df52021-07-21 12:42:15 +0100323
Raef Colese9479a02022-09-01 16:06:35 +0100324 for( height = 0; height < MBEDTLS_LMS_H_TREE_HEIGHT(ctx->params.type);
325 height++ )
Raef Coles8ff6df52021-07-21 12:42:15 +0100326 {
327 parent_node_id = curr_node_id / 2;
328
329 /* Left/right node ordering matters for the hash */
330 if( curr_node_id & 1 )
331 {
Raef Colese9479a02022-09-01 16:06:35 +0100332 left_node = sig + MBEDTLS_LMS_SIG_PATH_OFFSET(ctx->params.otstype) +
333 height * MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type);
Raef Coles01c71a12022-08-31 15:55:00 +0100334 right_node = Tc_candidate_root_node;
Raef Coles8ff6df52021-07-21 12:42:15 +0100335 }
336 else
337 {
338 left_node = Tc_candidate_root_node;
Raef Colese9479a02022-09-01 16:06:35 +0100339 right_node = sig + MBEDTLS_LMS_SIG_PATH_OFFSET(ctx->params.otstype) +
340 height * MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type);
Raef Coles8ff6df52021-07-21 12:42:15 +0100341 }
342
Raef Colese9479a02022-09-01 16:06:35 +0100343 create_merkle_internal_value( &ctx->params, left_node, right_node,
344 parent_node_id, Tc_candidate_root_node);
Raef Coles8ff6df52021-07-21 12:42:15 +0100345
346 curr_node_id /= 2;
347 }
348
Raef Colesf5632d32022-09-01 09:56:52 +0100349 if( memcmp( Tc_candidate_root_node, ctx->T_1_pub_key,
Raef Colese9479a02022-09-01 16:06:35 +0100350 MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type)) )
Raef Coles8ff6df52021-07-21 12:42:15 +0100351 {
352 return( MBEDTLS_ERR_LMS_VERIFY_FAILED );
353 }
354
355 return( 0 );
356}
357
Raef Colesab4f8742022-09-01 12:24:31 +0100358#ifdef MBEDTLS_LMS_PRIVATE
359
360static int calculate_merkle_tree( mbedtls_lms_private_t *ctx,
Raef Colese9479a02022-09-01 16:06:35 +0100361 unsigned char *tree )
Raef Colesab4f8742022-09-01 12:24:31 +0100362{
363 unsigned int priv_key_idx;
364 unsigned int r_node_idx;
365 int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
366
367 /* First create the leaf nodes, in ascending order */
Raef Colese9479a02022-09-01 16:06:35 +0100368 for( priv_key_idx = 0;
369 priv_key_idx < MERKLE_TREE_INTERNAL_NODE_AM(ctx->params.type);
Raef Colesab4f8742022-09-01 12:24:31 +0100370 priv_key_idx++ )
371 {
Raef Colese9479a02022-09-01 16:06:35 +0100372 r_node_idx = MERKLE_TREE_INTERNAL_NODE_AM(ctx->params.type) + priv_key_idx;
Raef Colesab4f8742022-09-01 12:24:31 +0100373
Raef Colese9479a02022-09-01 16:06:35 +0100374 ret = create_merkle_leaf_value( &ctx->params,
375 ctx->ots_public_keys[priv_key_idx].public_key, r_node_idx,
376 &tree[r_node_idx * MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type)] );
Raef Colesab4f8742022-09-01 12:24:31 +0100377 if( ret )
378 {
379 return( ret );
380 }
381 }
382
383 /* Then the internal nodes, in reverse order so that we can guarantee the
384 * parent has been created */
Raef Colese9479a02022-09-01 16:06:35 +0100385 for( r_node_idx = MERKLE_TREE_INTERNAL_NODE_AM(ctx->params.type) - 1;
386 r_node_idx > 0;
Raef Colesab4f8742022-09-01 12:24:31 +0100387 r_node_idx-- )
388 {
Raef Colese9479a02022-09-01 16:06:35 +0100389 ret = create_merkle_internal_value( &ctx->params,
390 &tree[(r_node_idx * 2) * MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type)],
391 &tree[(r_node_idx * 2 + 1) * MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type)],
392 r_node_idx, &tree[r_node_idx * MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type)] );
Raef Colesab4f8742022-09-01 12:24:31 +0100393 if( ret )
394 {
395 return( ret );
396 }
397 }
398
399 return( 0 );
400}
401
402static int get_merkle_path( mbedtls_lms_private_t *ctx,
403 unsigned int leaf_node_id,
Raef Colese9479a02022-09-01 16:06:35 +0100404 unsigned char *path )
Raef Colesab4f8742022-09-01 12:24:31 +0100405{
Raef Colese9479a02022-09-01 16:06:35 +0100406 unsigned char tree[MERKLE_TREE_NODE_AM_MAX][MBEDTLS_LMS_M_NODE_BYTES_MAX];
Raef Colesab4f8742022-09-01 12:24:31 +0100407 unsigned int curr_node_id = leaf_node_id;
408 unsigned int adjacent_node_id;
409 unsigned int height;
410 int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
411
Raef Colese9479a02022-09-01 16:06:35 +0100412 ret = calculate_merkle_tree( ctx, (unsigned char *)tree);
Raef Colesab4f8742022-09-01 12:24:31 +0100413 if( ret )
414 {
415 return( ret );
416 }
417
Raef Colese9479a02022-09-01 16:06:35 +0100418 for( height = 0; height < MBEDTLS_LMS_H_TREE_HEIGHT(ctx->params.type);
419 height++ )
Raef Colesab4f8742022-09-01 12:24:31 +0100420 {
421 adjacent_node_id = curr_node_id ^ 1;
422
Raef Colese9479a02022-09-01 16:06:35 +0100423 memcpy( &path[height * MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type)],
424 &tree[adjacent_node_id],
425 MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type) );
Raef Colesab4f8742022-09-01 12:24:31 +0100426
427 curr_node_id >>=1;
428 }
429
430 return( 0 );
431}
432
Raef Coles01c71a12022-08-31 15:55:00 +0100433void mbedtls_lms_init_private( mbedtls_lms_private_t *ctx )
Raef Coles8ff6df52021-07-21 12:42:15 +0100434{
Raef Coles01c71a12022-08-31 15:55:00 +0100435 mbedtls_platform_zeroize( ctx, sizeof( mbedtls_lms_public_t ) ) ;
436}
Raef Coles8ff6df52021-07-21 12:42:15 +0100437
Raef Coles01c71a12022-08-31 15:55:00 +0100438void mbedtls_lms_free_private( mbedtls_lms_private_t *ctx )
439{
440 unsigned int idx;
441
Raef Colesf5632d32022-09-01 09:56:52 +0100442 if( ctx->have_private_key )
Raef Coles8ff6df52021-07-21 12:42:15 +0100443 {
Raef Colese9479a02022-09-01 16:06:35 +0100444 for( idx = 0; idx < MERKLE_TREE_LEAF_NODE_AM(ctx->params.type); idx++ )
Raef Coles01c71a12022-08-31 15:55:00 +0100445 {
Raef Colesf5632d32022-09-01 09:56:52 +0100446 mbedtls_lmots_free_private( &ctx->ots_private_keys[idx] );
447 mbedtls_lmots_free_public( &ctx->ots_public_keys[idx] );
Raef Coles01c71a12022-08-31 15:55:00 +0100448 }
449
Raef Colesf5632d32022-09-01 09:56:52 +0100450 mbedtls_free( ctx->ots_private_keys );
451 mbedtls_free( ctx->ots_public_keys );
Raef Coles8ff6df52021-07-21 12:42:15 +0100452 }
453
Raef Coles01c71a12022-08-31 15:55:00 +0100454 mbedtls_platform_zeroize( ctx, sizeof( mbedtls_lms_public_t ) );
455}
Raef Coles8ff6df52021-07-21 12:42:15 +0100456
Raef Coles01c71a12022-08-31 15:55:00 +0100457
458int mbedtls_lms_generate_private_key( mbedtls_lms_private_t *ctx,
459 mbedtls_lms_algorithm_type_t type,
460 mbedtls_lmots_algorithm_type_t otstype,
461 int (*f_rng)(void *, unsigned char *, size_t),
462 void* p_rng, unsigned char *seed,
463 size_t seed_size )
464{
465 unsigned int idx = 0;
466 unsigned int free_idx = 0;
467 int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
468
Raef Coles8ff6df52021-07-21 12:42:15 +0100469 if( type != MBEDTLS_LMS_SHA256_M32_H10 )
470 {
471 return( MBEDTLS_ERR_LMS_BAD_INPUT_DATA );
472 }
Raef Coles8ff6df52021-07-21 12:42:15 +0100473
Raef Coles8ff6df52021-07-21 12:42:15 +0100474 if( otstype != MBEDTLS_LMOTS_SHA256_N32_W8 )
475 {
476 return( MBEDTLS_ERR_LMS_BAD_INPUT_DATA );
477 }
Raef Coles8ff6df52021-07-21 12:42:15 +0100478
Raef Colesf5632d32022-09-01 09:56:52 +0100479 if( ctx->have_private_key )
Raef Coles01c71a12022-08-31 15:55:00 +0100480 {
481 return( MBEDTLS_ERR_LMS_BAD_INPUT_DATA );
482 }
Raef Coles8ff6df52021-07-21 12:42:15 +0100483
Raef Colesf5632d32022-09-01 09:56:52 +0100484 ctx->params.type = type;
485 ctx->params.otstype = otstype;
Raef Coles01c71a12022-08-31 15:55:00 +0100486
487 f_rng( p_rng,
Raef Colesf5632d32022-09-01 09:56:52 +0100488 ctx->params.I_key_identifier,
Raef Coles01c71a12022-08-31 15:55:00 +0100489 MBEDTLS_LMOTS_I_KEY_ID_LEN );
490
Raef Colese9479a02022-09-01 16:06:35 +0100491 ctx->ots_private_keys = mbedtls_calloc( MERKLE_TREE_LEAF_NODE_AM(ctx->params.type),
492 sizeof( mbedtls_lmots_private_t));
Raef Colesf5632d32022-09-01 09:56:52 +0100493 if( ctx->ots_private_keys == NULL )
Raef Coles01c71a12022-08-31 15:55:00 +0100494 {
495 ret = MBEDTLS_ERR_LMS_ALLOC_FAILED;
496 goto exit;
497 }
498
Raef Colese9479a02022-09-01 16:06:35 +0100499 ctx->ots_public_keys = mbedtls_calloc( MERKLE_TREE_LEAF_NODE_AM(ctx->params.type),
500 sizeof( mbedtls_lmots_public_t));
Raef Colesf5632d32022-09-01 09:56:52 +0100501 if( ctx->ots_public_keys == NULL )
Raef Coles01c71a12022-08-31 15:55:00 +0100502 {
503 ret = MBEDTLS_ERR_LMS_ALLOC_FAILED;
504 goto exit;
505 }
506
Raef Colese9479a02022-09-01 16:06:35 +0100507 for( idx = 0; idx < MERKLE_TREE_LEAF_NODE_AM(ctx->params.type); idx++ )
Raef Coles01c71a12022-08-31 15:55:00 +0100508 {
Raef Colesf5632d32022-09-01 09:56:52 +0100509 mbedtls_lmots_init_private( &ctx->ots_private_keys[idx] );
510 mbedtls_lmots_init_public( &ctx->ots_public_keys[idx] );
Raef Coles01c71a12022-08-31 15:55:00 +0100511 }
512
513
Raef Colese9479a02022-09-01 16:06:35 +0100514 for( idx = 0; idx < MERKLE_TREE_LEAF_NODE_AM(ctx->params.type); idx++ )
Raef Coles01c71a12022-08-31 15:55:00 +0100515 {
Raef Colesf5632d32022-09-01 09:56:52 +0100516 ret = mbedtls_lmots_generate_private_key( &ctx->ots_private_keys[idx],
Raef Coles01c71a12022-08-31 15:55:00 +0100517 otstype,
Raef Colesf5632d32022-09-01 09:56:52 +0100518 ctx->params.I_key_identifier,
Raef Coles01c71a12022-08-31 15:55:00 +0100519 idx, seed, seed_size );
520 if( ret)
521 goto exit;
522
Raef Colesf5632d32022-09-01 09:56:52 +0100523 ret = mbedtls_lmots_calculate_public_key( &ctx->ots_public_keys[idx],
524 &ctx->ots_private_keys[idx] );
Raef Coles01c71a12022-08-31 15:55:00 +0100525 if( ret)
526 goto exit;
527 }
528
Raef Colesf5632d32022-09-01 09:56:52 +0100529 ctx->q_next_usable_key = 0;
530 ctx->have_private_key = 1;
Raef Coles01c71a12022-08-31 15:55:00 +0100531
532exit:
533 if( ret )
534 {
535 for ( free_idx = 0; free_idx < idx; free_idx++ ) {
Raef Colesf5632d32022-09-01 09:56:52 +0100536 mbedtls_lmots_free_private( &ctx->ots_private_keys[free_idx] );
537 mbedtls_lmots_free_public( &ctx->ots_public_keys[free_idx] );
Raef Coles01c71a12022-08-31 15:55:00 +0100538 }
539
Raef Colesf5632d32022-09-01 09:56:52 +0100540 mbedtls_free( ctx->ots_private_keys );
541 mbedtls_free( ctx->ots_public_keys );
Raef Coles01c71a12022-08-31 15:55:00 +0100542 return( ret );
543 }
Raef Coles8ff6df52021-07-21 12:42:15 +0100544
545 return( 0 );
546}
547
Raef Coles01c71a12022-08-31 15:55:00 +0100548int mbedtls_lms_calculate_public_key( mbedtls_lms_public_t *ctx,
549 mbedtls_lms_private_t *priv_ctx )
Raef Coles8ff6df52021-07-21 12:42:15 +0100550{
Raef Colese9479a02022-09-01 16:06:35 +0100551 unsigned char tree[MERKLE_TREE_NODE_AM_MAX][MBEDTLS_LMS_M_NODE_BYTES_MAX];
Raef Coles8ff6df52021-07-21 12:42:15 +0100552 int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
553
Raef Coles01c71a12022-08-31 15:55:00 +0100554 if( ! priv_ctx->MBEDTLS_PRIVATE( have_private_key ) )
Raef Coles8ff6df52021-07-21 12:42:15 +0100555 {
556 return( MBEDTLS_ERR_LMS_BAD_INPUT_DATA );
557 }
558
Raef Colesf5632d32022-09-01 09:56:52 +0100559 if( priv_ctx->params.type
Raef Coles01c71a12022-08-31 15:55:00 +0100560 != MBEDTLS_LMS_SHA256_M32_H10 )
Raef Coles8ff6df52021-07-21 12:42:15 +0100561 {
562 return( MBEDTLS_ERR_LMS_BAD_INPUT_DATA );
563 }
564
Raef Colesf5632d32022-09-01 09:56:52 +0100565 if( priv_ctx->params.otstype
Raef Coles01c71a12022-08-31 15:55:00 +0100566 != MBEDTLS_LMOTS_SHA256_N32_W8 )
Raef Coles8ff6df52021-07-21 12:42:15 +0100567 {
568 return( MBEDTLS_ERR_LMS_BAD_INPUT_DATA );
569 }
570
Raef Colesf5632d32022-09-01 09:56:52 +0100571 memcpy( &ctx->params, &priv_ctx->params,
Raef Coles01c71a12022-08-31 15:55:00 +0100572 sizeof(mbedtls_lmots_parameters_t) );
Raef Coles8ff6df52021-07-21 12:42:15 +0100573
Raef Colese9479a02022-09-01 16:06:35 +0100574 ret = calculate_merkle_tree( priv_ctx, (unsigned char *)tree);
Raef Coles8ff6df52021-07-21 12:42:15 +0100575 if( ret )
576 {
577 return( ret );
578 }
579
580 /* Root node is always at position 1, due to 1-based indexing */
Raef Colese9479a02022-09-01 16:06:35 +0100581 memcpy( ctx->T_1_pub_key, &tree[1],
582 MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type));
Raef Coles8ff6df52021-07-21 12:42:15 +0100583
Raef Colesf5632d32022-09-01 09:56:52 +0100584 ctx->have_public_key = 1;
Raef Coles8ff6df52021-07-21 12:42:15 +0100585
586 return( 0 );
587}
588
Raef Coles01c71a12022-08-31 15:55:00 +0100589
590int mbedtls_lms_export_public_key( mbedtls_lms_public_t *ctx, unsigned char *key,
591 size_t key_size, size_t *key_len )
Raef Coles8ff6df52021-07-21 12:42:15 +0100592{
Raef Colese9479a02022-09-01 16:06:35 +0100593 if( key_size < MBEDTLS_LMS_PUBLIC_KEY_LEN(ctx->params.type) ) {
Raef Coles01c71a12022-08-31 15:55:00 +0100594 return( MBEDTLS_ERR_LMS_BUFFER_TOO_SMALL );
595 }
596
Raef Colesf5632d32022-09-01 09:56:52 +0100597 if( ! ctx->have_public_key )
Raef Coles01c71a12022-08-31 15:55:00 +0100598 {
599 return( MBEDTLS_ERR_LMS_BAD_INPUT_DATA );
600 }
601
602 unsigned_int_to_network_bytes(
Raef Colesf5632d32022-09-01 09:56:52 +0100603 ctx->params.type,
Raef Coles01c71a12022-08-31 15:55:00 +0100604 MBEDTLS_LMS_TYPE_LEN, key + MBEDTLS_LMS_PUBLIC_KEY_TYPE_OFFSET );
605 unsigned_int_to_network_bytes(
Raef Colesf5632d32022-09-01 09:56:52 +0100606 ctx->params.otstype,
Raef Coles01c71a12022-08-31 15:55:00 +0100607 MBEDTLS_LMOTS_TYPE_LEN, key + MBEDTLS_LMS_PUBLIC_KEY_OTSTYPE_OFFSET );
608 memcpy( key + MBEDTLS_LMS_PUBLIC_KEY_I_KEY_ID_OFFSET,
Raef Colesf5632d32022-09-01 09:56:52 +0100609 ctx->params.I_key_identifier,
Raef Coles01c71a12022-08-31 15:55:00 +0100610 MBEDTLS_LMOTS_I_KEY_ID_LEN );
611 memcpy( key + MBEDTLS_LMS_PUBLIC_KEY_ROOT_NODE_OFFSET,
Raef Colesf5632d32022-09-01 09:56:52 +0100612 ctx->T_1_pub_key,
Raef Colese9479a02022-09-01 16:06:35 +0100613 MBEDTLS_LMS_M_NODE_BYTES(ctx->params.type) );
Raef Coles01c71a12022-08-31 15:55:00 +0100614
615 if( key_len != NULL ) {
Raef Colese9479a02022-09-01 16:06:35 +0100616 *key_len = MBEDTLS_LMS_PUBLIC_KEY_LEN(ctx->params.type);
Raef Coles01c71a12022-08-31 15:55:00 +0100617 }
618
619 return( 0 );
620}
621
622
623int mbedtls_lms_sign( mbedtls_lms_private_t *ctx,
624 int (*f_rng)(void *, unsigned char *, size_t),
625 void* p_rng, unsigned char *msg, unsigned int msg_size,
626 unsigned char *sig, size_t sig_size, size_t *sig_len)
627{
628 uint32_t q_leaf_identifier;
Raef Coles8ff6df52021-07-21 12:42:15 +0100629 int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
630
Raef Colesf5632d32022-09-01 09:56:52 +0100631 if( ! ctx->have_private_key )
Raef Coles8ff6df52021-07-21 12:42:15 +0100632 {
633 return( MBEDTLS_ERR_LMS_BAD_INPUT_DATA );
634 }
635
Raef Colese9479a02022-09-01 16:06:35 +0100636 if( sig_size < MBEDTLS_LMS_SIG_LEN(ctx->params.type, ctx->params.otstype) )
Raef Coles01c71a12022-08-31 15:55:00 +0100637 {
638 return( MBEDTLS_ERR_LMS_BUFFER_TOO_SMALL );
639 }
640
Raef Colesf5632d32022-09-01 09:56:52 +0100641 if( ctx->params.type != MBEDTLS_LMS_SHA256_M32_H10 )
Raef Coles8ff6df52021-07-21 12:42:15 +0100642 {
643 return( MBEDTLS_ERR_LMS_BAD_INPUT_DATA );
644 }
645
Raef Colesf5632d32022-09-01 09:56:52 +0100646 if( ctx->params.otstype
Raef Coles01c71a12022-08-31 15:55:00 +0100647 != MBEDTLS_LMOTS_SHA256_N32_W8 )
Raef Coles8ff6df52021-07-21 12:42:15 +0100648 {
649 return( MBEDTLS_ERR_LMS_BAD_INPUT_DATA );
650 }
651
Raef Colese9479a02022-09-01 16:06:35 +0100652 if( ctx->q_next_usable_key >= MERKLE_TREE_LEAF_NODE_AM(ctx->params.type) )
Raef Coles8ff6df52021-07-21 12:42:15 +0100653 {
Raef Coles01c71a12022-08-31 15:55:00 +0100654 return( MBEDTLS_ERR_LMS_OUT_OF_PRIVATE_KEYS );
Raef Coles8ff6df52021-07-21 12:42:15 +0100655 }
656
657
Raef Colesf5632d32022-09-01 09:56:52 +0100658 q_leaf_identifier = ctx->q_next_usable_key;
Raef Coles01c71a12022-08-31 15:55:00 +0100659 /* This new value must _always_ be written back to the disk before the
660 * signature is returned.
661 */
Raef Colesf5632d32022-09-01 09:56:52 +0100662 ctx->q_next_usable_key += 1;
Raef Coles8ff6df52021-07-21 12:42:15 +0100663
Raef Colesf5632d32022-09-01 09:56:52 +0100664 ret = mbedtls_lmots_sign( &ctx->ots_private_keys[q_leaf_identifier],
Raef Coles01c71a12022-08-31 15:55:00 +0100665 f_rng, p_rng, msg, msg_size,
666 sig + MBEDTLS_LMS_SIG_OTS_SIG_OFFSET,
Raef Colese9479a02022-09-01 16:06:35 +0100667 MBEDTLS_LMS_SIG_LEN(ctx->params.type, ctx->params.otstype),
668 NULL );
Raef Coles8ff6df52021-07-21 12:42:15 +0100669 if( ret )
670 {
Raef Coles8ff6df52021-07-21 12:42:15 +0100671 return( ret );
672 }
673
Raef Colesf5632d32022-09-01 09:56:52 +0100674 unsigned_int_to_network_bytes( ctx->params.type,
Raef Colese9479a02022-09-01 16:06:35 +0100675 MBEDTLS_LMS_TYPE_LEN,
676 sig + MBEDTLS_LMS_SIG_TYPE_OFFSET(ctx->params.otstype) );
Raef Coles01c71a12022-08-31 15:55:00 +0100677 unsigned_int_to_network_bytes( q_leaf_identifier, MBEDTLS_LMOTS_Q_LEAF_ID_LEN,
678 sig + MBEDTLS_LMS_SIG_Q_LEAF_ID_OFFSET);
679
Raef Colese9479a02022-09-01 16:06:35 +0100680 ret = get_merkle_path( ctx,
681 MERKLE_TREE_INTERNAL_NODE_AM(ctx->params.type) + q_leaf_identifier,
682 sig + MBEDTLS_LMS_SIG_PATH_OFFSET(ctx->params.otstype) );
Raef Coles01c71a12022-08-31 15:55:00 +0100683 if( ret )
684 {
685 return( ret );
686 }
687
688 if( sig_len != NULL ) {
Raef Colese9479a02022-09-01 16:06:35 +0100689 *sig_len = MBEDTLS_LMS_SIG_LEN(ctx->params.type, ctx->params.otstype);
Raef Coles01c71a12022-08-31 15:55:00 +0100690 }
691
692
Raef Coles8ff6df52021-07-21 12:42:15 +0100693 return( 0 );
694}
695
Raef Colesab4f8742022-09-01 12:24:31 +0100696#endif /* MBEDTLS_LMS_PRIVATE */
Raef Coles8ff6df52021-07-21 12:42:15 +0100697#endif /* MBEDTLS_LMS_C */