| 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/evp.h> | 8 #include <openssl/evp.h> |
| 9 #include <openssl/hmac.h> | 9 #include <openssl/hmac.h> |
| 10 #include <openssl/sha.h> | 10 #include <openssl/sha.h> |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 WebKit::WebCryptoKeyUsageMask /*usage_mask*/, | 136 WebKit::WebCryptoKeyUsageMask /*usage_mask*/, |
| 137 scoped_ptr<WebKit::WebCryptoKeyHandle>* handle, | 137 scoped_ptr<WebKit::WebCryptoKeyHandle>* handle, |
| 138 WebKit::WebCryptoKeyType* type) { | 138 WebKit::WebCryptoKeyType* type) { |
| 139 | 139 |
| 140 // TODO(padolph): Support all relevant alg types and then remove this gate. | 140 // TODO(padolph): Support all relevant alg types and then remove this gate. |
| 141 if (algorithm.id() != WebKit::WebCryptoAlgorithmIdHmac && | 141 if (algorithm.id() != WebKit::WebCryptoAlgorithmIdHmac && |
| 142 algorithm.id() != WebKit::WebCryptoAlgorithmIdAesCbc) { | 142 algorithm.id() != WebKit::WebCryptoAlgorithmIdAesCbc) { |
| 143 return false; | 143 return false; |
| 144 } | 144 } |
| 145 | 145 |
| 146 // TODO(padolph): Need to split handling for symmetric (raw or jwk format) and | 146 // TODO(padolph): Need to split handling for symmetric (raw format) and |
| 147 // asymmetric (jwk, spki, or pkcs8 format) keys. | 147 // asymmetric (spki or pkcs8 format) keys. |
| 148 // Currently only supporting symmetric. | 148 // Currently only supporting symmetric. |
| 149 | 149 |
| 150 // TODO(padolph): jwk handling. Define precedence between jwk contents and | |
| 151 // this method's parameters, e.g. 'alg' in jwk vs algorithm.id(). Who wins if | |
| 152 // they differ? (jwk, probably) | |
| 153 | |
| 154 // Symmetric keys are always type secret | 150 // Symmetric keys are always type secret |
| 155 *type = WebKit::WebCryptoKeyTypeSecret; | 151 *type = WebKit::WebCryptoKeyTypeSecret; |
| 156 | 152 |
| 157 const unsigned char* raw_key_data; | 153 const unsigned char* raw_key_data; |
| 158 unsigned raw_key_data_size; | 154 unsigned raw_key_data_size; |
| 159 switch (format) { | 155 switch (format) { |
| 160 case WebKit::WebCryptoKeyFormatRaw: | 156 case WebKit::WebCryptoKeyFormatRaw: |
| 161 raw_key_data = key_data; | 157 raw_key_data = key_data; |
| 162 raw_key_data_size = key_data_size; | 158 raw_key_data_size = key_data_size; |
| 163 break; | 159 break; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 | 283 |
| 288 break; | 284 break; |
| 289 } | 285 } |
| 290 default: | 286 default: |
| 291 return false; | 287 return false; |
| 292 } | 288 } |
| 293 return true; | 289 return true; |
| 294 } | 290 } |
| 295 | 291 |
| 296 } // namespace content | 292 } // namespace content |
| OLD | NEW |