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/webcrypto_impl.h" | 5 #include "content/child/webcrypto/webcrypto_impl.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/shared_crypto.h" | 9 #include "content/child/webcrypto/shared_crypto.h" |
10 #include "content/child/webcrypto/status.h" | 10 #include "content/child/webcrypto/status.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 } else { | 116 } else { |
117 DCHECK(key.handle()); | 117 DCHECK(key.handle()); |
118 DCHECK_EQ(algorithm.id(), key.algorithm().id()); | 118 DCHECK_EQ(algorithm.id(), key.algorithm().id()); |
119 DCHECK_EQ(extractable, key.extractable()); | 119 DCHECK_EQ(extractable, key.extractable()); |
120 DCHECK_EQ(usage_mask, key.usages()); | 120 DCHECK_EQ(usage_mask, key.usages()); |
121 result.completeWithKey(key); | 121 result.completeWithKey(key); |
122 } | 122 } |
123 } | 123 } |
124 } | 124 } |
125 | 125 |
126 void WebCryptoImpl::importKey( | 126 void WebCryptoImpl::importKey(blink::WebCryptoKeyFormat format, |
127 blink::WebCryptoKeyFormat format, | 127 const unsigned char* key_data, |
128 const unsigned char* key_data, | 128 unsigned int key_data_size, |
129 unsigned int key_data_size, | 129 const blink::WebCryptoAlgorithm& algorithm, |
130 const blink::WebCryptoAlgorithm& algorithm_or_null, | 130 bool extractable, |
131 bool extractable, | 131 blink::WebCryptoKeyUsageMask usage_mask, |
132 blink::WebCryptoKeyUsageMask usage_mask, | 132 blink::WebCryptoResult result) { |
133 blink::WebCryptoResult result) { | |
134 blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); | 133 blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); |
135 Status status = | 134 Status status = |
136 webcrypto::ImportKey(format, | 135 webcrypto::ImportKey(format, |
137 webcrypto::CryptoData(key_data, key_data_size), | 136 webcrypto::CryptoData(key_data, key_data_size), |
138 algorithm_or_null, | 137 algorithm, |
139 extractable, | 138 extractable, |
140 usage_mask, | 139 usage_mask, |
141 &key); | 140 &key); |
142 if (status.IsError()) { | 141 if (status.IsError()) { |
143 CompleteWithError(status, &result); | 142 CompleteWithError(status, &result); |
144 } else { | 143 } else { |
145 DCHECK(key.handle()); | 144 DCHECK(key.handle()); |
146 DCHECK(!key.algorithm().isNull()); | 145 DCHECK(!key.algorithm().isNull()); |
147 DCHECK_EQ(extractable, key.extractable()); | 146 DCHECK_EQ(extractable, key.extractable()); |
148 result.completeWithKey(key); | 147 result.completeWithKey(key); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 } | 226 } |
228 | 227 |
229 bool WebCryptoImpl::serializeKeyForClone( | 228 bool WebCryptoImpl::serializeKeyForClone( |
230 const blink::WebCryptoKey& key, | 229 const blink::WebCryptoKey& key, |
231 blink::WebVector<unsigned char>& key_data) { | 230 blink::WebVector<unsigned char>& key_data) { |
232 Status status = webcrypto::SerializeKeyForClone(key, &key_data); | 231 Status status = webcrypto::SerializeKeyForClone(key, &key_data); |
233 return status.IsSuccess(); | 232 return status.IsSuccess(); |
234 } | 233 } |
235 | 234 |
236 } // namespace content | 235 } // namespace content |
OLD | NEW |