| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <vector> | 5 #include <vector> |
| 6 #include <openssl/evp.h> | 6 #include <openssl/evp.h> |
| 7 | 7 |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "content/child/webcrypto/crypto_data.h" | 10 #include "content/child/webcrypto/crypto_data.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 CryptoData(params->iv()), | 55 CryptoData(params->iv()), |
| 56 CryptoData(params->optionalAdditionalData()), | 56 CryptoData(params->optionalAdditionalData()), |
| 57 GetAesGcmAlgorithmFromKeySize(raw_key.size()), | 57 GetAesGcmAlgorithmFromKeySize(raw_key.size()), |
| 58 buffer); | 58 buffer); |
| 59 } | 59 } |
| 60 | 60 |
| 61 class AesGcmImplementation : public AesAlgorithm { | 61 class AesGcmImplementation : public AesAlgorithm { |
| 62 public: | 62 public: |
| 63 AesGcmImplementation() : AesAlgorithm("GCM") {} | 63 AesGcmImplementation() : AesAlgorithm("GCM") {} |
| 64 | 64 |
| 65 virtual Status Encrypt(const blink::WebCryptoAlgorithm& algorithm, | 65 Status Encrypt(const blink::WebCryptoAlgorithm& algorithm, |
| 66 const blink::WebCryptoKey& key, | 66 const blink::WebCryptoKey& key, |
| 67 const CryptoData& data, | 67 const CryptoData& data, |
| 68 std::vector<uint8_t>* buffer) const override { | 68 std::vector<uint8_t>* buffer) const override { |
| 69 return AesGcmEncryptDecrypt(ENCRYPT, algorithm, key, data, buffer); | 69 return AesGcmEncryptDecrypt(ENCRYPT, algorithm, key, data, buffer); |
| 70 } | 70 } |
| 71 | 71 |
| 72 virtual Status Decrypt(const blink::WebCryptoAlgorithm& algorithm, | 72 Status Decrypt(const blink::WebCryptoAlgorithm& algorithm, |
| 73 const blink::WebCryptoKey& key, | 73 const blink::WebCryptoKey& key, |
| 74 const CryptoData& data, | 74 const CryptoData& data, |
| 75 std::vector<uint8_t>* buffer) const override { | 75 std::vector<uint8_t>* buffer) const override { |
| 76 return AesGcmEncryptDecrypt(DECRYPT, algorithm, key, data, buffer); | 76 return AesGcmEncryptDecrypt(DECRYPT, algorithm, key, data, buffer); |
| 77 } | 77 } |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 } // namespace | 80 } // namespace |
| 81 | 81 |
| 82 AlgorithmImplementation* CreatePlatformAesGcmImplementation() { | 82 AlgorithmImplementation* CreatePlatformAesGcmImplementation() { |
| 83 return new AesGcmImplementation; | 83 return new AesGcmImplementation; |
| 84 } | 84 } |
| 85 | 85 |
| 86 } // namespace webcrypto | 86 } // namespace webcrypto |
| 87 | 87 |
| 88 } // namespace content | 88 } // namespace content |
| OLD | NEW |