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

Unified Diff: chrome/renderer/resources/extensions/enterprise_platform_keys/subtle_crypto.js

Issue 306433003: enterprise.platformKeys: Support the publicExponent parameter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 years, 6 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
Index: chrome/renderer/resources/extensions/enterprise_platform_keys/subtle_crypto.js
diff --git a/chrome/renderer/resources/extensions/enterprise_platform_keys/subtle_crypto.js b/chrome/renderer/resources/extensions/enterprise_platform_keys/subtle_crypto.js
index efeb582a6fbf706760acc761a979cd354a5c61cb..1031135b4bce99b2561578611294fc72920ee363 100644
--- a/chrome/renderer/resources/extensions/enterprise_platform_keys/subtle_crypto.js
+++ b/chrome/renderer/resources/extensions/enterprise_platform_keys/subtle_crypto.js
@@ -51,6 +51,24 @@ function catchInvalidTokenError(reject) {
return false;
}
+// Returns true if |array| is a BigInteger describing the standard public
+// exponent 65537.
eroman 2014/06/09 22:49:01 The description could be clearer, indicating that
pneubeck (no reviews) 2014/06/16 17:54:51 Done.
+function equalsStandardPublicExponent(array) {
+ var expected = [0x01, 0x00, 0x01];
+ if (array.length < expected.length)
+ return false;
+ for (var i = 0; i < array.length; i++) {
+ var expectedDigit = 0;
+ if (i < expected.length) {
+ // |expected| is symmetric, endianness doesn't matter.
+ expectedDigit = expected[i];
+ }
+ if (array[array.length - 1 - i] !== expectedDigit)
+ return false;
+ }
+ return true;
+}
+
/**
* Implementation of WebCrypto.SubtleCrypto used in enterprise.platformKeys.
* @param {string} tokenId The id of the backing Token.
@@ -83,7 +101,9 @@ SubtleCryptoImpl.prototype.generateKey =
throw CreateSyntaxError();
}
- if (normalizedAlgorithmParameters.name !== 'RSASSA-PKCS1-v1_5') {
+ if (normalizedAlgorithmParameters.name !== 'RSASSA-PKCS1-v1_5' ||
+ !equalsStandardPublicExponent(
+ normalizedAlgorithmParameters.publicExponent)) {
// Note: This deviates from WebCrypto.SubtleCrypto.
throw CreateNotSupportedError();
}

Powered by Google App Engine
This is Rietveld 408576698