mirror of https://github.com/openssl/openssl.git
				
				
				
			ossl_ffc_params_copy: Copy the keylength too
Reviewed-by: Kurt Roeckx <kurt@roeckx.be> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Hugo Landau <hlandau@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18480)
This commit is contained in:
		
							parent
							
								
									2266d1cad0
								
							
						
					
					
						commit
						5f311b10ab
					
				|  | @ -196,6 +196,7 @@ int ossl_ffc_params_copy(FFC_PARAMS *dst, const FFC_PARAMS *src) | ||||||
|     dst->h = src->h; |     dst->h = src->h; | ||||||
|     dst->gindex = src->gindex; |     dst->gindex = src->gindex; | ||||||
|     dst->flags = src->flags; |     dst->flags = src->flags; | ||||||
|  |     dst->keylength = src->keylength; | ||||||
|     return 1; |     return 1; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -618,6 +618,8 @@ static int ffc_private_gen_test(int index) | ||||||
|                                                  ossl_ifc_ffc_compute_security_bits(BN_num_bits(params->p)), |                                                  ossl_ifc_ffc_compute_security_bits(BN_num_bits(params->p)), | ||||||
|                                                  priv))) |                                                  priv))) | ||||||
|         goto err; |         goto err; | ||||||
|  |     if (!TEST_int_le(BN_num_bits(priv), 225)) | ||||||
|  |         goto err; | ||||||
|     if (!TEST_true(ossl_ffc_validate_private_key(params->q, priv, &res))) |     if (!TEST_true(ossl_ffc_validate_private_key(params->q, priv, &res))) | ||||||
|         goto err; |         goto err; | ||||||
| 
 | 
 | ||||||
|  | @ -628,6 +630,37 @@ err: | ||||||
|     BN_CTX_free(ctx); |     BN_CTX_free(ctx); | ||||||
|     return ret; |     return ret; | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | static int ffc_params_copy_test(void) | ||||||
|  | { | ||||||
|  |     int ret = 0; | ||||||
|  |     DH *dh = NULL; | ||||||
|  |     FFC_PARAMS *params, copy; | ||||||
|  | 
 | ||||||
|  |     ossl_ffc_params_init(©); | ||||||
|  | 
 | ||||||
|  |     if (!TEST_ptr(dh = DH_new_by_nid(NID_ffdhe3072))) | ||||||
|  |         goto err; | ||||||
|  |     params = ossl_dh_get0_params(dh); | ||||||
|  | 
 | ||||||
|  |     if (!TEST_int_eq(params->keylength, 275)) | ||||||
|  |         goto err; | ||||||
|  | 
 | ||||||
|  |     if (!TEST_true(ossl_ffc_params_copy(©, params))) | ||||||
|  |         goto err; | ||||||
|  | 
 | ||||||
|  |     if (!TEST_int_eq(copy.keylength, 275)) | ||||||
|  |         goto err; | ||||||
|  | 
 | ||||||
|  |     if (!TEST_true(ossl_ffc_params_cmp(©, params, 0))) | ||||||
|  |         goto err; | ||||||
|  | 
 | ||||||
|  |     ret = 1; | ||||||
|  | err: | ||||||
|  |     ossl_ffc_params_cleanup(©); | ||||||
|  |     DH_free(dh); | ||||||
|  |     return ret; | ||||||
|  | } | ||||||
| #endif /* OPENSSL_NO_DH */ | #endif /* OPENSSL_NO_DH */ | ||||||
| 
 | 
 | ||||||
| int setup_tests(void) | int setup_tests(void) | ||||||
|  | @ -643,6 +676,7 @@ int setup_tests(void) | ||||||
|     ADD_TEST(ffc_public_validate_test); |     ADD_TEST(ffc_public_validate_test); | ||||||
|     ADD_TEST(ffc_private_validate_test); |     ADD_TEST(ffc_private_validate_test); | ||||||
|     ADD_ALL_TESTS(ffc_private_gen_test, 10); |     ADD_ALL_TESTS(ffc_private_gen_test, 10); | ||||||
|  |     ADD_TEST(ffc_params_copy_test); | ||||||
| #endif /* OPENSSL_NO_DH */ | #endif /* OPENSSL_NO_DH */ | ||||||
|     return 1; |     return 1; | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue