rsa.c (0ba5bc40) rsa.c (1b00a1f5)
1/*
2 * The RSA public-key cryptosystem
3 *
4 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
5 * SPDX-License-Identifier: GPL-2.0
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by

--- 239 unchanged lines hidden (view full) ---

248 int ret = 0;
249
250 const int have_N = ( mbedtls_mpi_cmp_int( &ctx->N, 0 ) != 0 );
251 const int have_P = ( mbedtls_mpi_cmp_int( &ctx->P, 0 ) != 0 );
252 const int have_Q = ( mbedtls_mpi_cmp_int( &ctx->Q, 0 ) != 0 );
253 const int have_D = ( mbedtls_mpi_cmp_int( &ctx->D, 0 ) != 0 );
254 const int have_E = ( mbedtls_mpi_cmp_int( &ctx->E, 0 ) != 0 );
255
1/*
2 * The RSA public-key cryptosystem
3 *
4 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
5 * SPDX-License-Identifier: GPL-2.0
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by

--- 239 unchanged lines hidden (view full) ---

248 int ret = 0;
249
250 const int have_N = ( mbedtls_mpi_cmp_int( &ctx->N, 0 ) != 0 );
251 const int have_P = ( mbedtls_mpi_cmp_int( &ctx->P, 0 ) != 0 );
252 const int have_Q = ( mbedtls_mpi_cmp_int( &ctx->Q, 0 ) != 0 );
253 const int have_D = ( mbedtls_mpi_cmp_int( &ctx->D, 0 ) != 0 );
254 const int have_E = ( mbedtls_mpi_cmp_int( &ctx->E, 0 ) != 0 );
255
256#if !defined(MBEDTLS_RSA_NO_CRT)
257 const int have_DP = ( mbedtls_mpi_cmp_int( &ctx->DP, 0 ) != 0 );
258 const int have_DQ = ( mbedtls_mpi_cmp_int( &ctx->DQ, 0 ) != 0 );
259 const int have_QP = ( mbedtls_mpi_cmp_int( &ctx->QP, 0 ) != 0 );
260#endif
261
256 /*
257 * Check whether provided parameters are enough
258 * to deduce all others. The following incomplete
259 * parameter sets for private keys are supported:
260 *
261 * (1) P, Q missing.
262 * (2) D and potentially N missing.
263 *

--- 49 unchanged lines hidden (view full) ---

313 }
314
315 /*
316 * Step 3: Deduce all additional parameters specific
317 * to our current RSA implementation.
318 */
319
320#if !defined(MBEDTLS_RSA_NO_CRT)
262 /*
263 * Check whether provided parameters are enough
264 * to deduce all others. The following incomplete
265 * parameter sets for private keys are supported:
266 *
267 * (1) P, Q missing.
268 * (2) D and potentially N missing.
269 *

--- 49 unchanged lines hidden (view full) ---

319 }
320
321 /*
322 * Step 3: Deduce all additional parameters specific
323 * to our current RSA implementation.
324 */
325
326#if !defined(MBEDTLS_RSA_NO_CRT)
321 if( is_priv )
327 if( is_priv && ! ( have_DP && have_DQ && have_QP ) )
322 {
323 ret = mbedtls_rsa_deduce_crt( &ctx->P, &ctx->Q, &ctx->D,
324 &ctx->DP, &ctx->DQ, &ctx->QP );
325 if( ret != 0 )
326 return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA + ret );
327 }
328#endif /* MBEDTLS_RSA_NO_CRT */
329

--- 2210 unchanged lines hidden ---
328 {
329 ret = mbedtls_rsa_deduce_crt( &ctx->P, &ctx->Q, &ctx->D,
330 &ctx->DP, &ctx->DQ, &ctx->QP );
331 if( ret != 0 )
332 return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA + ret );
333 }
334#endif /* MBEDTLS_RSA_NO_CRT */
335

--- 2210 unchanged lines hidden ---