| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 60 |
| 61 struct JwkToWebCryptoUsage { | 61 struct JwkToWebCryptoUsage { |
| 62 const char* const jwk_key_op; | 62 const char* const jwk_key_op; |
| 63 const blink::WebCryptoKeyUsage webcrypto_usage; | 63 const blink::WebCryptoKeyUsage webcrypto_usage; |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 const JwkToWebCryptoUsage kJwkWebCryptoUsageMap[] = { | 66 const JwkToWebCryptoUsage kJwkWebCryptoUsageMap[] = { |
| 67 {"encrypt", blink::WebCryptoKeyUsageEncrypt}, | 67 {"encrypt", blink::WebCryptoKeyUsageEncrypt}, |
| 68 {"decrypt", blink::WebCryptoKeyUsageDecrypt}, | 68 {"decrypt", blink::WebCryptoKeyUsageDecrypt}, |
| 69 {"deriveKey", blink::WebCryptoKeyUsageDeriveKey}, | 69 {"deriveKey", blink::WebCryptoKeyUsageDeriveKey}, |
| 70 // TODO(padolph): Add 'deriveBits' once supported by Blink. | 70 {"deriveBits", blink::WebCryptoKeyUsageDeriveBits}, |
| 71 {"sign", blink::WebCryptoKeyUsageSign}, | 71 {"sign", blink::WebCryptoKeyUsageSign}, |
| 72 {"unwrapKey", blink::WebCryptoKeyUsageUnwrapKey}, | 72 {"unwrapKey", blink::WebCryptoKeyUsageUnwrapKey}, |
| 73 {"verify", blink::WebCryptoKeyUsageVerify}, | 73 {"verify", blink::WebCryptoKeyUsageVerify}, |
| 74 {"wrapKey", blink::WebCryptoKeyUsageWrapKey}}; | 74 {"wrapKey", blink::WebCryptoKeyUsageWrapKey}}; |
| 75 | 75 |
| 76 // Modifies the input usage_mask by according to the key_op value. | 76 // Modifies the input usage_mask by according to the key_op value. |
| 77 bool JwkKeyOpToWebCryptoUsage(const std::string& key_op, | 77 bool JwkKeyOpToWebCryptoUsage(const std::string& key_op, |
| 78 blink::WebCryptoKeyUsageMask* usage_mask) { | 78 blink::WebCryptoKeyUsageMask* usage_mask) { |
| 79 for (size_t i = 0; i < arraysize(kJwkWebCryptoUsageMap); ++i) { | 79 for (size_t i = 0; i < arraysize(kJwkWebCryptoUsageMap); ++i) { |
| 80 if (kJwkWebCryptoUsageMap[i].jwk_key_op == key_op) { | 80 if (kJwkWebCryptoUsageMap[i].jwk_key_op == key_op) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 algorithm.id(), keylen_bytes * 8); | 182 algorithm.id(), keylen_bytes * 8); |
| 183 return true; | 183 return true; |
| 184 default: | 184 default: |
| 185 return false; | 185 return false; |
| 186 } | 186 } |
| 187 } | 187 } |
| 188 | 188 |
| 189 } // namespace webcrypto | 189 } // namespace webcrypto |
| 190 | 190 |
| 191 } // namespace content | 191 } // namespace content |
| OLD | NEW |