Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef WebCryptoUtil_h | |
| 6 #define WebCryptoUtil_h | |
| 7 | |
| 8 #include "WebCommon.h" | |
| 9 #include "WebVector.h" | |
| 10 | |
| 11 namespace blink { | |
| 12 | |
| 13 // Converts the (big-endian) BigInteger to unsigned int. Returns true on success (if its value is not too large). | |
| 14 static bool bigIntegerToUint(const WebVector<unsigned char>& bigInteger, unsigne d& result) | |
|
tommi (sloooow) - chröme
2015/10/26 17:18:03
static method in a header file - won't this cause
eroman
2015/10/26 18:02:10
Regardless whether this compiles or not, it is und
hbos_chromium
2015/10/27 08:50:20
I thought I could not use .cc files because everyt
| |
| 15 { | |
| 16 result = 0; | |
| 17 for (size_t i = 0; i < bigInteger.size(); ++i) { | |
| 18 size_t iReversed = bigInteger.size() - i - 1; | |
| 19 | |
| 20 if (iReversed >= sizeof(result) && bigInteger[i]) | |
| 21 return false; // Too large for unsigned int. | |
| 22 | |
| 23 result |= bigInteger[i] << 8 * iReversed; | |
| 24 } | |
| 25 return true; | |
| 26 } | |
| 27 | |
| 28 } // namespace blink | |
| 29 | |
| 30 #endif // WebCryptoUtil_h | |
| OLD | NEW |