static int wrap_nettle_pk_fixup (gnutls_pk_algorithm_t algo, gnutls_direction_t direction, gnutls_pk_params_st * params) { int result; if (direction == GNUTLS_IMPORT && algo == GNUTLS_PK_RSA) { /* do not trust the generated values. Some old private keys * generated by us have mess on the values. Those were very * old but it seemed some of the shipped example private * keys were as old. */ mpz_invert (TOMPZ (params->params[RSA_COEF]), TOMPZ (params->params[RSA_PRIME2]), TOMPZ (params->params[RSA_PRIME1])); /* calculate exp1 [6] and exp2 [7] */ _gnutls_mpi_release (¶ms->params[RSA_E1]); _gnutls_mpi_release (¶ms->params[RSA_E2]); result = calc_rsa_exp (params); if (result < 0) { gnutls_assert (); return result; } params->params_nr = RSA_PRIVATE_PARAMS; } return 0; }
static int wrap_nettle_pk_fixup(gnutls_pk_algorithm_t algo, gnutls_direction_t direction, gnutls_pk_params_st * params) { int ret; if (direction == GNUTLS_IMPORT && algo == GNUTLS_PK_RSA) { /* do not trust the generated values. Some old private keys * generated by us have mess on the values. Those were very * old but it seemed some of the shipped example private * keys were as old. */ if (params->params_nr < RSA_PRIVATE_PARAMS - 3) return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST); if (params->params[RSA_COEF] == NULL) { ret = _gnutls_mpi_init(¶ms->params[RSA_COEF]); if (ret < 0) return gnutls_assert_val(ret); } mpz_invert(TOMPZ(params->params[RSA_COEF]), TOMPZ(params->params[RSA_PRIME2]), TOMPZ(params->params[RSA_PRIME1])); /* calculate exp1 [6] and exp2 [7] */ zrelease_mpi_key(¶ms->params[RSA_E1]); zrelease_mpi_key(¶ms->params[RSA_E2]); ret = calc_rsa_exp(params); if (ret < 0) return gnutls_assert_val(ret); params->params_nr = RSA_PRIVATE_PARAMS; } return 0; }