| 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 default: | 184 default: |
| 185 return false; | 185 return false; |
| 186 } | 186 } |
| 187 } | 187 } |
| 188 | 188 |
| 189 bool ContainsKeyUsages(blink::WebCryptoKeyUsageMask a, | 189 bool ContainsKeyUsages(blink::WebCryptoKeyUsageMask a, |
| 190 blink::WebCryptoKeyUsageMask b) { | 190 blink::WebCryptoKeyUsageMask b) { |
| 191 return (a & b) == b; | 191 return (a & b) == b; |
| 192 } | 192 } |
| 193 | 193 |
| 194 // TODO(eroman): Move this helper to WebCryptoKey. |
| 195 bool KeyUsageAllows(const blink::WebCryptoKey& key, |
| 196 const blink::WebCryptoKeyUsage usage) { |
| 197 return ((key.usages() & usage) != 0); |
| 198 } |
| 199 |
| 194 bool IsAlgorithmRsa(blink::WebCryptoAlgorithmId alg_id) { | 200 bool IsAlgorithmRsa(blink::WebCryptoAlgorithmId alg_id) { |
| 195 return alg_id == blink::WebCryptoAlgorithmIdRsaOaep || | 201 return alg_id == blink::WebCryptoAlgorithmIdRsaOaep || |
| 196 alg_id == blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5; | 202 alg_id == blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5; |
| 197 } | 203 } |
| 198 | 204 |
| 199 bool IsAlgorithmAsymmetric(blink::WebCryptoAlgorithmId alg_id) { | 205 bool IsAlgorithmAsymmetric(blink::WebCryptoAlgorithmId alg_id) { |
| 200 // TODO(padolph): include all other asymmetric algorithms once they are | 206 // TODO(padolph): include all other asymmetric algorithms once they are |
| 201 // defined, e.g. EC and DH. | 207 // defined, e.g. EC and DH. |
| 202 return IsAlgorithmRsa(alg_id); | 208 return IsAlgorithmRsa(alg_id); |
| 203 } | 209 } |
| 204 | 210 |
| 205 } // namespace webcrypto | 211 } // namespace webcrypto |
| 206 | 212 |
| 207 } // namespace content | 213 } // namespace content |
| OLD | NEW |