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

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

Issue 1882433002: Removing NSS files and USE_OPENSSL flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing use_openssl (requires WebRTC change to compile) Created 4 years, 8 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
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 "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)
10 #include <openssl/des.h> 9 #include <openssl/des.h>
11 #include "crypto/openssl_util.h" 10 #include "crypto/openssl_util.h"
12 #elif defined(OS_IOS)
13 #include <CommonCrypto/CommonCryptor.h>
14 #else
15 #error "Unknown platform"
16 #endif
17 11
18 // The iOS version of DESEncrypt is our own code. 12 // The iOS version of DESEncrypt is our own code.
19 // DESSetKeyParity and DESMakeKey are based on 13 // DESSetKeyParity and DESMakeKey are based on
20 // mozilla/security/manager/ssl/src/nsNTLMAuthModule.cpp, CVS rev. 1.14. 14 // mozilla/security/manager/ssl/src/nsNTLMAuthModule.cpp, CVS rev. 1.14.
21 15
22 /* ***** BEGIN LICENSE BLOCK ***** 16 /* ***** BEGIN LICENSE BLOCK *****
23 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 17 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
24 * 18 *
25 * The contents of this file are subject to the Mozilla Public License Version 19 * The contents of this file are subject to the Mozilla Public License Version
26 * 1.1 (the "License"); you may not use this file except in compliance with 20 * 1.1 (the "License"); you may not use this file except in compliance with
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 key[0] = DESSetKeyParity(raw[0]); 67 key[0] = DESSetKeyParity(raw[0]);
74 key[1] = DESSetKeyParity((raw[0] << 7) | (raw[1] >> 1)); 68 key[1] = DESSetKeyParity((raw[0] << 7) | (raw[1] >> 1));
75 key[2] = DESSetKeyParity((raw[1] << 6) | (raw[2] >> 2)); 69 key[2] = DESSetKeyParity((raw[1] << 6) | (raw[2] >> 2));
76 key[3] = DESSetKeyParity((raw[2] << 5) | (raw[3] >> 3)); 70 key[3] = DESSetKeyParity((raw[2] << 5) | (raw[3] >> 3));
77 key[4] = DESSetKeyParity((raw[3] << 4) | (raw[4] >> 4)); 71 key[4] = DESSetKeyParity((raw[3] << 4) | (raw[4] >> 4));
78 key[5] = DESSetKeyParity((raw[4] << 3) | (raw[5] >> 5)); 72 key[5] = DESSetKeyParity((raw[4] << 3) | (raw[5] >> 5));
79 key[6] = DESSetKeyParity((raw[5] << 2) | (raw[6] >> 6)); 73 key[6] = DESSetKeyParity((raw[5] << 2) | (raw[6] >> 6));
80 key[7] = DESSetKeyParity((raw[6] << 1)); 74 key[7] = DESSetKeyParity((raw[6] << 1));
81 } 75 }
82 76
83 #if defined(USE_OPENSSL)
84
85 void DESEncrypt(const uint8_t* key, const uint8_t* src, uint8_t* hash) { 77 void DESEncrypt(const uint8_t* key, const uint8_t* src, uint8_t* hash) {
86 crypto::EnsureOpenSSLInit(); 78 crypto::EnsureOpenSSLInit();
87 79
88 DES_key_schedule ks; 80 DES_key_schedule ks;
89 DES_set_key( 81 DES_set_key(
90 reinterpret_cast<const DES_cblock*>(key), &ks); 82 reinterpret_cast<const DES_cblock*>(key), &ks);
91 83
92 DES_ecb_encrypt(reinterpret_cast<const DES_cblock*>(src), 84 DES_ecb_encrypt(reinterpret_cast<const DES_cblock*>(src),
93 reinterpret_cast<DES_cblock*>(hash), &ks, DES_ENCRYPT); 85 reinterpret_cast<DES_cblock*>(hash), &ks, DES_ENCRYPT);
94 } 86 }
95 87
96 #elif defined(OS_IOS)
Ryan Sleevi 2016/04/18 14:23:30 I'm torn on this. Semantically, your change is co
svaldez 2016/04/18 15:09:35 Acknowledged.
97
98 void DESEncrypt(const uint8_t* key, const uint8_t* src, uint8_t* hash) {
99 CCCryptorStatus status;
100 size_t data_out_moved = 0;
101 status = CCCrypt(kCCEncrypt, kCCAlgorithmDES, kCCOptionECBMode,
102 key, 8, NULL, src, 8, hash, 8, &data_out_moved);
103 DCHECK(status == kCCSuccess);
104 DCHECK(data_out_moved == 8);
105 }
106
107 #endif
108
109 } // namespace net 88 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698