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/nss/aes_key_nss.h" | 5 #include "content/child/webcrypto/nss/aes_key_nss.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/nss/key_nss.h" | 10 #include "content/child/webcrypto/nss/key_nss.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 import_mechanism_, | 95 import_mechanism_, |
96 import_flags_, | 96 import_flags_, |
97 key); | 97 key); |
98 } | 98 } |
99 | 99 |
100 Status AesAlgorithm::ImportKeyJwk(const CryptoData& key_data, | 100 Status AesAlgorithm::ImportKeyJwk(const CryptoData& key_data, |
101 const blink::WebCryptoAlgorithm& algorithm, | 101 const blink::WebCryptoAlgorithm& algorithm, |
102 bool extractable, | 102 bool extractable, |
103 blink::WebCryptoKeyUsageMask usage_mask, | 103 blink::WebCryptoKeyUsageMask usage_mask, |
104 blink::WebCryptoKey* key) const { | 104 blink::WebCryptoKey* key) const { |
105 std::vector<uint8> raw_data; | 105 std::vector<uint8_t> raw_data; |
106 Status status = ReadAesSecretKeyJwk( | 106 Status status = ReadAesSecretKeyJwk( |
107 key_data, jwk_suffix_, extractable, usage_mask, &raw_data); | 107 key_data, jwk_suffix_, extractable, usage_mask, &raw_data); |
108 if (status.IsError()) | 108 if (status.IsError()) |
109 return status; | 109 return status; |
110 | 110 |
111 return ImportKeyRaw( | 111 return ImportKeyRaw( |
112 CryptoData(raw_data), algorithm, extractable, usage_mask, key); | 112 CryptoData(raw_data), algorithm, extractable, usage_mask, key); |
113 } | 113 } |
114 | 114 |
115 Status AesAlgorithm::ExportKeyRaw(const blink::WebCryptoKey& key, | 115 Status AesAlgorithm::ExportKeyRaw(const blink::WebCryptoKey& key, |
116 std::vector<uint8>* buffer) const { | 116 std::vector<uint8_t>* buffer) const { |
117 *buffer = SymKeyNss::Cast(key)->raw_key_data(); | 117 *buffer = SymKeyNss::Cast(key)->raw_key_data(); |
118 return Status::Success(); | 118 return Status::Success(); |
119 } | 119 } |
120 | 120 |
121 Status AesAlgorithm::ExportKeyJwk(const blink::WebCryptoKey& key, | 121 Status AesAlgorithm::ExportKeyJwk(const blink::WebCryptoKey& key, |
122 std::vector<uint8>* buffer) const { | 122 std::vector<uint8_t>* buffer) const { |
123 SymKeyNss* sym_key = SymKeyNss::Cast(key); | 123 SymKeyNss* sym_key = SymKeyNss::Cast(key); |
124 const std::vector<uint8>& raw_data = sym_key->raw_key_data(); | 124 const std::vector<uint8_t>& raw_data = sym_key->raw_key_data(); |
125 | 125 |
126 WriteSecretKeyJwk(CryptoData(raw_data), | 126 WriteSecretKeyJwk(CryptoData(raw_data), |
127 MakeJwkAesAlgorithmName(jwk_suffix_, raw_data.size()), | 127 MakeJwkAesAlgorithmName(jwk_suffix_, raw_data.size()), |
128 key.extractable(), | 128 key.extractable(), |
129 key.usages(), | 129 key.usages(), |
130 buffer); | 130 buffer); |
131 | 131 |
132 return Status::Success(); | 132 return Status::Success(); |
133 } | 133 } |
134 | 134 |
135 } // namespace webcrypto | 135 } // namespace webcrypto |
136 | 136 |
137 } // namespace content | 137 } // namespace content |
OLD | NEW |