diff options
author | Jack Lloyd <[email protected]> | 2017-10-03 00:38:15 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-10-03 00:38:15 -0400 |
commit | 04d64c3e0fe60a25b1f1a5c2eaf7e2986d2130dd (patch) | |
tree | 3dc2cc7e970fc5f1cdc94887b03704d82c37e07e /src/lib/math/bigint/big_code.cpp | |
parent | 180540de74c58a72492692f58b63f32647e80bd8 (diff) |
Add wrappers for reinterpret_cast between char* and uint8_t*
Generally speaking reinterpret_cast is sketchy stuff. But the
special case of char*/uint8_t* is both common and safe. By
isolating those, the remaining (likely sketchy) cases are easier
to grep for.
Diffstat (limited to 'src/lib/math/bigint/big_code.cpp')
-rw-r--r-- | src/lib/math/bigint/big_code.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/math/bigint/big_code.cpp b/src/lib/math/bigint/big_code.cpp index f7ab53291..c42819965 100644 --- a/src/lib/math/bigint/big_code.cpp +++ b/src/lib/math/bigint/big_code.cpp @@ -26,7 +26,7 @@ void BigInt::encode(uint8_t output[], const BigInt& n, Base base) secure_vector<uint8_t> binary(n.encoded_size(Binary)); n.binary_encode(binary.data()); - hex_encode(reinterpret_cast<char*>(output), + hex_encode(cast_uint8_ptr_to_char(output), binary.data(), binary.size()); } else if(base == Decimal) @@ -128,12 +128,12 @@ BigInt BigInt::decode(const uint8_t buf[], size_t length, Base base) binary = hex_decode_locked(buf0_with_leading_0, 2); - binary += hex_decode_locked(reinterpret_cast<const char*>(&buf[1]), + binary += hex_decode_locked(cast_uint8_ptr_to_char(&buf[1]), length - 1, false); } else - binary = hex_decode_locked(reinterpret_cast<const char*>(buf), + binary = hex_decode_locked(cast_uint8_ptr_to_char(buf), length, false); r.binary_decode(binary.data(), binary.size()); |