aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/gost_3410
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-12-11 15:28:38 -0500
committerJack Lloyd <[email protected]>2016-12-18 16:48:24 -0500
commitf3cb3edb512bdcab498d825886c3366c341b3f78 (patch)
tree645c73ec295a5a34f25d99903b6d9fa9751e86d3 /src/lib/pubkey/gost_3410
parentc1dd21253c1f3188ff45d3ad47698efd08235ae8 (diff)
Convert to using standard uintN_t integer types
Renames a couple of functions for somewhat better name consistency, eg make_u32bit becomes make_uint32. The old typedefs remain for now since probably lots of application code uses them.
Diffstat (limited to 'src/lib/pubkey/gost_3410')
-rw-r--r--src/lib/pubkey/gost_3410/gost_3410.cpp30
-rw-r--r--src/lib/pubkey/gost_3410/gost_3410.h6
2 files changed, 18 insertions, 18 deletions
diff --git a/src/lib/pubkey/gost_3410/gost_3410.cpp b/src/lib/pubkey/gost_3410/gost_3410.cpp
index e8923c71a..ee263bb96 100644
--- a/src/lib/pubkey/gost_3410/gost_3410.cpp
+++ b/src/lib/pubkey/gost_3410/gost_3410.cpp
@@ -15,14 +15,14 @@
namespace Botan {
-std::vector<byte> GOST_3410_PublicKey::public_key_bits() const
+std::vector<uint8_t> GOST_3410_PublicKey::public_key_bits() const
{
const BigInt x = public_point().get_affine_x();
const BigInt y = public_point().get_affine_y();
size_t part_size = std::max(x.bytes(), y.bytes());
- std::vector<byte> bits(2*part_size);
+ std::vector<uint8_t> bits(2*part_size);
x.binary_encode(&bits[part_size - x.bytes()]);
y.binary_encode(&bits[2*part_size - y.bytes()]);
@@ -39,7 +39,7 @@ std::vector<byte> GOST_3410_PublicKey::public_key_bits() const
AlgorithmIdentifier GOST_3410_PublicKey::algorithm_identifier() const
{
- std::vector<byte> params =
+ std::vector<uint8_t> params =
DER_Encoder().start_cons(SEQUENCE)
.encode(OID(domain().get_oid()))
.end_cons()
@@ -49,7 +49,7 @@ AlgorithmIdentifier GOST_3410_PublicKey::algorithm_identifier() const
}
GOST_3410_PublicKey::GOST_3410_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits)
+ const std::vector<uint8_t>& key_bits)
{
OID ecc_param_id;
@@ -58,7 +58,7 @@ GOST_3410_PublicKey::GOST_3410_PublicKey(const AlgorithmIdentifier& alg_id,
m_domain_params = EC_Group(ecc_param_id);
- secure_vector<byte> bits;
+ secure_vector<uint8_t> bits;
BER_Decoder(key_bits).decode(bits, OCTET_STRING);
const size_t part_size = bits.size() / 2;
@@ -81,9 +81,9 @@ GOST_3410_PublicKey::GOST_3410_PublicKey(const AlgorithmIdentifier& alg_id,
namespace {
-BigInt decode_le(const byte msg[], size_t msg_len)
+BigInt decode_le(const uint8_t msg[], size_t msg_len)
{
- secure_vector<byte> msg_le(msg, msg + msg_len);
+ secure_vector<uint8_t> msg_le(msg, msg + msg_len);
for(size_t i = 0; i != msg_le.size() / 2; ++i)
std::swap(msg_le[i], msg_le[msg_le.size()-1-i]);
@@ -107,7 +107,7 @@ class GOST_3410_Signature_Operation : public PK_Ops::Signature_with_EMSA
size_t max_input_bits() const override { return m_order.bits(); }
- secure_vector<byte> raw_sign(const byte msg[], size_t msg_len,
+ secure_vector<uint8_t> raw_sign(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng) override;
private:
@@ -117,8 +117,8 @@ class GOST_3410_Signature_Operation : public PK_Ops::Signature_with_EMSA
const BigInt& m_x;
};
-secure_vector<byte>
-GOST_3410_Signature_Operation::raw_sign(const byte msg[], size_t msg_len,
+secure_vector<uint8_t>
+GOST_3410_Signature_Operation::raw_sign(const uint8_t msg[], size_t msg_len,
RandomNumberGenerator& rng)
{
BigInt k;
@@ -141,7 +141,7 @@ GOST_3410_Signature_Operation::raw_sign(const byte msg[], size_t msg_len,
if(r == 0 || s == 0)
throw Invalid_State("GOST 34.10: r == 0 || s == 0");
- secure_vector<byte> output(2*m_order.bytes());
+ secure_vector<uint8_t> output(2*m_order.bytes());
s.binary_encode(&output[output.size() / 2 - s.bytes()]);
r.binary_encode(&output[output.size() - r.bytes()]);
return output;
@@ -165,16 +165,16 @@ class GOST_3410_Verification_Operation : public PK_Ops::Verification_with_EMSA
bool with_recovery() const override { return false; }
- bool verify(const byte msg[], size_t msg_len,
- const byte sig[], size_t sig_len) override;
+ bool verify(const uint8_t msg[], size_t msg_len,
+ const uint8_t sig[], size_t sig_len) override;
private:
const PointGFp& m_base_point;
const PointGFp& m_public_point;
const BigInt& m_order;
};
-bool GOST_3410_Verification_Operation::verify(const byte msg[], size_t msg_len,
- const byte sig[], size_t sig_len)
+bool GOST_3410_Verification_Operation::verify(const uint8_t msg[], size_t msg_len,
+ const uint8_t sig[], size_t sig_len)
{
if(sig_len != m_order.bytes()*2)
return false;
diff --git a/src/lib/pubkey/gost_3410/gost_3410.h b/src/lib/pubkey/gost_3410/gost_3410.h
index 49f328d56..dbaf68ada 100644
--- a/src/lib/pubkey/gost_3410/gost_3410.h
+++ b/src/lib/pubkey/gost_3410/gost_3410.h
@@ -36,7 +36,7 @@ class BOTAN_DLL GOST_3410_PublicKey : public virtual EC_PublicKey
* @param key_bits DER encoded public key bits
*/
GOST_3410_PublicKey(const AlgorithmIdentifier& alg_id,
- const std::vector<byte>& key_bits);
+ const std::vector<uint8_t>& key_bits);
/**
* Get this keys algorithm name.
@@ -46,7 +46,7 @@ class BOTAN_DLL GOST_3410_PublicKey : public virtual EC_PublicKey
AlgorithmIdentifier algorithm_identifier() const override;
- std::vector<byte> public_key_bits() const override;
+ std::vector<uint8_t> public_key_bits() const override;
size_t message_parts() const override { return 2; }
@@ -74,7 +74,7 @@ class BOTAN_DLL GOST_3410_PrivateKey : public GOST_3410_PublicKey,
* @param key_bits PKCS #8 structure
*/
GOST_3410_PrivateKey(const AlgorithmIdentifier& alg_id,
- const secure_vector<byte>& key_bits) :
+ const secure_vector<uint8_t>& key_bits) :
EC_PrivateKey(alg_id, key_bits) {}
/**