| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/renderer/webcrypto/webcrypto_impl.h" | 5 #include "content/renderer/webcrypto/webcrypto_impl.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 #include <openssl/hmac.h> | 8 #include <openssl/hmac.h> |
| 9 #include <openssl/sha.h> | 9 #include <openssl/sha.h> |
| 10 | 10 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 WebKit::WebCryptoKeyUsageMask /*usage_mask*/, | 74 WebKit::WebCryptoKeyUsageMask /*usage_mask*/, |
| 75 scoped_ptr<WebKit::WebCryptoKeyHandle>* handle, | 75 scoped_ptr<WebKit::WebCryptoKeyHandle>* handle, |
| 76 WebKit::WebCryptoKeyType* type) { | 76 WebKit::WebCryptoKeyType* type) { |
| 77 | 77 |
| 78 // TODO(padolph): Support all relevant alg types and then remove this gate. | 78 // TODO(padolph): Support all relevant alg types and then remove this gate. |
| 79 if (algorithm.id() != WebKit::WebCryptoAlgorithmIdHmac && | 79 if (algorithm.id() != WebKit::WebCryptoAlgorithmIdHmac && |
| 80 algorithm.id() != WebKit::WebCryptoAlgorithmIdAesCbc) { | 80 algorithm.id() != WebKit::WebCryptoAlgorithmIdAesCbc) { |
| 81 return false; | 81 return false; |
| 82 } | 82 } |
| 83 | 83 |
| 84 // TODO(padolph): Need to split handling for symmetric (raw or jwk format) and | 84 // TODO(padolph): Need to split handling for symmetric (raw format) and |
| 85 // asymmetric (jwk, spki, or pkcs8 format) keys. | 85 // asymmetric (spki or pkcs8 format) keys. |
| 86 // Currently only supporting symmetric. | 86 // Currently only supporting symmetric. |
| 87 | 87 |
| 88 // TODO(padolph): jwk handling. Define precedence between jwk contents and | |
| 89 // this method's parameters, e.g. 'alg' in jwk vs algorithm.id(). Who wins if | |
| 90 // they differ? (jwk, probably) | |
| 91 | |
| 92 // Symmetric keys are always type secret | 88 // Symmetric keys are always type secret |
| 93 *type = WebKit::WebCryptoKeyTypeSecret; | 89 *type = WebKit::WebCryptoKeyTypeSecret; |
| 94 | 90 |
| 95 const unsigned char* raw_key_data; | 91 const unsigned char* raw_key_data; |
| 96 unsigned raw_key_data_size; | 92 unsigned raw_key_data_size; |
| 97 switch (format) { | 93 switch (format) { |
| 98 case WebKit::WebCryptoKeyFormatRaw: | 94 case WebKit::WebCryptoKeyFormatRaw: |
| 99 raw_key_data = key_data; | 95 raw_key_data = key_data; |
| 100 raw_key_data_size = key_data_size; | 96 raw_key_data_size = key_data_size; |
| 101 break; | 97 break; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 | 221 |
| 226 break; | 222 break; |
| 227 } | 223 } |
| 228 default: | 224 default: |
| 229 return false; | 225 return false; |
| 230 } | 226 } |
| 231 return true; | 227 return true; |
| 232 } | 228 } |
| 233 | 229 |
| 234 } // namespace content | 230 } // namespace content |
| OLD | NEW |