OLD | NEW |
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 "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_OPENSSL) | 9 #if defined(USE_OPENSSL) |
10 #include <openssl/des.h> | 10 #include <openssl/des.h> |
11 #include "crypto/openssl_util.h" | 11 #include "crypto/openssl_util.h" |
12 #elif defined(USE_NSS) | 12 #elif defined(USE_NSS_CERTS) |
13 #include <nss.h> | 13 #include <nss.h> |
14 #include <pk11pub.h> | 14 #include <pk11pub.h> |
15 #include "crypto/nss_util.h" | 15 #include "crypto/nss_util.h" |
16 #elif defined(OS_MACOSX) | 16 #elif defined(OS_MACOSX) |
17 #include <CommonCrypto/CommonCryptor.h> | 17 #include <CommonCrypto/CommonCryptor.h> |
18 #elif defined(OS_WIN) | 18 #elif defined(OS_WIN) |
19 #include <windows.h> | 19 #include <windows.h> |
20 #include <wincrypt.h> | 20 #include <wincrypt.h> |
21 #include "crypto/scoped_capi_types.h" | 21 #include "crypto/scoped_capi_types.h" |
22 #endif | 22 #endif |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 crypto::EnsureOpenSSLInit(); | 93 crypto::EnsureOpenSSLInit(); |
94 | 94 |
95 DES_key_schedule ks; | 95 DES_key_schedule ks; |
96 DES_set_key( | 96 DES_set_key( |
97 reinterpret_cast<const DES_cblock*>(key), &ks); | 97 reinterpret_cast<const DES_cblock*>(key), &ks); |
98 | 98 |
99 DES_ecb_encrypt(reinterpret_cast<const DES_cblock*>(src), | 99 DES_ecb_encrypt(reinterpret_cast<const DES_cblock*>(src), |
100 reinterpret_cast<DES_cblock*>(hash), &ks, DES_ENCRYPT); | 100 reinterpret_cast<DES_cblock*>(hash), &ks, DES_ENCRYPT); |
101 } | 101 } |
102 | 102 |
103 #elif defined(USE_NSS) | 103 #elif defined(USE_NSS_CERTS) |
104 | 104 |
105 void DESEncrypt(const uint8* key, const uint8* src, uint8* hash) { | 105 void DESEncrypt(const uint8* key, const uint8* src, uint8* hash) { |
106 CK_MECHANISM_TYPE cipher_mech = CKM_DES_ECB; | 106 CK_MECHANISM_TYPE cipher_mech = CKM_DES_ECB; |
107 PK11SlotInfo* slot = NULL; | 107 PK11SlotInfo* slot = NULL; |
108 PK11SymKey* symkey = NULL; | 108 PK11SymKey* symkey = NULL; |
109 PK11Context* ctxt = NULL; | 109 PK11Context* ctxt = NULL; |
110 SECItem key_item; | 110 SECItem key_item; |
111 SECItem* param = NULL; | 111 SECItem* param = NULL; |
112 SECStatus rv; | 112 SECStatus rv; |
113 unsigned int n; | 113 unsigned int n; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 // Pass a 'Final' of FALSE, otherwise CryptEncrypt appends one additional | 211 // Pass a 'Final' of FALSE, otherwise CryptEncrypt appends one additional |
212 // block of padding to the data. | 212 // block of padding to the data. |
213 DWORD hash_len = 8; | 213 DWORD hash_len = 8; |
214 CryptEncrypt(key, 0, FALSE, 0, hash, &hash_len, 8); | 214 CryptEncrypt(key, 0, FALSE, 0, hash, &hash_len, 8); |
215 } | 215 } |
216 } | 216 } |
217 | 217 |
218 #endif | 218 #endif |
219 | 219 |
220 } // namespace net | 220 } // namespace net |
OLD | NEW |