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

Unified Diff: Source/modules/crypto/NormalizeAlgorithm.cpp

Issue 289073005: [webcrypto] Hook up parameter normalization for RSA-OAEP. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase 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 | « LayoutTests/crypto/rsa-ssa-generateKey-parseAlgorithm-failures-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/crypto/NormalizeAlgorithm.cpp
diff --git a/Source/modules/crypto/NormalizeAlgorithm.cpp b/Source/modules/crypto/NormalizeAlgorithm.cpp
index 19965eeb8aab1e51759a8bcca196f5b11a9bfd2d..a0fb249be6ece17508c8e30c1436467e683117f7 100644
--- a/Source/modules/crypto/NormalizeAlgorithm.cpp
+++ b/Source/modules/crypto/NormalizeAlgorithm.cpp
@@ -72,6 +72,7 @@ const AlgorithmNameMapping algorithmNameMappings[] = {
{"AES-CBC", 7, blink::WebCryptoAlgorithmIdAesCbc},
{"AES-GCM", 7, blink::WebCryptoAlgorithmIdAesGcm},
{"AES-CTR", 7, blink::WebCryptoAlgorithmIdAesCtr},
+ {"RSA-OAEP", 8, blink::WebCryptoAlgorithmIdRsaOaep},
{"RSAES-PKCS1-V1_5", 16, blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5},
{"RSASSA-PKCS1-V1_5", 17, blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5},
};
@@ -218,18 +219,17 @@ const AlgorithmInfo algorithmIdToInfo[] = {
}
}, { // Index 9
"RSA-OAEP", {
- // FIXME:
- Undefined, // Encrypt
- Undefined, // Decrypt
+ blink::WebCryptoAlgorithmParamsTypeRsaOaepParams, // Encrypt
+ blink::WebCryptoAlgorithmParamsTypeRsaOaepParams, // Decrypt
Undefined, // Sign
Undefined, // Verify
Undefined, // Digest
- Undefined, // GenerateKey
- Undefined, // ImportKey
+ blink::WebCryptoAlgorithmParamsTypeRsaHashedKeyGenParams, // GenerateKey
+ blink::WebCryptoAlgorithmParamsTypeRsaHashedImportParams, // ImportKey
Undefined, // DeriveKey
Undefined, // DeriveBits
- Undefined, // WrapKey
- Undefined // UnwrapKey
+ blink::WebCryptoAlgorithmParamsTypeRsaOaepParams, // WrapKey
+ blink::WebCryptoAlgorithmParamsTypeRsaOaepParams // UnwrapKey
}
}, { // Index 10
"AES-CTR", {
@@ -818,6 +818,25 @@ bool parseAesGcmParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmPa
return true;
}
+// Defined by the WebCrypto spec as:
+//
+// dictionary RsaOaepParams : Algorithm {
+// CryptoOperationData? label;
+// };
+bool parseRsaOaepParams(const Dictionary& raw, OwnPtr<blink::WebCryptoAlgorithmParams>& params, const ErrorContext& context, CryptoResult* result)
+{
+ bool hasLabel;
+ RefPtr<ArrayBufferView> label;
+ if (!getOptionalCryptoOperationData(raw, "label", hasLabel, label, context, result))
+ return false;
+
+ const unsigned char* labelStart = hasLabel ? static_cast<const unsigned char*>(label->baseAddress()) : 0;
+ unsigned labelLength = hasLabel ? label->byteLength() : 0;
+
+ params = adoptPtr(new blink::WebCryptoRsaOaepParams(hasLabel, labelStart, labelLength));
+ return true;
+}
+
bool parseAlgorithmParams(const Dictionary& raw, blink::WebCryptoAlgorithmParamsType type, OwnPtr<blink::WebCryptoAlgorithmParams>& params, ErrorContext& context, CryptoResult* result)
{
switch (type) {
@@ -851,8 +870,8 @@ bool parseAlgorithmParams(const Dictionary& raw, blink::WebCryptoAlgorithmParams
context.add("AesGcmParams");
return parseAesGcmParams(raw, params, context, result);
case blink::WebCryptoAlgorithmParamsTypeRsaOaepParams:
- // TODO
- notImplemented();
+ context.add("RsaOaepParams");
+ return parseRsaOaepParams(raw, params, context, result);
break;
}
ASSERT_NOT_REACHED();
« no previous file with comments | « LayoutTests/crypto/rsa-ssa-generateKey-parseAlgorithm-failures-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698