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/misc | |
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/misc')
-rw-r--r-- | src/lib/misc/cryptobox/cryptobox.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/misc/cryptobox/cryptobox.cpp b/src/lib/misc/cryptobox/cryptobox.cpp index 195263368..5d2364871 100644 --- a/src/lib/misc/cryptobox/cryptobox.cpp +++ b/src/lib/misc/cryptobox/cryptobox.cpp @@ -154,7 +154,7 @@ decrypt_bin(const uint8_t input[], size_t input_len, secure_vector<uint8_t> decrypt_bin(const std::string& input, const std::string& passphrase) { - return decrypt_bin(reinterpret_cast<const uint8_t*>(input.data()), + return decrypt_bin(cast_char_ptr_to_uint8(input.data()), input.size(), passphrase); } @@ -164,14 +164,14 @@ std::string decrypt(const uint8_t input[], size_t input_len, { const secure_vector<uint8_t> bin = decrypt_bin(input, input_len, passphrase); - return std::string(reinterpret_cast<const char*>(&bin[0]), + return std::string(cast_uint8_ptr_to_char(&bin[0]), bin.size()); } std::string decrypt(const std::string& input, const std::string& passphrase) { - return decrypt(reinterpret_cast<const uint8_t*>(input.data()), + return decrypt(cast_char_ptr_to_uint8(input.data()), input.size(), passphrase); } |