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/aes_key_openssl.h" | 5 #include "content/child/webcrypto/openssl/aes_key_openssl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/child/webcrypto/crypto_data.h" | 8 #include "content/child/webcrypto/crypto_data.h" |
9 #include "content/child/webcrypto/jwk.h" | 9 #include "content/child/webcrypto/jwk.h" |
10 #include "content/child/webcrypto/openssl/key_openssl.h" | 10 #include "content/child/webcrypto/openssl/key_openssl.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 extractable, | 85 extractable, |
86 usage_mask, | 86 usage_mask, |
87 key); | 87 key); |
88 } | 88 } |
89 | 89 |
90 Status AesAlgorithm::ImportKeyJwk(const CryptoData& key_data, | 90 Status AesAlgorithm::ImportKeyJwk(const CryptoData& key_data, |
91 const blink::WebCryptoAlgorithm& algorithm, | 91 const blink::WebCryptoAlgorithm& algorithm, |
92 bool extractable, | 92 bool extractable, |
93 blink::WebCryptoKeyUsageMask usage_mask, | 93 blink::WebCryptoKeyUsageMask usage_mask, |
94 blink::WebCryptoKey* key) const { | 94 blink::WebCryptoKey* key) const { |
95 std::vector<uint8> raw_data; | 95 std::vector<uint8_t> raw_data; |
96 Status status = ReadAesSecretKeyJwk( | 96 Status status = ReadAesSecretKeyJwk( |
97 key_data, jwk_suffix_, extractable, usage_mask, &raw_data); | 97 key_data, jwk_suffix_, extractable, usage_mask, &raw_data); |
98 if (status.IsError()) | 98 if (status.IsError()) |
99 return status; | 99 return status; |
100 | 100 |
101 return ImportKeyRaw( | 101 return ImportKeyRaw( |
102 CryptoData(raw_data), algorithm, extractable, usage_mask, key); | 102 CryptoData(raw_data), algorithm, extractable, usage_mask, key); |
103 } | 103 } |
104 | 104 |
105 Status AesAlgorithm::ExportKeyRaw(const blink::WebCryptoKey& key, | 105 Status AesAlgorithm::ExportKeyRaw(const blink::WebCryptoKey& key, |
106 std::vector<uint8>* buffer) const { | 106 std::vector<uint8_t>* buffer) const { |
107 *buffer = SymKeyOpenSsl::Cast(key)->raw_key_data(); | 107 *buffer = SymKeyOpenSsl::Cast(key)->raw_key_data(); |
108 return Status::Success(); | 108 return Status::Success(); |
109 } | 109 } |
110 | 110 |
111 Status AesAlgorithm::ExportKeyJwk(const blink::WebCryptoKey& key, | 111 Status AesAlgorithm::ExportKeyJwk(const blink::WebCryptoKey& key, |
112 std::vector<uint8>* buffer) const { | 112 std::vector<uint8_t>* buffer) const { |
113 const std::vector<uint8>& raw_data = SymKeyOpenSsl::Cast(key)->raw_key_data(); | 113 const std::vector<uint8_t>& raw_data = |
| 114 SymKeyOpenSsl::Cast(key)->raw_key_data(); |
114 | 115 |
115 WriteSecretKeyJwk(CryptoData(raw_data), | 116 WriteSecretKeyJwk(CryptoData(raw_data), |
116 MakeJwkAesAlgorithmName(jwk_suffix_, raw_data.size()), | 117 MakeJwkAesAlgorithmName(jwk_suffix_, raw_data.size()), |
117 key.extractable(), | 118 key.extractable(), |
118 key.usages(), | 119 key.usages(), |
119 buffer); | 120 buffer); |
120 | 121 |
121 return Status::Success(); | 122 return Status::Success(); |
122 } | 123 } |
123 | 124 |
124 } // namespace webcrypto | 125 } // namespace webcrypto |
125 | 126 |
126 } // namespace content | 127 } // namespace content |
OLD | NEW |