OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 {"SHA-384", WebKit::WebCryptoAlgorithmIdSha384}, | 73 {"SHA-384", WebKit::WebCryptoAlgorithmIdSha384}, |
74 {"SHA-512", WebKit::WebCryptoAlgorithmIdSha512}, | 74 {"SHA-512", WebKit::WebCryptoAlgorithmIdSha512}, |
75 }; | 75 }; |
76 | 76 |
77 // What operations each algorithm supports, and what parameters it expects. | 77 // What operations each algorithm supports, and what parameters it expects. |
78 const OperationParamsMapping operationParamsMappings[] = { | 78 const OperationParamsMapping operationParamsMappings[] = { |
79 // AES-CBC (section 18.10.) | 79 // AES-CBC (section 18.10.) |
80 {WebKit::WebCryptoAlgorithmIdAesCbc, Decrypt, WebKit::WebCryptoAlgorithmPara
msTypeAesCbcParams}, | 80 {WebKit::WebCryptoAlgorithmIdAesCbc, Decrypt, WebKit::WebCryptoAlgorithmPara
msTypeAesCbcParams}, |
81 {WebKit::WebCryptoAlgorithmIdAesCbc, Encrypt, WebKit::WebCryptoAlgorithmPara
msTypeAesCbcParams}, | 81 {WebKit::WebCryptoAlgorithmIdAesCbc, Encrypt, WebKit::WebCryptoAlgorithmPara
msTypeAesCbcParams}, |
82 {WebKit::WebCryptoAlgorithmIdAesCbc, GenerateKey, WebKit::WebCryptoAlgorithm
ParamsTypeAesKeyGenParams}, | 82 {WebKit::WebCryptoAlgorithmIdAesCbc, GenerateKey, WebKit::WebCryptoAlgorithm
ParamsTypeAesKeyGenParams}, |
| 83 {WebKit::WebCryptoAlgorithmIdAesCbc, ImportKey, WebKit::WebCryptoAlgorithmPa
ramsTypeNone}, |
83 | 84 |
84 // HMAC (section 18.14.) | 85 // HMAC (section 18.14.) |
85 {WebKit::WebCryptoAlgorithmIdHmac, Sign, WebKit::WebCryptoAlgorithmParamsTyp
eHmacParams}, | 86 {WebKit::WebCryptoAlgorithmIdHmac, Sign, WebKit::WebCryptoAlgorithmParamsTyp
eHmacParams}, |
86 {WebKit::WebCryptoAlgorithmIdHmac, Verify, WebKit::WebCryptoAlgorithmParamsT
ypeHmacParams}, | 87 {WebKit::WebCryptoAlgorithmIdHmac, Verify, WebKit::WebCryptoAlgorithmParamsT
ypeHmacParams}, |
87 {WebKit::WebCryptoAlgorithmIdHmac, GenerateKey, WebKit::WebCryptoAlgorithmPa
ramsTypeHmacParams}, | 88 {WebKit::WebCryptoAlgorithmIdHmac, GenerateKey, WebKit::WebCryptoAlgorithmPa
ramsTypeHmacParams}, |
| 89 {WebKit::WebCryptoAlgorithmIdHmac, ImportKey, WebKit::WebCryptoAlgorithmPara
msTypeHmacParams}, |
88 | 90 |
89 // SHA-1 (section 18.16.) | 91 // SHA-1 (section 18.16.) |
90 {WebKit::WebCryptoAlgorithmIdSha1, Digest, WebKit::WebCryptoAlgorithmParamsT
ypeNone}, | 92 {WebKit::WebCryptoAlgorithmIdSha1, Digest, WebKit::WebCryptoAlgorithmParamsT
ypeNone}, |
91 | 93 |
92 // SHA-224 (section 18.16.) | 94 // SHA-224 (section 18.16.) |
93 {WebKit::WebCryptoAlgorithmIdSha224, Digest, WebKit::WebCryptoAlgorithmParam
sTypeNone}, | 95 {WebKit::WebCryptoAlgorithmIdSha224, Digest, WebKit::WebCryptoAlgorithmParam
sTypeNone}, |
94 | 96 |
95 // SHA-256 (section 18.16.) | 97 // SHA-256 (section 18.16.) |
96 {WebKit::WebCryptoAlgorithmIdSha256, Digest, WebKit::WebCryptoAlgorithmParam
sTypeNone}, | 98 {WebKit::WebCryptoAlgorithmIdSha256, Digest, WebKit::WebCryptoAlgorithmParam
sTypeNone}, |
97 | 99 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 | 258 |
257 if (!params && paramsType != WebKit::WebCryptoAlgorithmParamsTypeNone) { | 259 if (!params && paramsType != WebKit::WebCryptoAlgorithmParamsTypeNone) { |
258 es.throwDOMException(NotSupportedError); | 260 es.throwDOMException(NotSupportedError); |
259 return false; | 261 return false; |
260 } | 262 } |
261 | 263 |
262 algorithm = WebKit::WebCryptoAlgorithm(info->algorithmId, info->algorithmNam
e, params.release()); | 264 algorithm = WebKit::WebCryptoAlgorithm(info->algorithmId, info->algorithmNam
e, params.release()); |
263 return true; | 265 return true; |
264 } | 266 } |
265 | 267 |
266 bool normalizeAlgorithmForImportKey(const Dictionary& raw, WebKit::WebCryptoAlgo
rithm& algorithm, ExceptionState& es) | |
267 { | |
268 const AlgorithmInfo* info = algorithmInfo(raw, es); | |
269 if (!info) | |
270 return false; | |
271 | |
272 algorithm = WebKit::WebCryptoAlgorithm(info->algorithmId, info->algorithmNam
e, nullptr); | |
273 return true; | |
274 } | |
275 | |
276 } // namespace WebCore | 268 } // namespace WebCore |
OLD | NEW |