Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: crypto/encryptor.cc

Issue 8336024: OpenBSD patches for net, split from CR #8275005 (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: add missing crypto patch Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | net/base/dnsrr_resolver.cc » ('j') | net/base/dnsrr_resolver.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "crypto/encryptor.h" 5 #include "crypto/encryptor.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 9
10 // Include headers to provide bswap for all platforms. 10 // Include headers to provide bswap for all platforms.
11 #if defined(COMPILER_MSVC) 11 #if defined(COMPILER_MSVC)
12 #include <stdlib.h> 12 #include <stdlib.h>
13 #define bswap_16(x) _byteswap_ushort(x) 13 #define bswap_16(x) _byteswap_ushort(x)
14 #define bswap_32(x) _byteswap_ulong(x) 14 #define bswap_32(x) _byteswap_ulong(x)
15 #define bswap_64(x) _byteswap_uint64(x) 15 #define bswap_64(x) _byteswap_uint64(x)
16 #elif defined(OS_MACOSX) 16 #elif defined(OS_MACOSX)
17 #include <libkern/OSByteOrder.h> 17 #include <libkern/OSByteOrder.h>
18 #define bswap_16(x) OSSwapInt16(x) 18 #define bswap_16(x) OSSwapInt16(x)
19 #define bswap_32(x) OSSwapInt32(x) 19 #define bswap_32(x) OSSwapInt32(x)
20 #define bswap_64(x) OSSwapInt64(x) 20 #define bswap_64(x) OSSwapInt64(x)
21 #elif defined(OS_OPENBSD)
22 #define bswap_16(x) swap16(x)
23 #define bswap_32(x) swap32(x)
24 #define bswap_64(x) swap64(x)
wtc 2011/10/18 21:50:26 Just curious: are swap16, swap32, and swap64 compi
Robert Nagy 2011/10/19 07:10:02 They are defined in sys/endian.h so I just include
21 #else 25 #else
22 #include <byteswap.h> 26 #include <byteswap.h>
23 #endif 27 #endif
24 28
25 #if defined(ARCH_CPU_LITTLE_ENDIAN) 29 #if defined(ARCH_CPU_LITTLE_ENDIAN)
26 #define ntoh_64(x) bswap_64(x) 30 #define ntoh_64(x) bswap_64(x)
27 #define hton_64(x) bswap_64(x) 31 #define hton_64(x) bswap_64(x)
28 #else 32 #else
29 #define ntoh_64(x) (x) 33 #define ntoh_64(x) (x)
30 #define hton_64(x) (x) 34 #define hton_64(x) (x)
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 DCHECK_EQ(CTR, mode_); 115 DCHECK_EQ(CTR, mode_);
112 const uint8* plaintext_ptr = reinterpret_cast<const uint8*>(plaintext); 116 const uint8* plaintext_ptr = reinterpret_cast<const uint8*>(plaintext);
113 const uint8* mask_ptr = reinterpret_cast<const uint8*>(mask); 117 const uint8* mask_ptr = reinterpret_cast<const uint8*>(mask);
114 uint8* ciphertext_ptr = reinterpret_cast<uint8*>(ciphertext); 118 uint8* ciphertext_ptr = reinterpret_cast<uint8*>(ciphertext);
115 119
116 for (size_t i = 0; i < plaintext_len; ++i) 120 for (size_t i = 0; i < plaintext_len; ++i)
117 ciphertext_ptr[i] = plaintext_ptr[i] ^ mask_ptr[i]; 121 ciphertext_ptr[i] = plaintext_ptr[i] ^ mask_ptr[i];
118 } 122 }
119 123
120 } // namespace crypto 124 } // namespace crypto
OLDNEW
« no previous file with comments | « no previous file | net/base/dnsrr_resolver.cc » ('j') | net/base/dnsrr_resolver.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698