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

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

Issue 312393004: Expose WebCrypto's lookupAlgorithmInfo. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@share_normalize
Patch Set: Fixed constant definitions. 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: Source/modules/crypto/NormalizeAlgorithm.cpp
diff --git a/Source/modules/crypto/NormalizeAlgorithm.cpp b/Source/modules/crypto/NormalizeAlgorithm.cpp
index 62b76cee3974a02c3b2b208c28c36674e5773683..be30f68f1ea01dcc82483e8f7b33c1c7e15d4d4e 100644
--- a/Source/modules/crypto/NormalizeAlgorithm.cpp
+++ b/Source/modules/crypto/NormalizeAlgorithm.cpp
@@ -79,9 +79,6 @@ typedef char ParamsTypeOrUndefined;
const ParamsTypeOrUndefined Undefined = -1;
struct AlgorithmInfo {
- // The canonical (case-sensitive) name for the algorithm.
- const char* name;
-
// A map from the operation to the expected parameter type of the algorithm.
// If an operation is not applicable for the algorithm, set to Undefined.
const ParamsTypeOrUndefined operationToParamsType[blink::WebCryptoOperationLast + 1];
@@ -90,7 +87,7 @@ struct AlgorithmInfo {
// A mapping from the algorithm ID to information about the algorithm.
const AlgorithmInfo algorithmIdToInfo[] = {
{ // Index 0
- "AES-CBC", {
+ {
blink::WebCryptoAlgorithmParamsTypeAesCbcParams, // Encrypt
blink::WebCryptoAlgorithmParamsTypeAesCbcParams, // Decrypt
Undefined, // Sign
@@ -104,7 +101,7 @@ const AlgorithmInfo algorithmIdToInfo[] = {
blink::WebCryptoAlgorithmParamsTypeAesCbcParams // UnwrapKey
}
}, { // Index 1
- "HMAC", {
+ {
Undefined, // Encrypt
Undefined, // Decrypt
blink::WebCryptoAlgorithmParamsTypeNone, // Sign
@@ -118,7 +115,7 @@ const AlgorithmInfo algorithmIdToInfo[] = {
Undefined // UnwrapKey
}
}, { // Index 2
- "RSASSA-PKCS1-v1_5", {
+ {
Undefined, // Encrypt
Undefined, // Decrypt
blink::WebCryptoAlgorithmParamsTypeNone, // Sign
@@ -132,7 +129,7 @@ const AlgorithmInfo algorithmIdToInfo[] = {
Undefined // UnwrapKey
}
}, { // Index 3
- "SHA-1", {
+ {
Undefined, // Encrypt
Undefined, // Decrypt
Undefined, // Sign
@@ -146,7 +143,7 @@ const AlgorithmInfo algorithmIdToInfo[] = {
Undefined // UnwrapKey
}
}, { // Index 4
- "SHA-256", {
+ {
Undefined, // Encrypt
Undefined, // Decrypt
Undefined, // Sign
@@ -160,7 +157,7 @@ const AlgorithmInfo algorithmIdToInfo[] = {
Undefined // UnwrapKey
}
}, { // Index 5
- "SHA-384", {
+ {
Undefined, // Encrypt
Undefined, // Decrypt
Undefined, // Sign
@@ -174,7 +171,7 @@ const AlgorithmInfo algorithmIdToInfo[] = {
Undefined // UnwrapKey
}
}, { // Index 6
- "SHA-512", {
+ {
Undefined, // Encrypt
Undefined, // Decrypt
Undefined, // Sign
@@ -188,7 +185,7 @@ const AlgorithmInfo algorithmIdToInfo[] = {
Undefined // UnwrapKey
}
}, { // Index 7
- "AES-GCM", {
+ {
blink::WebCryptoAlgorithmParamsTypeAesGcmParams, // Encrypt
blink::WebCryptoAlgorithmParamsTypeAesGcmParams, // Decrypt
Undefined, // Sign
@@ -202,7 +199,7 @@ const AlgorithmInfo algorithmIdToInfo[] = {
blink::WebCryptoAlgorithmParamsTypeAesGcmParams // UnwrapKey
}
}, { // Index 8
- "RSA-OAEP", {
+ {
blink::WebCryptoAlgorithmParamsTypeRsaOaepParams, // Encrypt
blink::WebCryptoAlgorithmParamsTypeRsaOaepParams, // Decrypt
Undefined, // Sign
@@ -216,7 +213,7 @@ const AlgorithmInfo algorithmIdToInfo[] = {
blink::WebCryptoAlgorithmParamsTypeRsaOaepParams // UnwrapKey
}
}, { // Index 9
- "AES-CTR", {
+ {
blink::WebCryptoAlgorithmParamsTypeAesCtrParams, // Encrypt
blink::WebCryptoAlgorithmParamsTypeAesCtrParams, // Decrypt
Undefined, // Sign
@@ -230,7 +227,7 @@ const AlgorithmInfo algorithmIdToInfo[] = {
blink::WebCryptoAlgorithmParamsTypeAesCtrParams // UnwrapKey
}
}, { // Index 10
- "AES-KW", {
+ {
Undefined, // Encrypt
Undefined, // Decrypt
Undefined, // Sign
@@ -899,7 +896,7 @@ bool parseAlgorithm(const Dictionary& raw, blink::WebCryptoOperation op, blink::
const AlgorithmInfo* algorithmInfo = lookupAlgorithmInfo(algorithmId);
if (algorithmInfo->operationToParamsType[op] == Undefined) {
- context.add(algorithmIdToName(algorithmId));
+ context.add(blink::WebCryptoAlgorithm::idToName(algorithmId));
setNotSupportedError(context.toString("Unsupported operation", operationToString(op)), error);
return false;
}
@@ -921,9 +918,4 @@ bool normalizeAlgorithm(const Dictionary& raw, blink::WebCryptoOperation op, bli
return parseAlgorithm(raw, op, algorithm, ErrorContext(), error);
}
-const char* algorithmIdToName(blink::WebCryptoAlgorithmId id)
-{
- return lookupAlgorithmInfo(id)->name;
-}
-
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698