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

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

Issue 296333002: Revert 174726 "[webcrypto] Remove RSA-ES support (3 of 3)" (Closed) Base URL: svn://svn.chromium.org/blink/
Patch Set: 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 | trunk/Source/modules/crypto/KeyAlgorithm.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/Source/bindings/v8/SerializedScriptValue.cpp
===================================================================
--- trunk/Source/bindings/v8/SerializedScriptValue.cpp (revision 174732)
+++ trunk/Source/bindings/v8/SerializedScriptValue.cpp (working copy)
@@ -221,8 +221,10 @@
// 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 = algorithmId:uint32_t, type:uint32_t, modulusLengthBits:uint32_t, publicExponentLength:uint32_t, publicExponent:byte[publicExponentLength], hashId:uint32_t
+ // props = <same as for RsaKeyTag>, 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)
@@ -251,7 +253,7 @@
enum CryptoKeySubTag {
AesKeyTag = 1,
HmacKeyTag = 2,
- // ID 3 was used by RsaKeyTag, while still behind experimental flag.
+ RsaKeyTag = 3,
RsaHashedKeyTag = 4,
// Maximum allowed value is 255
};
@@ -266,7 +268,7 @@
AesCbcTag = 1,
HmacTag = 2,
RsaSsaPkcs1v1_5Tag = 3,
- // ID 4 was used by RsaEs, while still behind experimental flag.
+ RsaEsPkcs1v1_5Tag = 4,
Sha1Tag = 5,
Sha256Tag = 6,
Sha384Tag = 7,
@@ -515,8 +517,9 @@
case blink::WebCryptoKeyAlgorithmParamsTypeHmac:
doWriteHmacKey(key);
break;
+ case blink::WebCryptoKeyAlgorithmParamsTypeRsa:
case blink::WebCryptoKeyAlgorithmParamsTypeRsaHashed:
- doWriteRsaHashedKey(key);
+ doWriteRsaKey(key);
break;
case blink::WebCryptoKeyAlgorithmParamsTypeNone:
ASSERT_NOT_REACHED();
@@ -727,10 +730,12 @@
doWriteUint32(key.algorithm().aesParams()->lengthBits() / 8);
}
- void doWriteRsaHashedKey(const blink::WebCryptoKey& key)
+ void doWriteRsaKey(const blink::WebCryptoKey& key)
{
- ASSERT(key.algorithm().rsaHashedParams());
- append(static_cast<uint8_t>(RsaHashedKeyTag));
+ if (key.algorithm().rsaHashedParams())
+ append(static_cast<uint8_t>(RsaHashedKeyTag));
+ else
+ append(static_cast<uint8_t>(RsaKeyTag));
doWriteAlgorithmId(key.algorithm().id());
@@ -745,11 +750,13 @@
ASSERT_NOT_REACHED();
}
- const blink::WebCryptoRsaHashedKeyAlgorithmParams* params = key.algorithm().rsaHashedParams();
+ const blink::WebCryptoRsaKeyAlgorithmParams* params = key.algorithm().rsaParams();
doWriteUint32(params->modulusLengthBits());
doWriteUint32(params->publicExponent().size());
append(params->publicExponent().data(), params->publicExponent().size());
- doWriteAlgorithmId(key.algorithm().rsaHashedParams()->hash().id());
+
+ if (key.algorithm().rsaHashedParams())
+ doWriteAlgorithmId(key.algorithm().rsaHashedParams()->hash().id());
}
void doWriteAlgorithmId(blink::WebCryptoAlgorithmId id)
@@ -761,6 +768,8 @@
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:
@@ -2245,8 +2254,12 @@
if (!doReadHmacKey(algorithm, type))
return false;
break;
+ case RsaKeyTag:
+ if (!doReadRsaKey(false, algorithm, type))
+ return false;
+ break;
case RsaHashedKeyTag:
- if (!doReadRsaHashedKey(algorithm, type))
+ if (!doReadRsaKey(true, algorithm, type))
return false;
break;
default:
@@ -2406,7 +2419,7 @@
return !algorithm.isNull();
}
- bool doReadRsaHashedKey(blink::WebCryptoKeyAlgorithm& algorithm, blink::WebCryptoKeyType& type)
+ bool doReadRsaKey(bool hasHash, blink::WebCryptoKeyAlgorithm& algorithm, blink::WebCryptoKeyType& type)
{
blink::WebCryptoAlgorithmId id;
if (!doReadAlgorithmId(id))
@@ -2441,10 +2454,14 @@
const uint8_t* publicExponent = m_buffer + m_position;
m_position += publicExponentSize;
- blink::WebCryptoAlgorithmId hash;
- if (!doReadAlgorithmId(hash))
- return false;
- algorithm = blink::WebCryptoKeyAlgorithm::createRsaHashed(id, modulusLengthBits, publicExponent, publicExponentSize, hash);
+ 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);
+ }
return !algorithm.isNull();
}
@@ -2465,6 +2482,9 @@
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 | trunk/Source/modules/crypto/KeyAlgorithm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698