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_util.h" | 5 #include "content/child/webcrypto/webcrypto_util.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "content/child/webcrypto/status.h" | 10 #include "content/child/webcrypto/status.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 case blink::WebCryptoAlgorithmIdAesCtr: | 172 case blink::WebCryptoAlgorithmIdAesCtr: |
173 case blink::WebCryptoAlgorithmIdAesGcm: | 173 case blink::WebCryptoAlgorithmIdAesGcm: |
174 *key_algorithm = blink::WebCryptoKeyAlgorithm::createAes( | 174 *key_algorithm = blink::WebCryptoKeyAlgorithm::createAes( |
175 algorithm.id(), keylen_bytes * 8); | 175 algorithm.id(), keylen_bytes * 8); |
176 return true; | 176 return true; |
177 default: | 177 default: |
178 return false; | 178 return false; |
179 } | 179 } |
180 } | 180 } |
181 | 181 |
| 182 bool ContainsKeyUsages(blink::WebCryptoKeyUsageMask a, |
| 183 blink::WebCryptoKeyUsageMask b) { |
| 184 return (a & b) == b; |
| 185 } |
| 186 |
182 bool IsAlgorithmRsa(blink::WebCryptoAlgorithmId alg_id) { | 187 bool IsAlgorithmRsa(blink::WebCryptoAlgorithmId alg_id) { |
183 return alg_id == blink::WebCryptoAlgorithmIdRsaOaep || | 188 return alg_id == blink::WebCryptoAlgorithmIdRsaOaep || |
184 alg_id == blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5; | 189 alg_id == blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5; |
185 } | 190 } |
186 | 191 |
| 192 bool IsAlgorithmAsymmetric(blink::WebCryptoAlgorithmId alg_id) { |
| 193 // TODO(padolph): include all other asymmetric algorithms once they are |
| 194 // defined, e.g. EC and DH. |
| 195 return IsAlgorithmRsa(alg_id); |
| 196 } |
| 197 |
187 } // namespace webcrypto | 198 } // namespace webcrypto |
188 | 199 |
189 } // namespace content | 200 } // namespace content |
OLD | NEW |