Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: content/renderer/webcrypto/webcrypto_impl_openssl.cc

Issue 62633004: [webcrypto] Add RSA public key SPKI import/export for NSS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/aes.h> 8 #include <openssl/aes.h>
9 #include <openssl/evp.h> 9 #include <openssl/evp.h>
10 #include <openssl/hmac.h> 10 #include <openssl/hmac.h>
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 if (algorithm_or_null.isNull()) 323 if (algorithm_or_null.isNull())
324 return false; 324 return false;
325 const blink::WebCryptoAlgorithm& algorithm = algorithm_or_null; 325 const blink::WebCryptoAlgorithm& algorithm = algorithm_or_null;
326 326
327 // TODO(padolph): Support all relevant alg types and then remove this gate. 327 // TODO(padolph): Support all relevant alg types and then remove this gate.
328 if (algorithm.id() != blink::WebCryptoAlgorithmIdHmac && 328 if (algorithm.id() != blink::WebCryptoAlgorithmIdHmac &&
329 algorithm.id() != blink::WebCryptoAlgorithmIdAesCbc) { 329 algorithm.id() != blink::WebCryptoAlgorithmIdAesCbc) {
330 return false; 330 return false;
331 } 331 }
332 332
333 // TODO(padolph): Need to split handling for symmetric (raw or jwk format) and 333 // TODO(padolph): Need to split handling for symmetric
334 // asymmetric (jwk, spki, or pkcs8 format) keys.
335 // Currently only supporting symmetric. 334 // Currently only supporting symmetric.
336 335
337 // TODO(padolph): jwk handling. Define precedence between jwk contents and
338 // this method's parameters, e.g. 'alg' in jwk vs algorithm.id(). Who wins if
339 // they differ? (jwk, probably)
340
341 // Symmetric keys are always type secret 336 // Symmetric keys are always type secret
342 blink::WebCryptoKeyType type = blink::WebCryptoKeyTypeSecret; 337 blink::WebCryptoKeyType type = blink::WebCryptoKeyTypeSecret;
343 338
344 const unsigned char* raw_key_data; 339 const unsigned char* raw_key_data;
345 unsigned raw_key_data_size; 340 unsigned raw_key_data_size;
346 switch (format) { 341 switch (format) {
347 case blink::WebCryptoKeyFormatRaw: 342 case blink::WebCryptoKeyFormatRaw:
348 raw_key_data = key_data; 343 raw_key_data = key_data;
349 raw_key_data_size = key_data_size; 344 raw_key_data_size = key_data_size;
350 // The NSS implementation fails when importing a raw AES key with a length 345 // The NSS implementation fails when importing a raw AES key with a length
(...skipping 11 matching lines...) Expand all
362 return false; 357 return false;
363 } 358 }
364 359
365 *key = blink::WebCryptoKey::create( 360 *key = blink::WebCryptoKey::create(
366 new SymKeyHandle(raw_key_data, raw_key_data_size), 361 new SymKeyHandle(raw_key_data, raw_key_data_size),
367 type, extractable, algorithm, usage_mask); 362 type, extractable, algorithm, usage_mask);
368 363
369 return true; 364 return true;
370 } 365 }
371 366
367 bool WebCryptoImpl::ExportKeyInternal(
368 blink::WebCryptoKeyFormat format,
369 const blink::WebCryptoKey& key,
370 blink::WebArrayBuffer* buffer) {
371 // TODO(padolph): Implement raw export
372 // TODO(padolph): Implement spki export
373 // TODO(padolph): Implement pkcs8 export
374 // TODO(padolph): Implement jwk export
375 return false;
376 }
377
372 bool WebCryptoImpl::SignInternal( 378 bool WebCryptoImpl::SignInternal(
373 const blink::WebCryptoAlgorithm& algorithm, 379 const blink::WebCryptoAlgorithm& algorithm,
374 const blink::WebCryptoKey& key, 380 const blink::WebCryptoKey& key,
375 const unsigned char* data, 381 const unsigned char* data,
376 unsigned data_size, 382 unsigned data_size,
377 blink::WebArrayBuffer* buffer) { 383 blink::WebArrayBuffer* buffer) {
378 384
379 blink::WebArrayBuffer result; 385 blink::WebArrayBuffer result;
380 386
381 switch (algorithm.id()) { 387 switch (algorithm.id()) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 488
483 break; 489 break;
484 } 490 }
485 default: 491 default:
486 return false; 492 return false;
487 } 493 }
488 return true; 494 return true;
489 } 495 }
490 496
491 } // namespace content 497 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/webcrypto/webcrypto_impl_nss.cc ('k') | content/renderer/webcrypto/webcrypto_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698