Chromium Code Reviews| Index: third_party/WebKit/public/platform/WebCryptoUtil.h |
| diff --git a/third_party/WebKit/public/platform/WebCryptoUtil.h b/third_party/WebKit/public/platform/WebCryptoUtil.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..67bc5de9b2af60ab4534c1cdac2016f45d56a3a2 |
| --- /dev/null |
| +++ b/third_party/WebKit/public/platform/WebCryptoUtil.h |
| @@ -0,0 +1,30 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef WebCryptoUtil_h |
| +#define WebCryptoUtil_h |
| + |
| +#include "WebCommon.h" |
| +#include "WebVector.h" |
| + |
| +namespace blink { |
| + |
| +// Converts the (big-endian) BigInteger to unsigned int. Returns true on success (if its value is not too large). |
| +static bool bigIntegerToUint(const WebVector<unsigned char>& bigInteger, unsigned& 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
|
| +{ |
| + result = 0; |
| + for (size_t i = 0; i < bigInteger.size(); ++i) { |
| + size_t iReversed = bigInteger.size() - i - 1; |
| + |
| + if (iReversed >= sizeof(result) && bigInteger[i]) |
| + return false; // Too large for unsigned int. |
| + |
| + result |= bigInteger[i] << 8 * iReversed; |
| + } |
| + return true; |
| +} |
| + |
| +} // namespace blink |
| + |
| +#endif // WebCryptoUtil_h |