aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/math/bigint/big_code.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2015-03-11 23:38:57 +0000
committerlloyd <[email protected]>2015-03-11 23:38:57 +0000
commita4b75876eb2ae8b9b1edeea1927a6ad0da1dad88 (patch)
treed175654033f9e738a5679b368a3942026dae2de8 /src/lib/math/bigint/big_code.cpp
parent1bf1490726d859596ac95c78c9a7763b8d420b2d (diff)
Add BigInt::encode_1363 writing to specified buffer
Diffstat (limited to 'src/lib/math/bigint/big_code.cpp')
-rw-r--r--src/lib/math/bigint/big_code.cpp11
1 files changed, 8 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;
}
/*