diff options
Diffstat (limited to 'src/lib/libcrypto/ec/ec_ameth.c')
-rw-r--r-- | src/lib/libcrypto/ec/ec_ameth.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/lib/libcrypto/ec/ec_ameth.c b/src/lib/libcrypto/ec/ec_ameth.c index 59957afd3d..5c9a76c8be 100644 --- a/src/lib/libcrypto/ec/ec_ameth.c +++ b/src/lib/libcrypto/ec/ec_ameth.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ec_ameth.c,v 1.32 2022/05/24 20:00:15 tb Exp $ */ | 1 | /* $OpenBSD: ec_ameth.c,v 1.33 2022/06/27 12:36:05 tb Exp $ */ |
2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 | * project 2006. | 3 | * project 2006. |
4 | */ | 4 | */ |
@@ -386,6 +386,25 @@ ec_bits(const EVP_PKEY * pkey) | |||
386 | return ret; | 386 | return ret; |
387 | } | 387 | } |
388 | 388 | ||
389 | static int | ||
390 | ec_security_bits(const EVP_PKEY *pkey) | ||
391 | { | ||
392 | int ecbits = ec_bits(pkey); | ||
393 | |||
394 | if (ecbits >= 512) | ||
395 | return 256; | ||
396 | if (ecbits >= 384) | ||
397 | return 192; | ||
398 | if (ecbits >= 256) | ||
399 | return 128; | ||
400 | if (ecbits >= 224) | ||
401 | return 112; | ||
402 | if (ecbits >= 160) | ||
403 | return 80; | ||
404 | |||
405 | return ecbits / 2; | ||
406 | } | ||
407 | |||
389 | static int | 408 | static int |
390 | ec_missing_parameters(const EVP_PKEY * pkey) | 409 | ec_missing_parameters(const EVP_PKEY * pkey) |
391 | { | 410 | { |
@@ -1006,6 +1025,7 @@ const EVP_PKEY_ASN1_METHOD eckey_asn1_meth = { | |||
1006 | 1025 | ||
1007 | .pkey_size = int_ec_size, | 1026 | .pkey_size = int_ec_size, |
1008 | .pkey_bits = ec_bits, | 1027 | .pkey_bits = ec_bits, |
1028 | .pkey_security_bits = ec_security_bits, | ||
1009 | 1029 | ||
1010 | .param_decode = eckey_param_decode, | 1030 | .param_decode = eckey_param_decode, |
1011 | .param_encode = eckey_param_encode, | 1031 | .param_encode = eckey_param_encode, |