aboutsummaryrefslogtreecommitdiffstats
path: root/src/pubkey
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-02-25 02:01:06 +0000
committerlloyd <[email protected]>2010-02-25 02:01:06 +0000
commit2d1dd244a6714687c97736a809e9dd31f506306c (patch)
tree25d91133fd81ba0d1404bcec8c7984b4aac71f5b /src/pubkey
parentaab1529d89961521e9cb6f2d65de98729107891a (diff)
Convert PointGFp::get_affine_{x,y} to return just the BigInt value
Diffstat (limited to 'src/pubkey')
-rw-r--r--src/pubkey/ecdsa/ecdsa_op.cpp6
-rw-r--r--src/pubkey/eckaeg/eckaeg_op.cpp14
-rw-r--r--src/pubkey/gost_3410/gost_3410.cpp10
3 files changed, 16 insertions, 14 deletions
diff --git a/src/pubkey/ecdsa/ecdsa_op.cpp b/src/pubkey/ecdsa/ecdsa_op.cpp
index d37809962..0fb9fc564 100644
--- a/src/pubkey/ecdsa/ecdsa_op.cpp
+++ b/src/pubkey/ecdsa/ecdsa_op.cpp
@@ -1,7 +1,7 @@
/*
* ECDSA Operation
* (C) 2007 FlexSecure GmbH
-* 2008-2009 Jack Lloyd
+* 2008-2010 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
@@ -44,7 +44,7 @@ bool Default_ECDSA_Op::verify(const byte msg[], u32bit msg_len,
if(R.is_zero())
return false;
- BigInt x = R.get_affine_x().get_value();
+ BigInt x = R.get_affine_x();
return (x % n == r);
}
@@ -64,7 +64,7 @@ SecureVector<byte> Default_ECDSA_Op::sign(const byte msg[], u32bit msg_len,
PointGFp k_times_P = dom_pars.get_base_point() * k;
k_times_P.check_invariants();
- BigInt r = k_times_P.get_affine_x().get_value() % n;
+ BigInt r = k_times_P.get_affine_x() % n;
if(r == 0)
throw Internal_Error("Default_ECDSA_Op::sign: r was zero");
diff --git a/src/pubkey/eckaeg/eckaeg_op.cpp b/src/pubkey/eckaeg/eckaeg_op.cpp
index 1af5cb165..4fb0a23eb 100644
--- a/src/pubkey/eckaeg/eckaeg_op.cpp
+++ b/src/pubkey/eckaeg/eckaeg_op.cpp
@@ -1,7 +1,7 @@
/*
* ECKAEG Operation
* (C) 2007 FlexSecure GmbH
-* 2008 Jack Lloyd
+* 2008-2010 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
@@ -22,16 +22,18 @@ Default_ECKAEG_Op::Default_ECKAEG_Op(const EC_Domain_Params& dom_pars,
SecureVector<byte> Default_ECKAEG_Op::agree(const PointGFp& i) const
{
- BigInt cofactor(m_dom_pars.get_cofactor());
+ BigInt cofactor = m_dom_pars.get_cofactor();
BigInt n = m_dom_pars.get_order();
- BigInt l(inverse_mod(cofactor,n)); // l=h^-1 mod n
- PointGFp Q(cofactor*i); // q = h*Pb
- PointGFp S(Q);
+ BigInt l = inverse_mod(cofactor, n);
+
+ PointGFp S = cofactor * i;
S *= (m_priv_key * l) % n;
S.check_invariants();
- return FE2OSP(S.get_affine_x()); // fe2os(xs)
+
+ return BigInt::encode_1363(S.get_affine_x(),
+ S.get_curve().get_p().bytes());
}
}
diff --git a/src/pubkey/gost_3410/gost_3410.cpp b/src/pubkey/gost_3410/gost_3410.cpp
index bb68e2b8d..24e078dca 100644
--- a/src/pubkey/gost_3410/gost_3410.cpp
+++ b/src/pubkey/gost_3410/gost_3410.cpp
@@ -2,7 +2,7 @@
* GOST 34.10-2001 implemenation
* (C) 2007 Falko Strenzke, FlexSecure GmbH
* Manuel Hartl, FlexSecure GmbH
-* (C) 2008-2009 Jack Lloyd
+* (C) 2008-2010 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
@@ -72,8 +72,8 @@ X509_Encoder* GOST_3410_PublicKey::x509_encoder() const
key->affirm_init();
// Trust CryptoPro to come up with something obnoxious
- const BigInt x = key->mp_public_point->get_affine_x().get_value();
- const BigInt y = key->mp_public_point->get_affine_y().get_value();
+ const BigInt x = key->mp_public_point->get_affine_x();
+ const BigInt y = key->mp_public_point->get_affine_y();
SecureVector<byte> bits(2*std::max(x.bytes(), y.bytes()));
@@ -234,7 +234,7 @@ bool GOST_3410_PublicKey::verify(const byte msg[], u32bit msg_len,
PointGFp R = (z1 * mp_dom_pars->get_base_point() + z2 * *mp_public_point);
- return (R.get_affine_x().get_value() == r);
+ return (R.get_affine_x() == r);
}
GOST_3410_PublicKey::GOST_3410_PublicKey(const EC_Domain_Params& dom_par,
@@ -333,7 +333,7 @@ GOST_3410_PrivateKey::sign(const byte msg[],
PointGFp k_times_P = mp_dom_pars->get_base_point() * k;
k_times_P.check_invariants();
- BigInt r = k_times_P.get_affine_x().get_value() % n;
+ BigInt r = k_times_P.get_affine_x() % n;
if(r == 0)
throw Internal_Error("GOST_3410::sign: r was zero");