Extended MaximInterface
Dependents: mbed_DS28EC20_GPIO
Diff: Utilities/Ecc256.cpp
- Revision:
- 6:a8c83a2e6fa4
- Parent:
- 0:f77ad7f72d04
--- a/Utilities/Ecc256.cpp Fri Jan 19 10:25:02 2018 -0600 +++ b/Utilities/Ecc256.cpp Wed Jan 23 13:11:04 2019 -0600 @@ -30,24 +30,32 @@ * ownership rights. *******************************************************************************/ -#include <algorithm> #include "Ecc256.hpp" namespace MaximInterface { namespace Ecc256 { -CertificateData createCertificateData(const PublicKey & publicKey, - const RomId & romId, - const ManId & manId) { - using std::copy; +void copy(Point::const_span src, Point::span dst) { + copy(src.x, dst.x); + copy(src.y, dst.y); +} + +void copy(KeyPair::const_span src, KeyPair::span dst) { + copy(src.privateKey, dst.privateKey); + copy(src.publicKey, dst.publicKey); +} - CertificateData data; - CertificateData::iterator dataIt = data.begin(); - dataIt = copy(publicKey.x.begin(), publicKey.x.end(), dataIt); - dataIt = copy(publicKey.y.begin(), publicKey.y.end(), dataIt); - dataIt = copy(romId.begin(), romId.end(), dataIt); - copy(manId.begin(), manId.end(), dataIt); - return data; +void copy(Signature::const_span src, Signature::span dst) { + copy(src.r, dst.r); + copy(src.s, dst.s); +} + +PublicKey::span CertificateData::publicKey() { + const PublicKey::span span = { + make_span(result_).subspan<publicKeyIdx, Scalar::size>(), + make_span(result_) + .subspan<publicKeyIdx + Scalar::size, Scalar::size>()}; + return span; } } // namespace Ecc256