diff options
author | lloyd <[email protected]> | 2015-03-11 23:38:57 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2015-03-11 23:38:57 +0000 |
commit | a4b75876eb2ae8b9b1edeea1927a6ad0da1dad88 (patch) | |
tree | d175654033f9e738a5679b368a3942026dae2de8 | |
parent | 1bf1490726d859596ac95c78c9a7763b8d420b2d (diff) |
Add BigInt::encode_1363 writing to specified buffer
-rw-r--r-- | src/lib/math/bigint/big_code.cpp | 11 | ||||
-rw-r--r-- | src/lib/math/bigint/bigint.h | 2 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/lib/math/bigint/big_code.cpp b/src/lib/math/bigint/big_code.cpp index 228edb51a..d71e57849 100644 --- a/src/lib/math/bigint/big_code.cpp +++ b/src/lib/math/bigint/big_code.cpp @@ -81,15 +81,20 @@ secure_vector<byte> BigInt::encode_locked(const BigInt& n, Base base) */ secure_vector<byte> BigInt::encode_1363(const BigInt& n, size_t bytes) { + secure_vector<byte> output(bytes); + encode_1363(&output[0], output.size(), n); + return output; + } + +//static +void BigInt::encode_1363(byte output[], size_t bytes, const BigInt& n) + { const size_t n_bytes = n.bytes(); if(n_bytes > bytes) throw Encoding_Error("encode_1363: n is too large to encode properly"); const size_t leading_0s = bytes - n_bytes; - - secure_vector<byte> output(bytes); encode(&output[leading_0s], n, Binary); - return output; } /* diff --git a/src/lib/math/bigint/bigint.h b/src/lib/math/bigint/bigint.h index 269a74259..ba5d7198f 100644 --- a/src/lib/math/bigint/bigint.h +++ b/src/lib/math/bigint/bigint.h @@ -554,6 +554,8 @@ class BOTAN_DLL BigInt */ static secure_vector<byte> encode_1363(const BigInt& n, size_t bytes); + static void encode_1363(byte out[], size_t bytes, const BigInt& n); + private: secure_vector<word> m_reg; Sign m_signedness = Positive; |