aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/3rdparty/botan/src/lib/pubkey/ec_group
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/3rdparty/botan/src/lib/pubkey/ec_group')
-rw-r--r--src/libs/3rdparty/botan/src/lib/pubkey/ec_group/ec_group.cpp36
-rw-r--r--src/libs/3rdparty/botan/src/lib/pubkey/ec_group/ec_group.h2
-rw-r--r--src/libs/3rdparty/botan/src/lib/pubkey/ec_group/point_mul.cpp8
3 files changed, 18 insertions, 28 deletions
diff --git a/src/libs/3rdparty/botan/src/lib/pubkey/ec_group/ec_group.cpp b/src/libs/3rdparty/botan/src/lib/pubkey/ec_group/ec_group.cpp
index 586603507e..f4419c7f0b 100644
--- a/src/libs/3rdparty/botan/src/lib/pubkey/ec_group/ec_group.cpp
+++ b/src/libs/3rdparty/botan/src/lib/pubkey/ec_group/ec_group.cpp
@@ -10,6 +10,7 @@
#include <botan/ec_group.h>
#include <botan/internal/point_mul.h>
+#include <botan/internal/primality.h>
#include <botan/ber_dec.h>
#include <botan/der_enc.h>
#include <botan/oids.h>
@@ -19,12 +20,6 @@
#include <botan/rng.h>
#include <vector>
-#if defined(BOTAN_HAS_SYSTEM_RNG)
- #include <botan/system_rng.h>
-#elif defined(BOTAN_HAS_HMAC_DRBG) && defined(BOTAN_HAS_SHA2_32)
- #include <botan/hmac_drbg.h>
-#endif
-
namespace Botan {
class EC_Group_Data final
@@ -318,23 +313,7 @@ std::shared_ptr<EC_Group_Data> EC_Group::BER_decode_EC_group(const uint8_t bits[
.end_cons()
.verify_end();
-#if defined(BOTAN_HAS_SYSTEM_RNG)
- System_RNG rng;
-#elif defined(BOTAN_HAS_HMAC_DRBG) && defined(BOTAN_HAS_SHA2_32)
- /*
- * This is not ideal because the data is attacker controlled, but
- * it seems like it would be difficult for someone to come up
- * with an valid ASN.1 encoding where the prime happened to pass
- * Miller-Rabin test with exactly the values chosen when
- * HMAC_DRBG is seeded with the overall data.
- */
- HMAC_DRBG rng("SHA-256");
- rng.add_entropy(bits, len);
-#else
- Null_RNG rng;
-#endif
-
- if(p.bits() < 64 || p.is_negative() || (is_prime(p, rng) == false))
+ if(p.bits() < 64 || p.is_negative() || !is_bailie_psw_probable_prime(p))
throw Decoding_Error("Invalid ECC p parameter");
if(a.is_negative() || a >= p)
@@ -343,7 +322,7 @@ std::shared_ptr<EC_Group_Data> EC_Group::BER_decode_EC_group(const uint8_t bits[
if(b <= 0 || b >= p)
throw Decoding_Error("Invalid ECC b parameter");
- if(order <= 0)
+ if(order <= 0 || !is_bailie_psw_probable_prime(order))
throw Decoding_Error("Invalid ECC order parameter");
if(cofactor <= 0 || cofactor >= 16)
@@ -547,6 +526,15 @@ const OID& EC_Group::get_curve_oid() const
return data().oid();
}
+size_t EC_Group::point_size(PointGFp::Compression_Type format) const
+ {
+ // Hybrid and standard format are (x,y), compressed is y, +1 format byte
+ if(format == PointGFp::COMPRESSED)
+ return (1 + get_p_bytes());
+ else
+ return (1 + 2*get_p_bytes());
+ }
+
PointGFp EC_Group::OS2ECP(const uint8_t bits[], size_t len) const
{
return Botan::OS2ECP(bits, len, data().curve());
diff --git a/src/libs/3rdparty/botan/src/lib/pubkey/ec_group/ec_group.h b/src/libs/3rdparty/botan/src/lib/pubkey/ec_group/ec_group.h
index f8c1c1a123..8a22cebce1 100644
--- a/src/libs/3rdparty/botan/src/lib/pubkey/ec_group/ec_group.h
+++ b/src/libs/3rdparty/botan/src/lib/pubkey/ec_group/ec_group.h
@@ -302,6 +302,8 @@ class BOTAN_PUBLIC_API(2,0) EC_Group final
*/
PointGFp zero_point() const;
+ size_t point_size(PointGFp::Compression_Type format) const;
+
PointGFp OS2ECP(const uint8_t bits[], size_t len) const;
template<typename Alloc>
diff --git a/src/libs/3rdparty/botan/src/lib/pubkey/ec_group/point_mul.cpp b/src/libs/3rdparty/botan/src/lib/pubkey/ec_group/point_mul.cpp
index 760f060ced..da3abaacc6 100644
--- a/src/libs/3rdparty/botan/src/lib/pubkey/ec_group/point_mul.cpp
+++ b/src/libs/3rdparty/botan/src/lib/pubkey/ec_group/point_mul.cpp
@@ -170,7 +170,7 @@ PointGFp_Var_Point_Precompute::PointGFp_Var_Point_Precompute(const PointGFp& poi
if(ws.size() < PointGFp::WORKSPACE_SIZE)
ws.resize(PointGFp::WORKSPACE_SIZE);
- std::vector<PointGFp> U(1U << m_window_bits);
+ std::vector<PointGFp> U(static_cast<size_t>(1) << m_window_bits);
U[0] = point.zero();
U[1] = point;
@@ -354,10 +354,10 @@ PointGFp PointGFp_Multi_Point_Precompute::multi_exp(const BigInt& z1,
H.mult2i(2, ws);
}
- const uint8_t z1_b = z1.get_substring(z_bits - i - 2, 2);
- const uint8_t z2_b = z2.get_substring(z_bits - i - 2, 2);
+ const uint32_t z1_b = z1.get_substring(z_bits - i - 2, 2);
+ const uint32_t z2_b = z2.get_substring(z_bits - i - 2, 2);
- const uint8_t z12 = (4*z2_b) + z1_b;
+ const uint32_t z12 = (4*z2_b) + z1_b;
// This function is not intended to be const time
if(z12)