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

Unified Diff: components/webcrypto/algorithms/rsa.cc

Issue 1418113002: RTCPeerConnection.generateCertificate taking AlgorithmIdentifier and using WebCrypto (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase with master Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/renderer/media/rtc_certificate_generator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/webcrypto/algorithms/rsa.cc
diff --git a/components/webcrypto/algorithms/rsa.cc b/components/webcrypto/algorithms/rsa.cc
index 892a5a0ec134b35f23da0d0a606c67ef22cef40c..e789d2921f8aa8fb1e4e6416dc2d408a55c21412 100644
--- a/components/webcrypto/algorithms/rsa.cc
+++ b/components/webcrypto/algorithms/rsa.cc
@@ -19,6 +19,7 @@
#include "crypto/scoped_openssl_types.h"
#include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h"
#include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h"
+#include "third_party/WebKit/public/platform/WebCryptoUtil.h"
namespace webcrypto {
@@ -104,26 +105,6 @@ Status ReadRsaKeyJwk(const CryptoData& key_data,
return Status::Success();
}
-// Converts a (big-endian) WebCrypto BigInteger, with or without leading zeros,
-// to unsigned int.
-bool BigIntegerToUint(const uint8_t* data,
- size_t data_size,
- unsigned int* result) {
- if (data_size == 0)
- return false;
-
- *result = 0;
- for (size_t i = 0; i < data_size; ++i) {
- size_t reverse_i = data_size - i - 1;
-
- if (reverse_i >= sizeof(*result) && data[i])
- return false; // Too large for a uint.
-
- *result |= data[i] << 8 * reverse_i;
- }
- return true;
-}
-
// Creates a blink::WebCryptoAlgorithm having the modulus length and public
// exponent of |key|.
Status CreateRsaHashedKeyAlgorithm(
@@ -298,10 +279,8 @@ Status RsaHashedAlgorithm::GenerateKey(
}
unsigned int public_exponent = 0;
- if (!BigIntegerToUint(params->publicExponent().data(),
- params->publicExponent().size(), &public_exponent)) {
+ if (!blink::bigIntegerToUint(params->publicExponent(), public_exponent))
return Status::ErrorGenerateKeyPublicExponent();
- }
// OpenSSL hangs when given bad public exponents. Use a whitelist.
if (public_exponent != 3 && public_exponent != 65537)
« no previous file with comments | « no previous file | content/renderer/media/rtc_certificate_generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698