| 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 WebCryptoAlgorithmParamsTypeRsaPssParams, // Sign | 204 WebCryptoAlgorithmParamsTypeRsaPssParams, // Sign |
| 205 WebCryptoAlgorithmParamsTypeRsaPssParams, // Verify | 205 WebCryptoAlgorithmParamsTypeRsaPssParams, // Verify |
| 206 WebCryptoAlgorithmInfo::Undefined, // Digest | 206 WebCryptoAlgorithmInfo::Undefined, // Digest |
| 207 WebCryptoAlgorithmParamsTypeRsaHashedKeyGenParams, // GenerateKey | 207 WebCryptoAlgorithmParamsTypeRsaHashedKeyGenParams, // GenerateKey |
| 208 WebCryptoAlgorithmParamsTypeRsaHashedImportParams, // ImportKey | 208 WebCryptoAlgorithmParamsTypeRsaHashedImportParams, // ImportKey |
| 209 WebCryptoAlgorithmInfo::Undefined, // DeriveKey | 209 WebCryptoAlgorithmInfo::Undefined, // DeriveKey |
| 210 WebCryptoAlgorithmInfo::Undefined, // DeriveBits | 210 WebCryptoAlgorithmInfo::Undefined, // DeriveBits |
| 211 WebCryptoAlgorithmParamsTypeNone, // WrapKey | 211 WebCryptoAlgorithmParamsTypeNone, // WrapKey |
| 212 WebCryptoAlgorithmParamsTypeNone // UnwrapKey | 212 WebCryptoAlgorithmParamsTypeNone // UnwrapKey |
| 213 } | 213 } |
| 214 }, { // Index 12 |
| 215 "ECDSA", { |
| 216 WebCryptoAlgorithmInfo::Undefined, // Encrypt |
| 217 WebCryptoAlgorithmInfo::Undefined, // Decrypt |
| 218 WebCryptoAlgorithmParamsTypeEcdsaParams, // Sign |
| 219 WebCryptoAlgorithmParamsTypeEcdsaParams, // Verify |
| 220 WebCryptoAlgorithmInfo::Undefined, // Digest |
| 221 WebCryptoAlgorithmParamsTypeEcKeyGenParams, // GenerateKey |
| 222 WebCryptoAlgorithmParamsTypeEcKeyImportParams, // ImportKey |
| 223 WebCryptoAlgorithmInfo::Undefined, // DeriveKey |
| 224 WebCryptoAlgorithmInfo::Undefined, // DeriveBits |
| 225 WebCryptoAlgorithmParamsTypeNone, // WrapKey |
| 226 WebCryptoAlgorithmParamsTypeNone // UnwrapKey |
| 227 } |
| 214 }, | 228 }, |
| 215 }; | 229 }; |
| 216 | 230 |
| 217 // Initializing the algorithmIdToInfo table above depends on knowing the enum | 231 // Initializing the algorithmIdToInfo table above depends on knowing the enum |
| 218 // values for algorithm IDs. If those ever change, the table will need to be | 232 // values for algorithm IDs. If those ever change, the table will need to be |
| 219 // updated. | 233 // updated. |
| 220 COMPILE_ASSERT(WebCryptoAlgorithmIdAesCbc == 0, AesCbc_idDoesntMatch); | 234 COMPILE_ASSERT(WebCryptoAlgorithmIdAesCbc == 0, AesCbc_idDoesntMatch); |
| 221 COMPILE_ASSERT(WebCryptoAlgorithmIdHmac == 1, Hmac_idDoesntMatch); | 235 COMPILE_ASSERT(WebCryptoAlgorithmIdHmac == 1, Hmac_idDoesntMatch); |
| 222 COMPILE_ASSERT(WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 == 2, RsaSsaPkcs1v1_5_idDoesn
tMatch); | 236 COMPILE_ASSERT(WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 == 2, RsaSsaPkcs1v1_5_idDoesn
tMatch); |
| 223 COMPILE_ASSERT(WebCryptoAlgorithmIdSha1 == 3, Sha1_idDoesntMatch); | 237 COMPILE_ASSERT(WebCryptoAlgorithmIdSha1 == 3, Sha1_idDoesntMatch); |
| 224 COMPILE_ASSERT(WebCryptoAlgorithmIdSha256 == 4, Sha256_idDoesntMatch); | 238 COMPILE_ASSERT(WebCryptoAlgorithmIdSha256 == 4, Sha256_idDoesntMatch); |
| 225 COMPILE_ASSERT(WebCryptoAlgorithmIdSha384 == 5, Sha384_idDoesntMatch); | 239 COMPILE_ASSERT(WebCryptoAlgorithmIdSha384 == 5, Sha384_idDoesntMatch); |
| 226 COMPILE_ASSERT(WebCryptoAlgorithmIdSha512 == 6, Sha512_idDoesntMatch); | 240 COMPILE_ASSERT(WebCryptoAlgorithmIdSha512 == 6, Sha512_idDoesntMatch); |
| 227 COMPILE_ASSERT(WebCryptoAlgorithmIdAesGcm == 7, AesGcm_idDoesntMatch); | 241 COMPILE_ASSERT(WebCryptoAlgorithmIdAesGcm == 7, AesGcm_idDoesntMatch); |
| 228 COMPILE_ASSERT(WebCryptoAlgorithmIdRsaOaep == 8, RsaOaep_idDoesntMatch); | 242 COMPILE_ASSERT(WebCryptoAlgorithmIdRsaOaep == 8, RsaOaep_idDoesntMatch); |
| 229 COMPILE_ASSERT(WebCryptoAlgorithmIdAesCtr == 9, AesCtr_idDoesntMatch); | 243 COMPILE_ASSERT(WebCryptoAlgorithmIdAesCtr == 9, AesCtr_idDoesntMatch); |
| 230 COMPILE_ASSERT(WebCryptoAlgorithmIdAesKw == 10, AesKw_idDoesntMatch); | 244 COMPILE_ASSERT(WebCryptoAlgorithmIdAesKw == 10, AesKw_idDoesntMatch); |
| 231 COMPILE_ASSERT(WebCryptoAlgorithmIdRsaPss == 11, RsaPss_idDoesntMatch); | 245 COMPILE_ASSERT(WebCryptoAlgorithmIdRsaPss == 11, RsaPss_idDoesntMatch); |
| 232 COMPILE_ASSERT(WebCryptoAlgorithmIdLast == 11, Last_idDoesntMatch); | 246 COMPILE_ASSERT(WebCryptoAlgorithmIdEcdsa == 12, Ecdsa_idDoesntMatch); |
| 247 COMPILE_ASSERT(WebCryptoAlgorithmIdLast == 12, Last_idDoesntMatch); |
| 233 COMPILE_ASSERT(10 == WebCryptoOperationLast, UpdateParamsMapping); | 248 COMPILE_ASSERT(10 == WebCryptoOperationLast, UpdateParamsMapping); |
| 234 | 249 |
| 235 } // namespace | 250 } // namespace |
| 236 | 251 |
| 237 class WebCryptoAlgorithmPrivate : public ThreadSafeRefCounted<WebCryptoAlgorithm
Private> { | 252 class WebCryptoAlgorithmPrivate : public ThreadSafeRefCounted<WebCryptoAlgorithm
Private> { |
| 238 public: | 253 public: |
| 239 WebCryptoAlgorithmPrivate(WebCryptoAlgorithmId id, PassOwnPtr<WebCryptoAlgor
ithmParams> params) | 254 WebCryptoAlgorithmPrivate(WebCryptoAlgorithmId id, PassOwnPtr<WebCryptoAlgor
ithmParams> params) |
| 240 : id(id) | 255 : id(id) |
| 241 , params(params) | 256 , params(params) |
| 242 { | 257 { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 } | 375 } |
| 361 | 376 |
| 362 const WebCryptoRsaPssParams* WebCryptoAlgorithm::rsaPssParams() const | 377 const WebCryptoRsaPssParams* WebCryptoAlgorithm::rsaPssParams() const |
| 363 { | 378 { |
| 364 ASSERT(!isNull()); | 379 ASSERT(!isNull()); |
| 365 if (paramsType() == WebCryptoAlgorithmParamsTypeRsaPssParams) | 380 if (paramsType() == WebCryptoAlgorithmParamsTypeRsaPssParams) |
| 366 return static_cast<WebCryptoRsaPssParams*>(m_private->params.get()); | 381 return static_cast<WebCryptoRsaPssParams*>(m_private->params.get()); |
| 367 return 0; | 382 return 0; |
| 368 } | 383 } |
| 369 | 384 |
| 385 const WebCryptoEcdsaParams* WebCryptoAlgorithm::ecdsaParams() const |
| 386 { |
| 387 ASSERT(!isNull()); |
| 388 if (paramsType() == WebCryptoAlgorithmParamsTypeEcdsaParams) |
| 389 return static_cast<WebCryptoEcdsaParams*>(m_private->params.get()); |
| 390 return 0; |
| 391 } |
| 392 |
| 393 const WebCryptoEcKeyGenParams* WebCryptoAlgorithm::ecKeyGenParams() const |
| 394 { |
| 395 ASSERT(!isNull()); |
| 396 if (paramsType() == WebCryptoAlgorithmParamsTypeEcKeyGenParams) |
| 397 return static_cast<WebCryptoEcKeyGenParams*>(m_private->params.get()); |
| 398 return 0; |
| 399 } |
| 400 |
| 401 const WebCryptoEcKeyImportParams* WebCryptoAlgorithm::ecKeyImportParams() const |
| 402 { |
| 403 ASSERT(!isNull()); |
| 404 if (paramsType() == WebCryptoAlgorithmParamsTypeEcKeyImportParams) |
| 405 return static_cast<WebCryptoEcKeyImportParams*>(m_private->params.get())
; |
| 406 return 0; |
| 407 } |
| 408 |
| 370 bool WebCryptoAlgorithm::isHash(WebCryptoAlgorithmId id) | 409 bool WebCryptoAlgorithm::isHash(WebCryptoAlgorithmId id) |
| 371 { | 410 { |
| 372 switch (id) { | 411 switch (id) { |
| 373 case WebCryptoAlgorithmIdSha1: | 412 case WebCryptoAlgorithmIdSha1: |
| 374 case WebCryptoAlgorithmIdSha256: | 413 case WebCryptoAlgorithmIdSha256: |
| 375 case WebCryptoAlgorithmIdSha384: | 414 case WebCryptoAlgorithmIdSha384: |
| 376 case WebCryptoAlgorithmIdSha512: | 415 case WebCryptoAlgorithmIdSha512: |
| 377 return true; | 416 return true; |
| 378 case WebCryptoAlgorithmIdAesCbc: | 417 case WebCryptoAlgorithmIdAesCbc: |
| 379 case WebCryptoAlgorithmIdHmac: | 418 case WebCryptoAlgorithmIdHmac: |
| 380 case WebCryptoAlgorithmIdRsaSsaPkcs1v1_5: | 419 case WebCryptoAlgorithmIdRsaSsaPkcs1v1_5: |
| 381 case WebCryptoAlgorithmIdAesGcm: | 420 case WebCryptoAlgorithmIdAesGcm: |
| 382 case WebCryptoAlgorithmIdRsaOaep: | 421 case WebCryptoAlgorithmIdRsaOaep: |
| 383 case WebCryptoAlgorithmIdAesCtr: | 422 case WebCryptoAlgorithmIdAesCtr: |
| 384 case WebCryptoAlgorithmIdAesKw: | 423 case WebCryptoAlgorithmIdAesKw: |
| 385 case WebCryptoAlgorithmIdRsaPss: | 424 case WebCryptoAlgorithmIdRsaPss: |
| 425 case WebCryptoAlgorithmIdEcdsa: |
| 386 break; | 426 break; |
| 387 } | 427 } |
| 388 return false; | 428 return false; |
| 389 } | 429 } |
| 390 | 430 |
| 391 void WebCryptoAlgorithm::assign(const WebCryptoAlgorithm& other) | 431 void WebCryptoAlgorithm::assign(const WebCryptoAlgorithm& other) |
| 392 { | 432 { |
| 393 m_private = other.m_private; | 433 m_private = other.m_private; |
| 394 } | 434 } |
| 395 | 435 |
| 396 void WebCryptoAlgorithm::reset() | 436 void WebCryptoAlgorithm::reset() |
| 397 { | 437 { |
| 398 m_private.reset(); | 438 m_private.reset(); |
| 399 } | 439 } |
| 400 | 440 |
| 401 } // namespace blink | 441 } // namespace blink |
| OLD | NEW |