aboutsummaryrefslogtreecommitdiffstats
path: root/src/math/ec_gfp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-05-18 20:32:36 +0000
committerlloyd <[email protected]>2012-05-18 20:32:36 +0000
commitc691561f3198f481c13457433efbccc1c9fcd898 (patch)
treea45ea2c5a30e0cb009fbcb68a61ef39332ff790c /src/math/ec_gfp
parentd76700f01c7ecac5633edf75f8d7408b46c5dbac (diff)
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.
Diffstat (limited to 'src/math/ec_gfp')
-rw-r--r--src/math/ec_gfp/point_gfp.cpp18
-rw-r--r--src/math/ec_gfp/point_gfp.h7
2 files changed, 13 insertions, 12 deletions
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<word>& z_reg = z.get_reg();
+ secure_vector<word>& 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<word>& z_reg = z.get_reg();
+ secure_vector<word>& 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<byte> EC2OSP(const PointGFp& point, byte format)
+secure_vector<byte> EC2OSP(const PointGFp& point, byte format)
{
if(point.is_zero())
- return SecureVector<byte>(1); // single 0 byte
+ return secure_vector<byte>(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<byte> bX = BigInt::encode_1363(x, p_bytes);
- SecureVector<byte> bY = BigInt::encode_1363(y, p_bytes);
+ secure_vector<byte> bX = BigInt::encode_1363(x, p_bytes);
+ secure_vector<byte> bY = BigInt::encode_1363(y, p_bytes);
if(format == PointGFp::UNCOMPRESSED)
{
- SecureVector<byte> result;
+ secure_vector<byte> result;
result.push_back(0x04);
result += bX;
@@ -504,7 +504,7 @@ SecureVector<byte> EC2OSP(const PointGFp& point, byte format)
}
else if(format == PointGFp::COMPRESSED)
{
- SecureVector<byte> result;
+ secure_vector<byte> result;
result.push_back(0x02 | static_cast<byte>(y.get_bit(0)));
result += bX;
@@ -513,7 +513,7 @@ SecureVector<byte> EC2OSP(const PointGFp& point, byte format)
}
else if(format == PointGFp::HYBRID)
{
- SecureVector<byte> result;
+ secure_vector<byte> result;
result.push_back(0x06 | static_cast<byte>(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<word> ws; // workspace for Montgomery
+ mutable secure_vector<word> ws; // workspace for Montgomery
};
// relational operators
@@ -278,12 +278,13 @@ inline PointGFp operator*(const PointGFp& point, const BigInt& scalar)
}
// encoding and decoding
-SecureVector<byte> BOTAN_DLL EC2OSP(const PointGFp& point, byte format);
+secure_vector<byte> 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<byte>& data, const CurveGFp& curve)
+template<typename Alloc>
+PointGFp OS2ECP(const std::vector<byte, Alloc>& data, const CurveGFp& curve)
{ return OS2ECP(&data[0], data.size(), curve); }
}