Chromium Code Reviews| Index: Source/platform/exported/WebCryptoAlgorithm.cpp |
| diff --git a/Source/platform/exported/WebCryptoAlgorithm.cpp b/Source/platform/exported/WebCryptoAlgorithm.cpp |
| index 024b9701c8d97d5e7f2338340f7fe574d1b3ab60..8fa012c3eac4548188602d526adee6275a4670e7 100644 |
| --- a/Source/platform/exported/WebCryptoAlgorithm.cpp |
| +++ b/Source/platform/exported/WebCryptoAlgorithm.cpp |
| @@ -35,6 +35,20 @@ |
| #include "wtf/OwnPtr.h" |
| #include "wtf/ThreadSafeRefCounted.h" |
| +namespace { |
| +const char kAlgorithmNameAesCbc[] = "AES-CBC"; |
| +const char kAlgorithmNameHmac[] = "HMAC"; |
| +const char kAlgorithmNameRsaSsaPkcs1v15[] = "RSASSA-PKCS1-v1_5"; |
| +const char kAlgorithmNameSha1[] = "SHA-1"; |
| +const char kAlgorithmNameSha256[] = "SHA-256"; |
| +const char kAlgorithmNameSha384[] = "SHA-384"; |
| +const char kAlgorithmNameSha512[] = "SHA-512"; |
| +const char kAlgorithmNameAesGcm[] = "AES-GCM"; |
| +const char kAlgorithmNameRsaOaep[] = "RSA-OAEP"; |
| +const char kAlgorithmNameAesCtr[] = "AES-CTR"; |
| +const char kAlgorithmNameAesKw[] = "AES-KW"; |
| +} |
| + |
| namespace blink { |
| class WebCryptoAlgorithmPrivate : public ThreadSafeRefCounted<WebCryptoAlgorithmPrivate> { |
| @@ -64,6 +78,36 @@ WebCryptoAlgorithm WebCryptoAlgorithm::adoptParamsAndCreate(WebCryptoAlgorithmId |
| return WebCryptoAlgorithm(id, adoptPtr(params)); |
| } |
| +const char* WebCryptoAlgorithm::idToName(blink::WebCryptoAlgorithmId id) |
| +{ |
| + switch (id) { |
| + case blink::WebCryptoAlgorithmIdAesCbc: |
| + return kAlgorithmNameAesCbc; |
| + case blink::WebCryptoAlgorithmIdHmac: |
| + return kAlgorithmNameHmac; |
| + case blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5: |
| + return kAlgorithmNameRsaSsaPkcs1v15; |
| + case blink::WebCryptoAlgorithmIdSha1: |
| + return kAlgorithmNameSha1; |
| + case blink::WebCryptoAlgorithmIdSha256: |
| + return kAlgorithmNameSha256; |
| + case blink::WebCryptoAlgorithmIdSha384: |
| + return kAlgorithmNameSha384; |
| + case blink::WebCryptoAlgorithmIdSha512: |
| + return kAlgorithmNameSha512; |
| + case blink::WebCryptoAlgorithmIdAesGcm: |
| + return kAlgorithmNameAesGcm; |
| + case blink::WebCryptoAlgorithmIdRsaOaep: |
| + return kAlgorithmNameRsaOaep; |
| + case blink::WebCryptoAlgorithmIdAesCtr: |
| + return kAlgorithmNameAesCtr; |
| + case blink::WebCryptoAlgorithmIdAesKw: |
| + return kAlgorithmNameAesKw; |
| + } |
|
abarth-chromium
2014/06/12 17:25:27
Can this be a static table instead of code?
pneubeck (no reviews)
2014/06/12 18:06:46
Is a map of pairs
struct { blink::WebCryptoAlgor
eroman
2014/06/12 19:16:45
Perhaps a solution would be to extract all of Algo
|
| + ASSERT_NOT_REACHED(); |
| + return 0; |
| +} |
| + |
| bool WebCryptoAlgorithm::isNull() const |
| { |
| return m_private.isNull(); |