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

Unified Diff: Source/bindings/v8/SerializedScriptValue.cpp

Issue 284973002: [webcrypto] Remove RSA-ES support (3 of 3) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Placate compiler warning on android about uninitialized variable Created 6 years, 7 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 | Source/modules/crypto/KeyAlgorithm.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/SerializedScriptValue.cpp
diff --git a/Source/bindings/v8/SerializedScriptValue.cpp b/Source/bindings/v8/SerializedScriptValue.cpp
index b8e90f69015c0d2bdc38481e399558c547fbc8e9..b6f7dd24893d448c03aed47b5b66f6be81daee15 100644
--- a/Source/bindings/v8/SerializedScriptValue.cpp
+++ b/Source/bindings/v8/SerializedScriptValue.cpp
@@ -221,10 +221,8 @@ enum SerializationTag {
// props = keyLengthBytes:uint32_t, algorithmId:uint32_t
// If subtag=HmacKeyTag:
// props = keyLengthBytes:uint32_t, hashId:uint32_t
- // If subtag=RsaKeyTag:
- // props = algorithmId:uint32_t, type:uint32_t, modulusLengthBits:uint32_t, publicExponentLength:uint32_t, publicExponent:byte[publicExponentLength]
// If subtag=RsaHashedKeyTag:
- // props = <same as for RsaKeyTag>, hashId:uint32_t
+ // props = algorithmId:uint32_t, type:uint32_t, modulusLengthBits:uint32_t, publicExponentLength:uint32_t, publicExponent:byte[publicExponentLength], hashId:uint32_t
ObjectReferenceTag = '^', // ref:uint32_t -> reference table[ref]
GenerateFreshObjectTag = 'o', // -> empty object allocated an object ID and pushed onto the open stack (ref)
GenerateFreshSparseArrayTag = 'a', // length:uint32_t -> empty array[length] allocated an object ID and pushed onto the open stack (ref)
@@ -253,7 +251,7 @@ enum ArrayBufferViewSubTag {
enum CryptoKeySubTag {
AesKeyTag = 1,
HmacKeyTag = 2,
- RsaKeyTag = 3,
+ // ID 3 was used by RsaKeyTag, while still behind experimental flag.
RsaHashedKeyTag = 4,
// Maximum allowed value is 255
};
@@ -268,7 +266,7 @@ enum CryptoKeyAlgorithmTag {
AesCbcTag = 1,
HmacTag = 2,
RsaSsaPkcs1v1_5Tag = 3,
- RsaEsPkcs1v1_5Tag = 4,
+ // ID 4 was used by RsaEs, while still behind experimental flag.
Sha1Tag = 5,
Sha256Tag = 6,
Sha384Tag = 7,
@@ -517,9 +515,8 @@ public:
case blink::WebCryptoKeyAlgorithmParamsTypeHmac:
doWriteHmacKey(key);
break;
- case blink::WebCryptoKeyAlgorithmParamsTypeRsa:
case blink::WebCryptoKeyAlgorithmParamsTypeRsaHashed:
- doWriteRsaKey(key);
+ doWriteRsaHashedKey(key);
break;
case blink::WebCryptoKeyAlgorithmParamsTypeNone:
ASSERT_NOT_REACHED();
@@ -730,12 +727,10 @@ private:
doWriteUint32(key.algorithm().aesParams()->lengthBits() / 8);
}
- void doWriteRsaKey(const blink::WebCryptoKey& key)
+ void doWriteRsaHashedKey(const blink::WebCryptoKey& key)
{
- if (key.algorithm().rsaHashedParams())
- append(static_cast<uint8_t>(RsaHashedKeyTag));
- else
- append(static_cast<uint8_t>(RsaKeyTag));
+ ASSERT(key.algorithm().rsaHashedParams());
+ append(static_cast<uint8_t>(RsaHashedKeyTag));
doWriteAlgorithmId(key.algorithm().id());
@@ -750,13 +745,11 @@ private:
ASSERT_NOT_REACHED();
}
- const blink::WebCryptoRsaKeyAlgorithmParams* params = key.algorithm().rsaParams();
+ const blink::WebCryptoRsaHashedKeyAlgorithmParams* params = key.algorithm().rsaHashedParams();
doWriteUint32(params->modulusLengthBits());
doWriteUint32(params->publicExponent().size());
append(params->publicExponent().data(), params->publicExponent().size());
-
- if (key.algorithm().rsaHashedParams())
- doWriteAlgorithmId(key.algorithm().rsaHashedParams()->hash().id());
+ doWriteAlgorithmId(key.algorithm().rsaHashedParams()->hash().id());
}
void doWriteAlgorithmId(blink::WebCryptoAlgorithmId id)
@@ -768,8 +761,6 @@ private:
return doWriteUint32(HmacTag);
case blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5:
return doWriteUint32(RsaSsaPkcs1v1_5Tag);
- case blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5:
- return doWriteUint32(RsaEsPkcs1v1_5Tag);
case blink::WebCryptoAlgorithmIdSha1:
return doWriteUint32(Sha1Tag);
case blink::WebCryptoAlgorithmIdSha256:
@@ -2243,7 +2234,7 @@ private:
return false;
blink::WebCryptoKeyAlgorithm algorithm;
- blink::WebCryptoKeyType type;
+ blink::WebCryptoKeyType type = blink::WebCryptoKeyTypeSecret;
switch (static_cast<CryptoKeySubTag>(rawKeyType)) {
case AesKeyTag:
@@ -2254,12 +2245,8 @@ private:
if (!doReadHmacKey(algorithm, type))
return false;
break;
- case RsaKeyTag:
- if (!doReadRsaKey(false, algorithm, type))
- return false;
- break;
case RsaHashedKeyTag:
- if (!doReadRsaKey(true, algorithm, type))
+ if (!doReadRsaHashedKey(algorithm, type))
return false;
break;
default:
@@ -2419,7 +2406,7 @@ private:
return !algorithm.isNull();
}
- bool doReadRsaKey(bool hasHash, blink::WebCryptoKeyAlgorithm& algorithm, blink::WebCryptoKeyType& type)
+ bool doReadRsaHashedKey(blink::WebCryptoKeyAlgorithm& algorithm, blink::WebCryptoKeyType& type)
{
blink::WebCryptoAlgorithmId id;
if (!doReadAlgorithmId(id))
@@ -2454,14 +2441,10 @@ private:
const uint8_t* publicExponent = m_buffer + m_position;
m_position += publicExponentSize;
- if (hasHash) {
- blink::WebCryptoAlgorithmId hash;
- if (!doReadAlgorithmId(hash))
- return false;
- algorithm = blink::WebCryptoKeyAlgorithm::createRsaHashed(id, modulusLengthBits, publicExponent, publicExponentSize, hash);
- } else {
- algorithm = blink::WebCryptoKeyAlgorithm::createRsa(id, modulusLengthBits, publicExponent, publicExponentSize);
- }
+ blink::WebCryptoAlgorithmId hash;
+ if (!doReadAlgorithmId(hash))
+ return false;
+ algorithm = blink::WebCryptoKeyAlgorithm::createRsaHashed(id, modulusLengthBits, publicExponent, publicExponentSize, hash);
return !algorithm.isNull();
}
@@ -2482,9 +2465,6 @@ private:
case RsaSsaPkcs1v1_5Tag:
id = blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5;
return true;
- case RsaEsPkcs1v1_5Tag:
- id = blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5;
- return true;
case Sha1Tag:
id = blink::WebCryptoAlgorithmIdSha1;
return true;
« no previous file with comments | « no previous file | Source/modules/crypto/KeyAlgorithm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698