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 "content/child/webcrypto/openssl/util_openssl.h" |
| 6 |
| 7 #include <openssl/evp.h> |
| 8 |
5 #include "content/child/webcrypto/crypto_data.h" | 9 #include "content/child/webcrypto/crypto_data.h" |
| 10 #include "content/child/webcrypto/platform_crypto.h" |
| 11 #include "crypto/openssl_util.h" |
6 | 12 |
7 namespace content { | 13 namespace content { |
8 | 14 |
9 namespace webcrypto { | 15 namespace webcrypto { |
10 | 16 |
11 CryptoData::CryptoData() : bytes_(NULL), byte_length_(0) {} | 17 void PlatformInit() { |
| 18 crypto::EnsureOpenSSLInit(); |
| 19 } |
12 | 20 |
13 CryptoData::CryptoData(const unsigned char* bytes, unsigned int byte_length) | 21 const EVP_MD* GetDigest(blink::WebCryptoAlgorithmId id) { |
14 : bytes_(bytes), byte_length_(byte_length) {} | 22 switch (id) { |
| 23 case blink::WebCryptoAlgorithmIdSha1: |
| 24 return EVP_sha1(); |
| 25 case blink::WebCryptoAlgorithmIdSha256: |
| 26 return EVP_sha256(); |
| 27 case blink::WebCryptoAlgorithmIdSha384: |
| 28 return EVP_sha384(); |
| 29 case blink::WebCryptoAlgorithmIdSha512: |
| 30 return EVP_sha512(); |
| 31 default: |
| 32 return NULL; |
| 33 } |
| 34 } |
15 | 35 |
16 CryptoData::CryptoData(const std::vector<unsigned char>& bytes) | 36 AlgorithmImplementation* CreatePlatformRsaOaepImplementation() { |
17 : bytes_(bytes.size() ? &bytes[0] : NULL), byte_length_(bytes.size()) {} | 37 // TODO(eroman): |
| 38 return NULL; |
| 39 } |
18 | 40 |
19 CryptoData::CryptoData(const std::string& bytes) | 41 AlgorithmImplementation* CreatePlatformRsaSsaImplementation() { |
20 : bytes_(bytes.size() ? reinterpret_cast<const unsigned char*>(bytes.data()) | 42 // TODO(eroman): |
21 : NULL), | 43 return NULL; |
22 byte_length_(bytes.size()) {} | 44 } |
23 | |
24 CryptoData::CryptoData(const blink::WebVector<unsigned char>& bytes) | |
25 : bytes_(bytes.data()), byte_length_(bytes.size()) {} | |
26 | 45 |
27 } // namespace webcrypto | 46 } // namespace webcrypto |
28 | 47 |
29 } // namespace content | 48 } // namespace content |
OLD | NEW |