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/pbkdf | |
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/pbkdf')
-rw-r--r-- | src/lib/pbkdf/pbkdf2/pbkdf2.cpp | 2 | ||||
-rw-r--r-- | src/lib/pbkdf/pgp_s2k/pgp_s2k.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/pbkdf/pbkdf2/pbkdf2.cpp b/src/lib/pbkdf/pbkdf2/pbkdf2.cpp index 4e1a73331..d4388bd10 100644 --- a/src/lib/pbkdf/pbkdf2/pbkdf2.cpp +++ b/src/lib/pbkdf/pbkdf2/pbkdf2.cpp @@ -26,7 +26,7 @@ pbkdf2(MessageAuthenticationCode& prf, try { - prf.set_key(reinterpret_cast<const uint8_t*>(passphrase.data()), passphrase.size()); + prf.set_key(cast_char_ptr_to_uint8(passphrase.data()), passphrase.size()); } catch(Invalid_Key_Length&) { diff --git a/src/lib/pbkdf/pgp_s2k/pgp_s2k.cpp b/src/lib/pbkdf/pgp_s2k/pgp_s2k.cpp index f298bb3e4..14f21eae2 100644 --- a/src/lib/pbkdf/pgp_s2k/pgp_s2k.cpp +++ b/src/lib/pbkdf/pgp_s2k/pgp_s2k.cpp @@ -91,7 +91,7 @@ size_t OpenPGP_S2K::pbkdf(uint8_t output_buf[], size_t output_len, if(passphrase.empty() == false) { copy_mem(&input_buf[salt_len], - reinterpret_cast<const uint8_t*>(passphrase.data()), + cast_char_ptr_to_uint8(passphrase.data()), passphrase.size()); } |