Permalink
Browse files

ec: Avoid exposing internal function

  • Loading branch information...
leoetlino committed May 15, 2018
1 parent b9dd94b commit e83591f188f329e9f29f2c5c59ee68a551ac454c
Showing with 12 additions and 4 deletions.
  1. +7 −1 Source/Core/Common/Crypto/ec.cpp
  2. +3 −1 Source/Core/Common/Crypto/ec.h
  3. +2 −2 Source/Core/Core/IOS/IOSC.cpp
@@ -313,7 +313,7 @@ static void point_add(u8* r, const u8* p, const u8* q)
elt_add(ry, s, rx);
}
void point_mul(u8* d, const u8* a, const u8* b) // a is bignum
static void point_mul(u8* d, const u8* a, const u8* b) // a is bignum
{
u32 i;
u8 mask;
@@ -410,6 +410,12 @@ void ec_priv_to_pub(const u8* k, u8* Q)
point_mul(Q, k, ec_G);
}
std::array<u8, 60> ComputeSharedSecret(const u8* private_key, const u8* public_key)
{
std::array<u8, 60> shared_secret;
point_mul(shared_secret.data(), private_key, public_key);
return shared_secret;
}
#ifdef _MSC_VER
#pragma warning(pop)
#endif
@@ -4,10 +4,12 @@
#pragma once
#include <array>
#include "Common/CommonTypes.h"
void generate_ecdsa(u8* R, u8* S, const u8* k, const u8* hash);
void ec_priv_to_pub(const u8* k, u8* Q);
void point_mul(u8* d, const u8* a, const u8* b);
std::array<u8, 60> ComputeSharedSecret(const u8* private_key, const u8* public_key);
@@ -250,8 +250,8 @@ ReturnCode IOSC::ComputeSharedKey(Handle dest_handle, Handle private_handle, Han
}
// Calculate the ECC shared secret.
std::array<u8, 0x3c> shared_secret;
point_mul(shared_secret.data(), private_entry->data.data(), public_entry->data.data());
const std::array<u8, 0x3c> shared_secret =
ComputeSharedSecret(private_entry->data.data(), public_entry->data.data());
std::array<u8, 20> sha1;
mbedtls_sha1(shared_secret.data(), shared_secret.size() / 2, sha1.data());

0 comments on commit e83591f

Please sign in to comment.