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

Side by Side Diff: net/http/des.cc

Issue 5195001: Fixes the remaining net_unittests for OpenSSL, with the exceptions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable browser unittests Created 10 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "net/http/des.h" 5 #include "net/http/des.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 #if defined(USE_NSS) 9 #if defined(USE_OPENSSL)
10 #include <openssl/des.h>
11 #include "base/openssl_util.h"
12 #elif defined(USE_NSS)
10 #include <nss.h> 13 #include <nss.h>
11 #include <pk11pub.h> 14 #include <pk11pub.h>
12 #include "base/nss_util.h" 15 #include "base/nss_util.h"
13 #elif defined(OS_MACOSX) 16 #elif defined(OS_MACOSX)
14 #include <CommonCrypto/CommonCryptor.h> 17 #include <CommonCrypto/CommonCryptor.h>
15 #elif defined(OS_WIN) 18 #elif defined(OS_WIN)
16 #include <windows.h> 19 #include <windows.h>
17 #include <wincrypt.h> 20 #include <wincrypt.h>
18 #include "base/crypto/scoped_capi_types.h" 21 #include "base/crypto/scoped_capi_types.h"
19 #endif 22 #endif
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 key[3] = DESSetKeyParity((raw[2] << 5) | (raw[3] >> 3)); 83 key[3] = DESSetKeyParity((raw[2] << 5) | (raw[3] >> 3));
81 key[4] = DESSetKeyParity((raw[3] << 4) | (raw[4] >> 4)); 84 key[4] = DESSetKeyParity((raw[3] << 4) | (raw[4] >> 4));
82 key[5] = DESSetKeyParity((raw[4] << 3) | (raw[5] >> 5)); 85 key[5] = DESSetKeyParity((raw[4] << 3) | (raw[5] >> 5));
83 key[6] = DESSetKeyParity((raw[5] << 2) | (raw[6] >> 6)); 86 key[6] = DESSetKeyParity((raw[5] << 2) | (raw[6] >> 6));
84 key[7] = DESSetKeyParity((raw[6] << 1)); 87 key[7] = DESSetKeyParity((raw[6] << 1));
85 } 88 }
86 89
87 #if defined(USE_OPENSSL) 90 #if defined(USE_OPENSSL)
88 91
89 void DESEncrypt(const uint8* key, const uint8* src, uint8* hash) { 92 void DESEncrypt(const uint8* key, const uint8* src, uint8* hash) {
90 // TODO(joth): When implementing consider splitting up this file by platform. 93 base::EnsureOpenSSLInit();
91 NOTIMPLEMENTED(); 94
95 DES_key_schedule ks;
96 DES_set_key_unchecked(
97 reinterpret_cast<const_DES_cblock*>(const_cast<uint8*>(key)), &ks);
98
99 DES_ecb_encrypt(reinterpret_cast<const_DES_cblock*>(const_cast<uint8*>(src)),
100 reinterpret_cast<DES_cblock*>(hash), &ks, 1); // 1 = encrypt.
bulach 2010/12/01 18:01:33 des.h has a DES_ENCRYPT
joth 2010/12/02 17:12:01 Done.
92 } 101 }
93 102
94 #elif defined(USE_NSS) 103 #elif defined(USE_NSS)
95 104
96 void DESEncrypt(const uint8* key, const uint8* src, uint8* hash) { 105 void DESEncrypt(const uint8* key, const uint8* src, uint8* hash) {
97 CK_MECHANISM_TYPE cipher_mech = CKM_DES_ECB; 106 CK_MECHANISM_TYPE cipher_mech = CKM_DES_ECB;
98 PK11SlotInfo* slot = NULL; 107 PK11SlotInfo* slot = NULL;
99 PK11SymKey* symkey = NULL; 108 PK11SymKey* symkey = NULL;
100 PK11Context* ctxt = NULL; 109 PK11Context* ctxt = NULL;
101 SECItem key_item; 110 SECItem key_item;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 // Pass a 'Final' of FALSE, otherwise CryptEncrypt appends one additional 211 // Pass a 'Final' of FALSE, otherwise CryptEncrypt appends one additional
203 // block of padding to the data. 212 // block of padding to the data.
204 DWORD hash_len = 8; 213 DWORD hash_len = 8;
205 CryptEncrypt(key, 0, FALSE, 0, hash, &hash_len, 8); 214 CryptEncrypt(key, 0, FALSE, 0, hash, &hash_len, 8);
206 } 215 }
207 } 216 }
208 217
209 #endif 218 #endif
210 219
211 } // namespace net 220 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698