diff options
author | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-28 20:19:31 +0000 |
---|---|---|
committer | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-28 20:19:31 +0000 |
commit | 9eb7b11b614e987d7608678d0396873f37ca817e (patch) | |
tree | 7f222f4ae73bd3c3edc33d39f3bf7050d10f4254 /crypto/symmetric_key_win.cc | |
parent | 97f37d558f60a245190b17ce14d3d9039fc83767 (diff) | |
download | chromium_src-9eb7b11b614e987d7608678d0396873f37ca817e.zip chromium_src-9eb7b11b614e987d7608678d0396873f37ca817e.tar.gz chromium_src-9eb7b11b614e987d7608678d0396873f37ca817e.tar.bz2 |
Add base::HostToNetXX() & NetToHostXX(), and use them to replace htonX() & ntohX() in Chrome.
This primarily addresses issues with code using the OS-provided htonX() & ntohX() functions from within the Chrome sandbox. Under Windows these functions are provided by ws2_32.dll, which is no longer available within Chrome's sandbox.
The new base::HostToNetXX() and NetToHostXX() functions are safe for use by sandboxed code on Windows, and provide a single place where future fixes for other platforms can be made.
BUG=117252
Review URL: http://codereview.chromium.org/9716020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129476 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'crypto/symmetric_key_win.cc')
-rw-r--r-- | crypto/symmetric_key_win.cc | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/crypto/symmetric_key_win.cc b/crypto/symmetric_key_win.cc index 87e0bc3..f4cd751 100644 --- a/crypto/symmetric_key_win.cc +++ b/crypto/symmetric_key_win.cc @@ -4,12 +4,11 @@ #include "crypto/symmetric_key.h" -#include <winsock2.h> // For htonl. - #include <vector> // TODO(wtc): replace scoped_array by std::vector. #include "base/memory/scoped_ptr.h" +#include "base/sys_byteorder.h" namespace crypto { @@ -264,7 +263,7 @@ bool ComputePBKDF2Block(HCRYPTHASH hash, return false; // Iteration U_1: and append (big-endian) INT (i). - uint32 big_endian_block_index = htonl(block_index); + uint32 big_endian_block_index = base::HostToNet32(block_index); ok = CryptHashData(safe_hash, reinterpret_cast<BYTE*>(&big_endian_block_index), sizeof(big_endian_block_index), 0); |