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/kdf | |
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/kdf')
-rw-r--r-- | src/lib/kdf/hkdf/hkdf.cpp | 2 | ||||
-rw-r--r-- | src/lib/kdf/kdf.h | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/lib/kdf/hkdf/hkdf.cpp b/src/lib/kdf/hkdf/hkdf.cpp index 63085d191..6ccd786c3 100644 --- a/src/lib/kdf/hkdf/hkdf.cpp +++ b/src/lib/kdf/hkdf/hkdf.cpp @@ -103,7 +103,7 @@ hkdf_expand_label(const std::string& hash_fn, prefix[2] = static_cast<uint8_t>(label.size()); copy_mem(prefix.data() + 3, - reinterpret_cast<const uint8_t*>(label.data()), + cast_char_ptr_to_uint8(label.data()), label.size()); prefix[3 + label.size()] = static_cast<uint8_t>(hash_val_len); diff --git a/src/lib/kdf/kdf.h b/src/lib/kdf/kdf.h index b99a3a83c..dd4cfedf6 100644 --- a/src/lib/kdf/kdf.h +++ b/src/lib/kdf/kdf.h @@ -107,9 +107,9 @@ class BOTAN_PUBLIC_API(2,0) KDF const std::string& label = "") const { return derive_key(key_len, secret.data(), secret.size(), - reinterpret_cast<const uint8_t*>(salt.data()), + cast_char_ptr_to_uint8(salt.data()), salt.length(), - reinterpret_cast<const uint8_t*>(label.data()), + cast_char_ptr_to_uint8(label.data()), label.length()); } @@ -152,7 +152,7 @@ class BOTAN_PUBLIC_API(2,0) KDF return derive_key(key_len, secret.data(), secret.size(), salt, salt_len, - reinterpret_cast<const uint8_t*>(label.data()), + cast_char_ptr_to_uint8(label.data()), label.size()); } @@ -172,9 +172,9 @@ class BOTAN_PUBLIC_API(2,0) KDF const std::string& label = "") const { return derive_key(key_len, secret, secret_len, - reinterpret_cast<const uint8_t*>(salt.data()), + cast_char_ptr_to_uint8(salt.data()), salt.length(), - reinterpret_cast<const uint8_t*>(label.data()), + cast_char_ptr_to_uint8(label.data()), label.length()); } |