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

Side by Side Diff: trunk/src/chrome/browser/devtools/adb/android_rsa.cc

Issue 227743006: Revert 262147 "Remove all uses of GG_LONGLONG and GG_ULONGLONG." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "chrome/browser/devtools/adb/android_rsa.h" 5 #include "chrome/browser/devtools/adb/android_rsa.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/browser/prefs/pref_service_syncable.h" 9 #include "chrome/browser/prefs/pref_service_syncable.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 return result; 93 return result;
94 } 94 }
95 95
96 void BnSub(uint32* a, uint32* b) { 96 void BnSub(uint32* a, uint32* b) {
97 int carry_over = 0; 97 int carry_over = 0;
98 for (size_t i = 0; i < kBigIntSize; ++i) { 98 for (size_t i = 0; i < kBigIntSize; ++i) {
99 int64 sub = static_cast<int64>(a[i]) - b[i] - carry_over; 99 int64 sub = static_cast<int64>(a[i]) - b[i] - carry_over;
100 carry_over = 0; 100 carry_over = 0;
101 if (sub < 0) { 101 if (sub < 0) {
102 carry_over = 1; 102 carry_over = 1;
103 sub += 0x100000000LL; 103 sub += GG_LONGLONG(0x100000000);
104 } 104 }
105 a[i] = static_cast<uint32>(sub); 105 a[i] = static_cast<uint32>(sub);
106 } 106 }
107 } 107 }
108 108
109 void BnLeftShift(uint32* a, int offset) { 109 void BnLeftShift(uint32* a, int offset) {
110 for (int i = kBigIntSize - offset - 1; i >= 0; --i) 110 for (int i = kBigIntSize - offset - 1; i >= 0; --i)
111 a[i + offset] = a[i]; 111 a[i + offset] = a[i];
112 for (int i = 0; i < offset; ++i) 112 for (int i = 0; i < offset; ++i)
113 a[i] = 0; 113 a[i] = 0;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 t += pk_data[4 * i + 2]; 226 t += pk_data[4 * i + 2];
227 t = t << 8; 227 t = t << 8;
228 t += pk_data[4 * i + 3]; 228 t += pk_data[4 * i + 3];
229 n[kRSANumWords - i - 1] = t; 229 n[kRSANumWords - i - 1] = t;
230 } 230 }
231 uint64 n0 = n[0]; 231 uint64 n0 = n[0];
232 232
233 RSAPublicKey pkey; 233 RSAPublicKey pkey;
234 pkey.len = kRSANumWords; 234 pkey.len = kRSANumWords;
235 pkey.exponent = 65537; // Fixed public exponent 235 pkey.exponent = 65537; // Fixed public exponent
236 pkey.n0inv = 0 - ModInverse(n0, 0x100000000LL); 236 pkey.n0inv = 0 - ModInverse(n0, GG_LONGLONG(0x100000000));
237 if (pkey.n0inv == 0) 237 if (pkey.n0inv == 0)
238 return kDummyRSAPublicKey; 238 return kDummyRSAPublicKey;
239 239
240 uint32* r = BnNew(); 240 uint32* r = BnNew();
241 r[kRSANumWords * 2] = 1; 241 r[kRSANumWords * 2] = 1;
242 242
243 uint32* rr; 243 uint32* rr;
244 BnDiv(r, n, NULL, &rr); 244 BnDiv(r, n, NULL, &rr);
245 245
246 for (size_t i = 0; i < kRSANumWords; ++i) { 246 for (size_t i = 0; i < kRSANumWords; ++i) {
(...skipping 14 matching lines...) Expand all
261 std::string AndroidRSASign(crypto::RSAPrivateKey* key, 261 std::string AndroidRSASign(crypto::RSAPrivateKey* key,
262 const std::string& body) { 262 const std::string& body) {
263 std::vector<uint8> digest(body.begin(), body.end()); 263 std::vector<uint8> digest(body.begin(), body.end());
264 std::vector<uint8> result; 264 std::vector<uint8> result;
265 if (!crypto::SignatureCreator::Sign(key, vector_as_array(&digest), 265 if (!crypto::SignatureCreator::Sign(key, vector_as_array(&digest),
266 digest.size(), &result)) { 266 digest.size(), &result)) {
267 return std::string(); 267 return std::string();
268 } 268 }
269 return std::string(result.begin(), result.end()); 269 return std::string(result.begin(), result.end());
270 } 270 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698