| 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 WebCryptoAlgorithmInfo::Undefined, // Sign | 190 WebCryptoAlgorithmInfo::Undefined, // Sign |
| 191 WebCryptoAlgorithmInfo::Undefined, // Verify | 191 WebCryptoAlgorithmInfo::Undefined, // Verify |
| 192 WebCryptoAlgorithmInfo::Undefined, // Digest | 192 WebCryptoAlgorithmInfo::Undefined, // Digest |
| 193 WebCryptoAlgorithmParamsTypeAesKeyGenParams, // GenerateKey | 193 WebCryptoAlgorithmParamsTypeAesKeyGenParams, // GenerateKey |
| 194 WebCryptoAlgorithmParamsTypeNone, // ImportKey | 194 WebCryptoAlgorithmParamsTypeNone, // ImportKey |
| 195 WebCryptoAlgorithmInfo::Undefined, // DeriveKey | 195 WebCryptoAlgorithmInfo::Undefined, // DeriveKey |
| 196 WebCryptoAlgorithmInfo::Undefined, // DeriveBits | 196 WebCryptoAlgorithmInfo::Undefined, // DeriveBits |
| 197 WebCryptoAlgorithmParamsTypeNone, // WrapKey | 197 WebCryptoAlgorithmParamsTypeNone, // WrapKey |
| 198 WebCryptoAlgorithmParamsTypeNone // UnwrapKey | 198 WebCryptoAlgorithmParamsTypeNone // UnwrapKey |
| 199 } | 199 } |
| 200 }, { // Index 11 |
| 201 "RSA-PSS", { |
| 202 WebCryptoAlgorithmInfo::Undefined, // Encrypt |
| 203 WebCryptoAlgorithmInfo::Undefined, // Decrypt |
| 204 WebCryptoAlgorithmParamsTypeRsaPssParams, // Sign |
| 205 WebCryptoAlgorithmParamsTypeRsaPssParams, // Verify |
| 206 WebCryptoAlgorithmInfo::Undefined, // Digest |
| 207 WebCryptoAlgorithmParamsTypeRsaHashedKeyGenParams, // GenerateKey |
| 208 WebCryptoAlgorithmParamsTypeRsaHashedImportParams, // ImportKey |
| 209 WebCryptoAlgorithmInfo::Undefined, // DeriveKey |
| 210 WebCryptoAlgorithmInfo::Undefined, // DeriveBits |
| 211 WebCryptoAlgorithmParamsTypeNone, // WrapKey |
| 212 WebCryptoAlgorithmParamsTypeNone // UnwrapKey |
| 213 } |
| 200 }, | 214 }, |
| 201 }; | 215 }; |
| 202 | 216 |
| 203 // Initializing the algorithmIdToInfo table above depends on knowing the enum | 217 // Initializing the algorithmIdToInfo table above depends on knowing the enum |
| 204 // values for algorithm IDs. If those ever change, the table will need to be | 218 // values for algorithm IDs. If those ever change, the table will need to be |
| 205 // updated. | 219 // updated. |
| 206 COMPILE_ASSERT(WebCryptoAlgorithmIdAesCbc == 0, AesCbc_idDoesntMatch); | 220 COMPILE_ASSERT(WebCryptoAlgorithmIdAesCbc == 0, AesCbc_idDoesntMatch); |
| 207 COMPILE_ASSERT(WebCryptoAlgorithmIdHmac == 1, Hmac_idDoesntMatch); | 221 COMPILE_ASSERT(WebCryptoAlgorithmIdHmac == 1, Hmac_idDoesntMatch); |
| 208 COMPILE_ASSERT(WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 == 2, RsaSsaPkcs1v1_5_idDoesn
tMatch); | 222 COMPILE_ASSERT(WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 == 2, RsaSsaPkcs1v1_5_idDoesn
tMatch); |
| 209 COMPILE_ASSERT(WebCryptoAlgorithmIdSha1 == 3, Sha1_idDoesntMatch); | 223 COMPILE_ASSERT(WebCryptoAlgorithmIdSha1 == 3, Sha1_idDoesntMatch); |
| 210 COMPILE_ASSERT(WebCryptoAlgorithmIdSha256 == 4, Sha256_idDoesntMatch); | 224 COMPILE_ASSERT(WebCryptoAlgorithmIdSha256 == 4, Sha256_idDoesntMatch); |
| 211 COMPILE_ASSERT(WebCryptoAlgorithmIdSha384 == 5, Sha384_idDoesntMatch); | 225 COMPILE_ASSERT(WebCryptoAlgorithmIdSha384 == 5, Sha384_idDoesntMatch); |
| 212 COMPILE_ASSERT(WebCryptoAlgorithmIdSha512 == 6, Sha512_idDoesntMatch); | 226 COMPILE_ASSERT(WebCryptoAlgorithmIdSha512 == 6, Sha512_idDoesntMatch); |
| 213 COMPILE_ASSERT(WebCryptoAlgorithmIdAesGcm == 7, AesGcm_idDoesntMatch); | 227 COMPILE_ASSERT(WebCryptoAlgorithmIdAesGcm == 7, AesGcm_idDoesntMatch); |
| 214 COMPILE_ASSERT(WebCryptoAlgorithmIdRsaOaep == 8, RsaOaep_idDoesntMatch); | 228 COMPILE_ASSERT(WebCryptoAlgorithmIdRsaOaep == 8, RsaOaep_idDoesntMatch); |
| 215 COMPILE_ASSERT(WebCryptoAlgorithmIdAesCtr == 9, AesCtr_idDoesntMatch); | 229 COMPILE_ASSERT(WebCryptoAlgorithmIdAesCtr == 9, AesCtr_idDoesntMatch); |
| 216 COMPILE_ASSERT(WebCryptoAlgorithmIdAesKw == 10, AesKw_idDoesntMatch); | 230 COMPILE_ASSERT(WebCryptoAlgorithmIdAesKw == 10, AesKw_idDoesntMatch); |
| 217 COMPILE_ASSERT(WebCryptoAlgorithmIdLast == 10, Last_idDoesntMatch); | 231 COMPILE_ASSERT(WebCryptoAlgorithmIdRsaPss == 11, RsaPss_idDoesntMatch); |
| 232 COMPILE_ASSERT(WebCryptoAlgorithmIdLast == 11, Last_idDoesntMatch); |
| 218 COMPILE_ASSERT(10 == WebCryptoOperationLast, UpdateParamsMapping); | 233 COMPILE_ASSERT(10 == WebCryptoOperationLast, UpdateParamsMapping); |
| 219 | 234 |
| 220 } // namespace | 235 } // namespace |
| 221 | 236 |
| 222 class WebCryptoAlgorithmPrivate : public ThreadSafeRefCounted<WebCryptoAlgorithm
Private> { | 237 class WebCryptoAlgorithmPrivate : public ThreadSafeRefCounted<WebCryptoAlgorithm
Private> { |
| 223 public: | 238 public: |
| 224 WebCryptoAlgorithmPrivate(WebCryptoAlgorithmId id, PassOwnPtr<WebCryptoAlgor
ithmParams> params) | 239 WebCryptoAlgorithmPrivate(WebCryptoAlgorithmId id, PassOwnPtr<WebCryptoAlgor
ithmParams> params) |
| 225 : id(id) | 240 : id(id) |
| 226 , params(params) | 241 , params(params) |
| 227 { | 242 { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 } | 352 } |
| 338 | 353 |
| 339 const WebCryptoRsaHashedKeyGenParams* WebCryptoAlgorithm::rsaHashedKeyGenParams(
) const | 354 const WebCryptoRsaHashedKeyGenParams* WebCryptoAlgorithm::rsaHashedKeyGenParams(
) const |
| 340 { | 355 { |
| 341 ASSERT(!isNull()); | 356 ASSERT(!isNull()); |
| 342 if (paramsType() == WebCryptoAlgorithmParamsTypeRsaHashedKeyGenParams) | 357 if (paramsType() == WebCryptoAlgorithmParamsTypeRsaHashedKeyGenParams) |
| 343 return static_cast<WebCryptoRsaHashedKeyGenParams*>(m_private->params.ge
t()); | 358 return static_cast<WebCryptoRsaHashedKeyGenParams*>(m_private->params.ge
t()); |
| 344 return 0; | 359 return 0; |
| 345 } | 360 } |
| 346 | 361 |
| 362 const WebCryptoRsaPssParams* WebCryptoAlgorithm::rsaPssParams() const |
| 363 { |
| 364 ASSERT(!isNull()); |
| 365 if (paramsType() == WebCryptoAlgorithmParamsTypeRsaPssParams) |
| 366 return static_cast<WebCryptoRsaPssParams*>(m_private->params.get()); |
| 367 return 0; |
| 368 } |
| 369 |
| 347 bool WebCryptoAlgorithm::isHash(WebCryptoAlgorithmId id) | 370 bool WebCryptoAlgorithm::isHash(WebCryptoAlgorithmId id) |
| 348 { | 371 { |
| 349 switch (id) { | 372 switch (id) { |
| 350 case WebCryptoAlgorithmIdSha1: | 373 case WebCryptoAlgorithmIdSha1: |
| 351 case WebCryptoAlgorithmIdSha256: | 374 case WebCryptoAlgorithmIdSha256: |
| 352 case WebCryptoAlgorithmIdSha384: | 375 case WebCryptoAlgorithmIdSha384: |
| 353 case WebCryptoAlgorithmIdSha512: | 376 case WebCryptoAlgorithmIdSha512: |
| 354 return true; | 377 return true; |
| 355 case WebCryptoAlgorithmIdAesCbc: | 378 case WebCryptoAlgorithmIdAesCbc: |
| 356 case WebCryptoAlgorithmIdHmac: | 379 case WebCryptoAlgorithmIdHmac: |
| 357 case WebCryptoAlgorithmIdRsaSsaPkcs1v1_5: | 380 case WebCryptoAlgorithmIdRsaSsaPkcs1v1_5: |
| 358 case WebCryptoAlgorithmIdAesGcm: | 381 case WebCryptoAlgorithmIdAesGcm: |
| 359 case WebCryptoAlgorithmIdRsaOaep: | 382 case WebCryptoAlgorithmIdRsaOaep: |
| 360 case WebCryptoAlgorithmIdAesCtr: | 383 case WebCryptoAlgorithmIdAesCtr: |
| 361 case WebCryptoAlgorithmIdAesKw: | 384 case WebCryptoAlgorithmIdAesKw: |
| 385 case WebCryptoAlgorithmIdRsaPss: |
| 362 break; | 386 break; |
| 363 } | 387 } |
| 364 return false; | 388 return false; |
| 365 } | 389 } |
| 366 | 390 |
| 367 void WebCryptoAlgorithm::assign(const WebCryptoAlgorithm& other) | 391 void WebCryptoAlgorithm::assign(const WebCryptoAlgorithm& other) |
| 368 { | 392 { |
| 369 m_private = other.m_private; | 393 m_private = other.m_private; |
| 370 } | 394 } |
| 371 | 395 |
| 372 void WebCryptoAlgorithm::reset() | 396 void WebCryptoAlgorithm::reset() |
| 373 { | 397 { |
| 374 m_private.reset(); | 398 m_private.reset(); |
| 375 } | 399 } |
| 376 | 400 |
| 377 } // namespace blink | 401 } // namespace blink |
| OLD | NEW |