| 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 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "modules/crypto/CryptoOperation.h" | 32 #include "modules/crypto/CryptoOperation.h" |
| 33 | 33 |
| 34 #include "modules/crypto/AesCbcParams.h" | |
| 35 #include "modules/crypto/AesKeyGenParams.h" | |
| 36 #include "modules/crypto/Algorithm.h" | 34 #include "modules/crypto/Algorithm.h" |
| 37 | 35 |
| 38 namespace WebCore { | 36 namespace WebCore { |
| 39 | 37 |
| 40 namespace { | |
| 41 | |
| 42 PassRefPtr<Algorithm> createAlgorithm(const WebKit::WebCryptoAlgorithm& algorith
m) | |
| 43 { | |
| 44 switch (algorithm.paramsType()) { | |
| 45 case WebKit::WebCryptoAlgorithmParamsTypeNone: | |
| 46 return Algorithm::create(algorithm); | |
| 47 case WebKit::WebCryptoAlgorithmParamsTypeAesCbcParams: | |
| 48 return AesCbcParams::create(algorithm); | |
| 49 case WebKit::WebCryptoAlgorithmParamsTypeAesKeyGenParams: | |
| 50 return AesKeyGenParams::create(algorithm); | |
| 51 } | |
| 52 ASSERT_NOT_REACHED(); | |
| 53 return 0; | |
| 54 } | |
| 55 | |
| 56 } // namespace | |
| 57 | |
| 58 CryptoOperation::CryptoOperation(const WebKit::WebCryptoAlgorithm& algorithm) | 38 CryptoOperation::CryptoOperation(const WebKit::WebCryptoAlgorithm& algorithm) |
| 59 : m_algorithm(algorithm) | 39 : m_algorithm(algorithm) |
| 60 { | 40 { |
| 61 ScriptWrappable::init(this); | 41 ScriptWrappable::init(this); |
| 62 } | 42 } |
| 63 | 43 |
| 64 Algorithm* CryptoOperation::algorithm() | 44 Algorithm* CryptoOperation::algorithm() |
| 65 { | 45 { |
| 66 if (!m_algorithmNode) | 46 if (!m_algorithmNode) |
| 67 m_algorithmNode = createAlgorithm(m_algorithm); | 47 m_algorithmNode = Algorithm::create(m_algorithm); |
| 68 return m_algorithmNode.get(); | 48 return m_algorithmNode.get(); |
| 69 } | 49 } |
| 70 | 50 |
| 71 } // namespace WebCore | 51 } // namespace WebCore |
| OLD | NEW |