From c691561f3198f481c13457433efbccc1c9fcd898 Mon Sep 17 00:00:00 2001 From: lloyd Date: Fri, 18 May 2012 20:32:36 +0000 Subject: Fairly huge update that replaces the old secmem types with std::vector using a custom allocator. Currently our allocator just does new/delete with a memset before deletion, and the mmap and mlock allocators have been removed. --- src/math/ec_gfp/point_gfp.cpp | 18 +++++++++--------- src/math/ec_gfp/point_gfp.h | 7 ++++--- 2 files changed, 13 insertions(+), 12 deletions(-) (limited to 'src/math/ec_gfp') diff --git a/src/math/ec_gfp/point_gfp.cpp b/src/math/ec_gfp/point_gfp.cpp index 7ac6b4141..ec6fed4a1 100644 --- a/src/math/ec_gfp/point_gfp.cpp +++ b/src/math/ec_gfp/point_gfp.cpp @@ -45,7 +45,7 @@ void PointGFp::monty_mult(BigInt& z, const BigInt& x, const BigInt& y) const const size_t p_size = curve.get_p_words(); const word p_dash = curve.get_p_dash(); - SecureVector& z_reg = z.get_reg(); + secure_vector& z_reg = z.get_reg(); z_reg.resize(2*p_size+1); zeroise(z_reg); @@ -71,7 +71,7 @@ void PointGFp::monty_sqr(BigInt& z, const BigInt& x) const const size_t p_size = curve.get_p_words(); const word p_dash = curve.get_p_dash(); - SecureVector& z_reg = z.get_reg(); + secure_vector& z_reg = z.get_reg(); z_reg.resize(2*p_size+1); zeroise(z_reg); @@ -479,22 +479,22 @@ bool PointGFp::operator==(const PointGFp& other) const } // encoding and decoding -SecureVector EC2OSP(const PointGFp& point, byte format) +secure_vector EC2OSP(const PointGFp& point, byte format) { if(point.is_zero()) - return SecureVector(1); // single 0 byte + return secure_vector(1); // single 0 byte const size_t p_bytes = point.get_curve().get_p().bytes(); BigInt x = point.get_affine_x(); BigInt y = point.get_affine_y(); - SecureVector bX = BigInt::encode_1363(x, p_bytes); - SecureVector bY = BigInt::encode_1363(y, p_bytes); + secure_vector bX = BigInt::encode_1363(x, p_bytes); + secure_vector bY = BigInt::encode_1363(y, p_bytes); if(format == PointGFp::UNCOMPRESSED) { - SecureVector result; + secure_vector result; result.push_back(0x04); result += bX; @@ -504,7 +504,7 @@ SecureVector EC2OSP(const PointGFp& point, byte format) } else if(format == PointGFp::COMPRESSED) { - SecureVector result; + secure_vector result; result.push_back(0x02 | static_cast(y.get_bit(0))); result += bX; @@ -513,7 +513,7 @@ SecureVector EC2OSP(const PointGFp& point, byte format) } else if(format == PointGFp::HYBRID) { - SecureVector result; + secure_vector result; result.push_back(0x06 | static_cast(y.get_bit(0))); result += bX; diff --git a/src/math/ec_gfp/point_gfp.h b/src/math/ec_gfp/point_gfp.h index 546a8dd6f..017f66e1c 100644 --- a/src/math/ec_gfp/point_gfp.h +++ b/src/math/ec_gfp/point_gfp.h @@ -245,7 +245,7 @@ class BOTAN_DLL PointGFp CurveGFp curve; BigInt coord_x, coord_y, coord_z; - mutable SecureVector ws; // workspace for Montgomery + mutable secure_vector ws; // workspace for Montgomery }; // relational operators @@ -278,12 +278,13 @@ inline PointGFp operator*(const PointGFp& point, const BigInt& scalar) } // encoding and decoding -SecureVector BOTAN_DLL EC2OSP(const PointGFp& point, byte format); +secure_vector BOTAN_DLL EC2OSP(const PointGFp& point, byte format); PointGFp BOTAN_DLL OS2ECP(const byte data[], size_t data_len, const CurveGFp& curve); -inline PointGFp OS2ECP(const MemoryRegion& data, const CurveGFp& curve) +template +PointGFp OS2ECP(const std::vector& data, const CurveGFp& curve) { return OS2ECP(&data[0], data.size(), curve); } } -- cgit v1.2.3