 Chromium Code Reviews
 Chromium Code Reviews Issue 777403004:
  [WebCrypto] Throw syntaxError if keyUsage is empty in ImportKey  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 777403004:
  [WebCrypto] Throw syntaxError if keyUsage is empty in ImportKey  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| 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 "base/logging.h" | 5 #include "base/logging.h" | 
| 6 #include "base/stl_util.h" | 6 #include "base/stl_util.h" | 
| 7 #include "content/child/webcrypto/algorithm_dispatch.h" | 7 #include "content/child/webcrypto/algorithm_dispatch.h" | 
| 8 #include "content/child/webcrypto/crypto_data.h" | 8 #include "content/child/webcrypto/crypto_data.h" | 
| 9 #include "content/child/webcrypto/status.h" | 9 #include "content/child/webcrypto/status.h" | 
| 10 #include "content/child/webcrypto/test/test_helpers.h" | 10 #include "content/child/webcrypto/test/test_helpers.h" | 
| (...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 816 blink::WebCryptoKey private_key; | 816 blink::WebCryptoKey private_key; | 
| 817 | 817 | 
| 818 ASSERT_EQ(Status::ErrorCreateKeyEmptyUsages(), | 818 ASSERT_EQ(Status::ErrorCreateKeyEmptyUsages(), | 
| 819 GenerateKeyPair(CreateRsaHashedKeyGenAlgorithm( | 819 GenerateKeyPair(CreateRsaHashedKeyGenAlgorithm( | 
| 820 blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, | 820 blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, | 
| 821 blink::WebCryptoAlgorithmIdSha256, | 821 blink::WebCryptoAlgorithmIdSha256, | 
| 822 modulus_length, public_exponent), | 822 modulus_length, public_exponent), | 
| 823 true, 0, &public_key, &private_key)); | 823 true, 0, &public_key, &private_key)); | 
| 824 } | 824 } | 
| 825 | 825 | 
| 826 TEST(WebCryptoRsaSsaTest, ImportKeyEmptyUsages) { | |
| 827 blink::WebCryptoKey key; | |
| 828 ASSERT_EQ(Status::ErrorImportKeyEmptyUsages(), | |
| 
eroman
2014/12/09 17:42:55
Incorrect, this should pass per the spec.
 | |
| 829 ImportKey(blink::WebCryptoKeyFormatSpki, | |
| 830 CryptoData(HexStringToBytes(kPublicKeySpkiDerHex)), | |
| 831 CreateRsaHashedImportAlgorithm( | |
| 832 blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, | |
| 833 blink::WebCryptoAlgorithmIdSha256), | |
| 834 true, 0, &key)); | |
| 835 | |
| 836 } | |
| 837 | |
| 826 TEST(WebCryptoRsaSsaTest, ImportExportJwkRsaPublicKey) { | 838 TEST(WebCryptoRsaSsaTest, ImportExportJwkRsaPublicKey) { | 
| 827 struct TestCase { | 839 struct TestCase { | 
| 828 const blink::WebCryptoAlgorithmId hash; | 840 const blink::WebCryptoAlgorithmId hash; | 
| 829 const blink::WebCryptoKeyUsageMask usage; | 841 const blink::WebCryptoKeyUsageMask usage; | 
| 830 const char* const jwk_alg; | 842 const char* const jwk_alg; | 
| 831 }; | 843 }; | 
| 832 const TestCase kTests[] = { | 844 const TestCase kTests[] = { | 
| 833 {blink::WebCryptoAlgorithmIdSha1, blink::WebCryptoKeyUsageVerify, "RS1"}, | 845 {blink::WebCryptoAlgorithmIdSha1, blink::WebCryptoKeyUsageVerify, "RS1"}, | 
| 834 {blink::WebCryptoAlgorithmIdSha256, | 846 {blink::WebCryptoAlgorithmIdSha256, | 
| 835 blink::WebCryptoKeyUsageVerify, | 847 blink::WebCryptoKeyUsageVerify, | 
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 984 true, usages, &key); | 996 true, usages, &key); | 
| 985 EXPECT_EQ(test_error, StatusToString(status)); | 997 EXPECT_EQ(test_error, StatusToString(status)); | 
| 986 } | 998 } | 
| 987 } | 999 } | 
| 988 | 1000 | 
| 989 } // namespace | 1001 } // namespace | 
| 990 | 1002 | 
| 991 } // namespace webcrypto | 1003 } // namespace webcrypto | 
| 992 | 1004 | 
| 993 } // namespace content | 1005 } // namespace content | 
| OLD | NEW |