Skip to content

Commit

Permalink
Merge pull request #3993 from Rohde-Schwarz/span/some_pubkey_things
Browse files Browse the repository at this point in the history
  • Loading branch information
reneme committed Apr 9, 2024
2 parents 8970266 + 7cf8919 commit ad0aeed
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
9 changes: 6 additions & 3 deletions src/lib/pubkey/curve25519/curve25519.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace {

void size_check(size_t size, const char* thing) {
if(size != 32) {
throw Decoding_Error(fmt("Invalid size {} for Curve2551 {}", size, thing));
throw Decoding_Error(fmt("Invalid size {} for Curve25519 {}", size, thing));
}
}

Expand All @@ -44,8 +44,11 @@ bool Curve25519_PublicKey::check_key(RandomNumberGenerator& /*rng*/, bool /*stro
return true; // no tests possible?
}

Curve25519_PublicKey::Curve25519_PublicKey(const AlgorithmIdentifier& /*unused*/, std::span<const uint8_t> key_bits) {
m_public.assign(key_bits.begin(), key_bits.end());
Curve25519_PublicKey::Curve25519_PublicKey(const AlgorithmIdentifier& /*unused*/, std::span<const uint8_t> key_bits) :
Curve25519_PublicKey(key_bits) {}

Curve25519_PublicKey::Curve25519_PublicKey(std::span<const uint8_t> pub) {
m_public.assign(pub.begin(), pub.end());

size_check(m_public.size(), "public key");
}
Expand Down
8 changes: 1 addition & 7 deletions src/lib/pubkey/curve25519/curve25519.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,7 @@ class BOTAN_PUBLIC_API(2, 0) Curve25519_PublicKey : public virtual Public_Key {
* Create a Curve25519 Public Key.
* @param pub 32-byte raw public key
*/
explicit Curve25519_PublicKey(const std::vector<uint8_t>& pub) : m_public(pub) {}

/**
* Create a Curve25519 Public Key.
* @param pub 32-byte raw public key
*/
explicit Curve25519_PublicKey(const secure_vector<uint8_t>& pub) : m_public(pub.begin(), pub.end()) {}
explicit Curve25519_PublicKey(std::span<const uint8_t> pub);

protected:
Curve25519_PublicKey() = default;
Expand Down
3 changes: 1 addition & 2 deletions src/lib/pubkey/ec_group/ec_point.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,7 @@ EC_Point BOTAN_PUBLIC_API(2, 0) OS2ECP(const uint8_t data[], size_t data_len, co
std::pair<BigInt, BigInt> BOTAN_UNSTABLE_API
OS2ECP(const uint8_t data[], size_t data_len, const BigInt& curve_p, const BigInt& curve_a, const BigInt& curve_b);

template <typename Alloc>
EC_Point OS2ECP(const std::vector<uint8_t, Alloc>& data, const CurveGFp& curve) {
inline EC_Point OS2ECP(std::span<const uint8_t> data, const CurveGFp& curve) {
return OS2ECP(data.data(), data.size(), curve);
}

Expand Down
3 changes: 1 addition & 2 deletions src/lib/pubkey/ed25519/ed25519.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ class BOTAN_PUBLIC_API(2, 2) Ed25519_PublicKey : public virtual Public_Key {
*/
Ed25519_PublicKey(const AlgorithmIdentifier& alg_id, std::span<const uint8_t> key_bits);

template <typename Alloc>
Ed25519_PublicKey(const std::vector<uint8_t, Alloc>& pub) : Ed25519_PublicKey(pub.data(), pub.size()) {}
Ed25519_PublicKey(std::span<const uint8_t> pub) : Ed25519_PublicKey(pub.data(), pub.size()) {}

Ed25519_PublicKey(const uint8_t pub_key[], size_t len);

Expand Down

0 comments on commit ad0aeed

Please sign in to comment.