pk.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. /*
  2. * Public Key abstraction layer
  3. *
  4. * Copyright The Mbed TLS Contributors
  5. * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
  6. *
  7. * This file is provided under the Apache License 2.0, or the
  8. * GNU General Public License v2.0 or later.
  9. *
  10. * **********
  11. * Apache License 2.0:
  12. *
  13. * Licensed under the Apache License, Version 2.0 (the "License"); you may
  14. * not use this file except in compliance with the License.
  15. * You may obtain a copy of the License at
  16. *
  17. * http://www.apache.org/licenses/LICENSE-2.0
  18. *
  19. * Unless required by applicable law or agreed to in writing, software
  20. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  21. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  22. * See the License for the specific language governing permissions and
  23. * limitations under the License.
  24. *
  25. * **********
  26. *
  27. * **********
  28. * GNU General Public License v2.0 or later:
  29. *
  30. * This program is free software; you can redistribute it and/or modify
  31. * it under the terms of the GNU General Public License as published by
  32. * the Free Software Foundation; either version 2 of the License, or
  33. * (at your option) any later version.
  34. *
  35. * This program is distributed in the hope that it will be useful,
  36. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  37. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  38. * GNU General Public License for more details.
  39. *
  40. * You should have received a copy of the GNU General Public License along
  41. * with this program; if not, write to the Free Software Foundation, Inc.,
  42. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  43. *
  44. * **********
  45. */
  46. #if !defined(MBEDTLS_CONFIG_FILE)
  47. #include "mbedtls/config.h"
  48. #else
  49. #include MBEDTLS_CONFIG_FILE
  50. #endif
  51. #if defined(MBEDTLS_PK_C)
  52. #include "mbedtls/pk.h"
  53. #include "mbedtls/pk_internal.h"
  54. #include "mbedtls/platform_util.h"
  55. #if defined(MBEDTLS_RSA_C)
  56. #include "mbedtls/rsa.h"
  57. #endif
  58. #if defined(MBEDTLS_ECP_C)
  59. #include "mbedtls/ecp.h"
  60. #endif
  61. #if defined(MBEDTLS_ECDSA_C)
  62. #include "mbedtls/ecdsa.h"
  63. #endif
  64. #include <limits.h>
  65. #include <stdint.h>
  66. /* Parameter validation macros based on platform_util.h */
  67. #define PK_VALIDATE_RET( cond ) \
  68. MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_PK_BAD_INPUT_DATA )
  69. #define PK_VALIDATE( cond ) \
  70. MBEDTLS_INTERNAL_VALIDATE( cond )
  71. /*
  72. * Initialise a mbedtls_pk_context
  73. */
  74. void mbedtls_pk_init( mbedtls_pk_context *ctx )
  75. {
  76. PK_VALIDATE( ctx != NULL );
  77. ctx->pk_info = NULL;
  78. ctx->pk_ctx = NULL;
  79. }
  80. /*
  81. * Free (the components of) a mbedtls_pk_context
  82. */
  83. void mbedtls_pk_free( mbedtls_pk_context *ctx )
  84. {
  85. if( ctx == NULL )
  86. return;
  87. if ( ctx->pk_info != NULL )
  88. ctx->pk_info->ctx_free_func( ctx->pk_ctx );
  89. mbedtls_platform_zeroize( ctx, sizeof( mbedtls_pk_context ) );
  90. }
  91. #if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE)
  92. /*
  93. * Initialize a restart context
  94. */
  95. void mbedtls_pk_restart_init( mbedtls_pk_restart_ctx *ctx )
  96. {
  97. PK_VALIDATE( ctx != NULL );
  98. ctx->pk_info = NULL;
  99. ctx->rs_ctx = NULL;
  100. }
  101. /*
  102. * Free the components of a restart context
  103. */
  104. void mbedtls_pk_restart_free( mbedtls_pk_restart_ctx *ctx )
  105. {
  106. if( ctx == NULL || ctx->pk_info == NULL ||
  107. ctx->pk_info->rs_free_func == NULL )
  108. {
  109. return;
  110. }
  111. ctx->pk_info->rs_free_func( ctx->rs_ctx );
  112. ctx->pk_info = NULL;
  113. ctx->rs_ctx = NULL;
  114. }
  115. #endif /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */
  116. /*
  117. * Get pk_info structure from type
  118. */
  119. const mbedtls_pk_info_t * mbedtls_pk_info_from_type( mbedtls_pk_type_t pk_type )
  120. {
  121. switch( pk_type ) {
  122. #if defined(MBEDTLS_RSA_C)
  123. case MBEDTLS_PK_RSA:
  124. return( &mbedtls_rsa_info );
  125. #endif
  126. #if defined(MBEDTLS_ECP_C)
  127. case MBEDTLS_PK_ECKEY:
  128. return( &mbedtls_eckey_info );
  129. case MBEDTLS_PK_ECKEY_DH:
  130. return( &mbedtls_eckeydh_info );
  131. #endif
  132. #if defined(MBEDTLS_ECDSA_C)
  133. case MBEDTLS_PK_ECDSA:
  134. return( &mbedtls_ecdsa_info );
  135. #endif
  136. /* MBEDTLS_PK_RSA_ALT omitted on purpose */
  137. default:
  138. return( NULL );
  139. }
  140. }
  141. /*
  142. * Initialise context
  143. */
  144. int mbedtls_pk_setup( mbedtls_pk_context *ctx, const mbedtls_pk_info_t *info )
  145. {
  146. PK_VALIDATE_RET( ctx != NULL );
  147. if( info == NULL || ctx->pk_info != NULL )
  148. return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
  149. if( ( ctx->pk_ctx = info->ctx_alloc_func() ) == NULL )
  150. return( MBEDTLS_ERR_PK_ALLOC_FAILED );
  151. ctx->pk_info = info;
  152. return( 0 );
  153. }
  154. #if defined(MBEDTLS_PK_RSA_ALT_SUPPORT)
  155. /*
  156. * Initialize an RSA-alt context
  157. */
  158. int mbedtls_pk_setup_rsa_alt( mbedtls_pk_context *ctx, void * key,
  159. mbedtls_pk_rsa_alt_decrypt_func decrypt_func,
  160. mbedtls_pk_rsa_alt_sign_func sign_func,
  161. mbedtls_pk_rsa_alt_key_len_func key_len_func )
  162. {
  163. mbedtls_rsa_alt_context *rsa_alt;
  164. const mbedtls_pk_info_t *info = &mbedtls_rsa_alt_info;
  165. PK_VALIDATE_RET( ctx != NULL );
  166. if( ctx->pk_info != NULL )
  167. return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
  168. if( ( ctx->pk_ctx = info->ctx_alloc_func() ) == NULL )
  169. return( MBEDTLS_ERR_PK_ALLOC_FAILED );
  170. ctx->pk_info = info;
  171. rsa_alt = (mbedtls_rsa_alt_context *) ctx->pk_ctx;
  172. rsa_alt->key = key;
  173. rsa_alt->decrypt_func = decrypt_func;
  174. rsa_alt->sign_func = sign_func;
  175. rsa_alt->key_len_func = key_len_func;
  176. return( 0 );
  177. }
  178. #endif /* MBEDTLS_PK_RSA_ALT_SUPPORT */
  179. /*
  180. * Tell if a PK can do the operations of the given type
  181. */
  182. int mbedtls_pk_can_do( const mbedtls_pk_context *ctx, mbedtls_pk_type_t type )
  183. {
  184. /* A context with null pk_info is not set up yet and can't do anything.
  185. * For backward compatibility, also accept NULL instead of a context
  186. * pointer. */
  187. if( ctx == NULL || ctx->pk_info == NULL )
  188. return( 0 );
  189. return( ctx->pk_info->can_do( type ) );
  190. }
  191. /*
  192. * Helper for mbedtls_pk_sign and mbedtls_pk_verify
  193. */
  194. static inline int pk_hashlen_helper( mbedtls_md_type_t md_alg, size_t *hash_len )
  195. {
  196. const mbedtls_md_info_t *md_info;
  197. if( *hash_len != 0 )
  198. return( 0 );
  199. if( ( md_info = mbedtls_md_info_from_type( md_alg ) ) == NULL )
  200. return( -1 );
  201. *hash_len = mbedtls_md_get_size( md_info );
  202. return( 0 );
  203. }
  204. #if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE)
  205. /*
  206. * Helper to set up a restart context if needed
  207. */
  208. static int pk_restart_setup( mbedtls_pk_restart_ctx *ctx,
  209. const mbedtls_pk_info_t *info )
  210. {
  211. /* Don't do anything if already set up or invalid */
  212. if( ctx == NULL || ctx->pk_info != NULL )
  213. return( 0 );
  214. /* Should never happen when we're called */
  215. if( info->rs_alloc_func == NULL || info->rs_free_func == NULL )
  216. return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
  217. if( ( ctx->rs_ctx = info->rs_alloc_func() ) == NULL )
  218. return( MBEDTLS_ERR_PK_ALLOC_FAILED );
  219. ctx->pk_info = info;
  220. return( 0 );
  221. }
  222. #endif /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */
  223. /*
  224. * Verify a signature (restartable)
  225. */
  226. int mbedtls_pk_verify_restartable( mbedtls_pk_context *ctx,
  227. mbedtls_md_type_t md_alg,
  228. const unsigned char *hash, size_t hash_len,
  229. const unsigned char *sig, size_t sig_len,
  230. mbedtls_pk_restart_ctx *rs_ctx )
  231. {
  232. PK_VALIDATE_RET( ctx != NULL );
  233. PK_VALIDATE_RET( ( md_alg == MBEDTLS_MD_NONE && hash_len == 0 ) ||
  234. hash != NULL );
  235. PK_VALIDATE_RET( sig != NULL );
  236. if( ctx->pk_info == NULL ||
  237. pk_hashlen_helper( md_alg, &hash_len ) != 0 )
  238. return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
  239. #if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE)
  240. /* optimization: use non-restartable version if restart disabled */
  241. if( rs_ctx != NULL &&
  242. mbedtls_ecp_restart_is_enabled() &&
  243. ctx->pk_info->verify_rs_func != NULL )
  244. {
  245. int ret;
  246. if( ( ret = pk_restart_setup( rs_ctx, ctx->pk_info ) ) != 0 )
  247. return( ret );
  248. ret = ctx->pk_info->verify_rs_func( ctx->pk_ctx,
  249. md_alg, hash, hash_len, sig, sig_len, rs_ctx->rs_ctx );
  250. if( ret != MBEDTLS_ERR_ECP_IN_PROGRESS )
  251. mbedtls_pk_restart_free( rs_ctx );
  252. return( ret );
  253. }
  254. #else /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */
  255. (void) rs_ctx;
  256. #endif /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */
  257. if( ctx->pk_info->verify_func == NULL )
  258. return( MBEDTLS_ERR_PK_TYPE_MISMATCH );
  259. return( ctx->pk_info->verify_func( ctx->pk_ctx, md_alg, hash, hash_len,
  260. sig, sig_len ) );
  261. }
  262. /*
  263. * Verify a signature
  264. */
  265. int mbedtls_pk_verify( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg,
  266. const unsigned char *hash, size_t hash_len,
  267. const unsigned char *sig, size_t sig_len )
  268. {
  269. return( mbedtls_pk_verify_restartable( ctx, md_alg, hash, hash_len,
  270. sig, sig_len, NULL ) );
  271. }
  272. /*
  273. * Verify a signature with options
  274. */
  275. int mbedtls_pk_verify_ext( mbedtls_pk_type_t type, const void *options,
  276. mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg,
  277. const unsigned char *hash, size_t hash_len,
  278. const unsigned char *sig, size_t sig_len )
  279. {
  280. PK_VALIDATE_RET( ctx != NULL );
  281. PK_VALIDATE_RET( ( md_alg == MBEDTLS_MD_NONE && hash_len == 0 ) ||
  282. hash != NULL );
  283. PK_VALIDATE_RET( sig != NULL );
  284. if( ctx->pk_info == NULL )
  285. return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
  286. if( ! mbedtls_pk_can_do( ctx, type ) )
  287. return( MBEDTLS_ERR_PK_TYPE_MISMATCH );
  288. if( type == MBEDTLS_PK_RSASSA_PSS )
  289. {
  290. #if defined(MBEDTLS_RSA_C) && defined(MBEDTLS_PKCS1_V21)
  291. int ret;
  292. const mbedtls_pk_rsassa_pss_options *pss_opts;
  293. #if SIZE_MAX > UINT_MAX
  294. if( md_alg == MBEDTLS_MD_NONE && UINT_MAX < hash_len )
  295. return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
  296. #endif /* SIZE_MAX > UINT_MAX */
  297. if( options == NULL )
  298. return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
  299. pss_opts = (const mbedtls_pk_rsassa_pss_options *) options;
  300. if( sig_len < mbedtls_pk_get_len( ctx ) )
  301. return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
  302. ret = mbedtls_rsa_rsassa_pss_verify_ext( mbedtls_pk_rsa( *ctx ),
  303. NULL, NULL, MBEDTLS_RSA_PUBLIC,
  304. md_alg, (unsigned int) hash_len, hash,
  305. pss_opts->mgf1_hash_id,
  306. pss_opts->expected_salt_len,
  307. sig );
  308. if( ret != 0 )
  309. return( ret );
  310. if( sig_len > mbedtls_pk_get_len( ctx ) )
  311. return( MBEDTLS_ERR_PK_SIG_LEN_MISMATCH );
  312. return( 0 );
  313. #else
  314. return( MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE );
  315. #endif /* MBEDTLS_RSA_C && MBEDTLS_PKCS1_V21 */
  316. }
  317. /* General case: no options */
  318. if( options != NULL )
  319. return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
  320. return( mbedtls_pk_verify( ctx, md_alg, hash, hash_len, sig, sig_len ) );
  321. }
  322. /*
  323. * Make a signature (restartable)
  324. */
  325. int mbedtls_pk_sign_restartable( mbedtls_pk_context *ctx,
  326. mbedtls_md_type_t md_alg,
  327. const unsigned char *hash, size_t hash_len,
  328. unsigned char *sig, size_t *sig_len,
  329. int (*f_rng)(void *, unsigned char *, size_t), void *p_rng,
  330. mbedtls_pk_restart_ctx *rs_ctx )
  331. {
  332. PK_VALIDATE_RET( ctx != NULL );
  333. PK_VALIDATE_RET( ( md_alg == MBEDTLS_MD_NONE && hash_len == 0 ) ||
  334. hash != NULL );
  335. PK_VALIDATE_RET( sig != NULL );
  336. if( ctx->pk_info == NULL ||
  337. pk_hashlen_helper( md_alg, &hash_len ) != 0 )
  338. return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
  339. #if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE)
  340. /* optimization: use non-restartable version if restart disabled */
  341. if( rs_ctx != NULL &&
  342. mbedtls_ecp_restart_is_enabled() &&
  343. ctx->pk_info->sign_rs_func != NULL )
  344. {
  345. int ret;
  346. if( ( ret = pk_restart_setup( rs_ctx, ctx->pk_info ) ) != 0 )
  347. return( ret );
  348. ret = ctx->pk_info->sign_rs_func( ctx->pk_ctx, md_alg,
  349. hash, hash_len, sig, sig_len, f_rng, p_rng, rs_ctx->rs_ctx );
  350. if( ret != MBEDTLS_ERR_ECP_IN_PROGRESS )
  351. mbedtls_pk_restart_free( rs_ctx );
  352. return( ret );
  353. }
  354. #else /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */
  355. (void) rs_ctx;
  356. #endif /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */
  357. if( ctx->pk_info->sign_func == NULL )
  358. return( MBEDTLS_ERR_PK_TYPE_MISMATCH );
  359. return( ctx->pk_info->sign_func( ctx->pk_ctx, md_alg, hash, hash_len,
  360. sig, sig_len, f_rng, p_rng ) );
  361. }
  362. /*
  363. * Make a signature
  364. */
  365. int mbedtls_pk_sign( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg,
  366. const unsigned char *hash, size_t hash_len,
  367. unsigned char *sig, size_t *sig_len,
  368. int (*f_rng)(void *, unsigned char *, size_t), void *p_rng )
  369. {
  370. return( mbedtls_pk_sign_restartable( ctx, md_alg, hash, hash_len,
  371. sig, sig_len, f_rng, p_rng, NULL ) );
  372. }
  373. /*
  374. * Decrypt message
  375. */
  376. int mbedtls_pk_decrypt( mbedtls_pk_context *ctx,
  377. const unsigned char *input, size_t ilen,
  378. unsigned char *output, size_t *olen, size_t osize,
  379. int (*f_rng)(void *, unsigned char *, size_t), void *p_rng )
  380. {
  381. PK_VALIDATE_RET( ctx != NULL );
  382. PK_VALIDATE_RET( input != NULL || ilen == 0 );
  383. PK_VALIDATE_RET( output != NULL || osize == 0 );
  384. PK_VALIDATE_RET( olen != NULL );
  385. if( ctx->pk_info == NULL )
  386. return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
  387. if( ctx->pk_info->decrypt_func == NULL )
  388. return( MBEDTLS_ERR_PK_TYPE_MISMATCH );
  389. return( ctx->pk_info->decrypt_func( ctx->pk_ctx, input, ilen,
  390. output, olen, osize, f_rng, p_rng ) );
  391. }
  392. /*
  393. * Encrypt message
  394. */
  395. int mbedtls_pk_encrypt( mbedtls_pk_context *ctx,
  396. const unsigned char *input, size_t ilen,
  397. unsigned char *output, size_t *olen, size_t osize,
  398. int (*f_rng)(void *, unsigned char *, size_t), void *p_rng )
  399. {
  400. PK_VALIDATE_RET( ctx != NULL );
  401. PK_VALIDATE_RET( input != NULL || ilen == 0 );
  402. PK_VALIDATE_RET( output != NULL || osize == 0 );
  403. PK_VALIDATE_RET( olen != NULL );
  404. if( ctx->pk_info == NULL )
  405. return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
  406. if( ctx->pk_info->encrypt_func == NULL )
  407. return( MBEDTLS_ERR_PK_TYPE_MISMATCH );
  408. return( ctx->pk_info->encrypt_func( ctx->pk_ctx, input, ilen,
  409. output, olen, osize, f_rng, p_rng ) );
  410. }
  411. /*
  412. * Check public-private key pair
  413. */
  414. int mbedtls_pk_check_pair( const mbedtls_pk_context *pub, const mbedtls_pk_context *prv )
  415. {
  416. PK_VALIDATE_RET( pub != NULL );
  417. PK_VALIDATE_RET( prv != NULL );
  418. if( pub->pk_info == NULL ||
  419. prv->pk_info == NULL ||
  420. prv->pk_info->check_pair_func == NULL )
  421. {
  422. return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
  423. }
  424. if( prv->pk_info->type == MBEDTLS_PK_RSA_ALT )
  425. {
  426. if( pub->pk_info->type != MBEDTLS_PK_RSA )
  427. return( MBEDTLS_ERR_PK_TYPE_MISMATCH );
  428. }
  429. else
  430. {
  431. if( pub->pk_info != prv->pk_info )
  432. return( MBEDTLS_ERR_PK_TYPE_MISMATCH );
  433. }
  434. return( prv->pk_info->check_pair_func( pub->pk_ctx, prv->pk_ctx ) );
  435. }
  436. /*
  437. * Get key size in bits
  438. */
  439. size_t mbedtls_pk_get_bitlen( const mbedtls_pk_context *ctx )
  440. {
  441. /* For backward compatibility, accept NULL or a context that
  442. * isn't set up yet, and return a fake value that should be safe. */
  443. if( ctx == NULL || ctx->pk_info == NULL )
  444. return( 0 );
  445. return( ctx->pk_info->get_bitlen( ctx->pk_ctx ) );
  446. }
  447. /*
  448. * Export debug information
  449. */
  450. int mbedtls_pk_debug( const mbedtls_pk_context *ctx, mbedtls_pk_debug_item *items )
  451. {
  452. PK_VALIDATE_RET( ctx != NULL );
  453. if( ctx->pk_info == NULL )
  454. return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
  455. if( ctx->pk_info->debug_func == NULL )
  456. return( MBEDTLS_ERR_PK_TYPE_MISMATCH );
  457. ctx->pk_info->debug_func( ctx->pk_ctx, items );
  458. return( 0 );
  459. }
  460. /*
  461. * Access the PK type name
  462. */
  463. const char *mbedtls_pk_get_name( const mbedtls_pk_context *ctx )
  464. {
  465. if( ctx == NULL || ctx->pk_info == NULL )
  466. return( "invalid PK" );
  467. return( ctx->pk_info->name );
  468. }
  469. /*
  470. * Access the PK type
  471. */
  472. mbedtls_pk_type_t mbedtls_pk_get_type( const mbedtls_pk_context *ctx )
  473. {
  474. if( ctx == NULL || ctx->pk_info == NULL )
  475. return( MBEDTLS_PK_NONE );
  476. return( ctx->pk_info->type );
  477. }
  478. #endif /* MBEDTLS_PK_C */