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/nss/sym_key_nss.h" | 5 #include "content/child/webcrypto/nss/sym_key_nss.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/child/webcrypto/crypto_data.h" | 8 #include "content/child/webcrypto/crypto_data.h" |
9 #include "content/child/webcrypto/generate_key_result.h" | 9 #include "content/child/webcrypto/generate_key_result.h" |
10 #include "content/child/webcrypto/nss/key_nss.h" | 10 #include "content/child/webcrypto/nss/key_nss.h" |
(...skipping 25 matching lines...) Expand all Loading... | |
36 if (!pk11_key) | 36 if (!pk11_key) |
37 return Status::OperationError(); | 37 return Status::OperationError(); |
38 | 38 |
39 if (PK11_ExtractKeyValue(pk11_key.get()) != SECSuccess) | 39 if (PK11_ExtractKeyValue(pk11_key.get()) != SECSuccess) |
40 return Status::OperationError(); | 40 return Status::OperationError(); |
41 | 41 |
42 const SECItem* key_data = PK11_GetKeyData(pk11_key.get()); | 42 const SECItem* key_data = PK11_GetKeyData(pk11_key.get()); |
43 if (!key_data) | 43 if (!key_data) |
44 return Status::OperationError(); | 44 return Status::OperationError(); |
45 | 45 |
46 // TODO(nharper): mask usages with allowed usages | |
eroman
2014/11/20 23:40:10
Testing the allowed usages is the responsibility o
nharper
2014/11/21 22:12:01
Done.
| |
47 if (usages == 0) { | |
eroman
2014/11/20 23:40:09
The style being used in these files is that single
nharper
2014/11/21 22:12:01
Done.
| |
48 return Status::ErrorCreateKeyBadUsages(); | |
eroman
2014/11/20 23:40:10
Introduce a new error message so this is easier to
nharper
2014/11/21 22:12:01
Done.
| |
49 } | |
50 | |
46 scoped_ptr<SymKeyNss> handle(new SymKeyNss( | 51 scoped_ptr<SymKeyNss> handle(new SymKeyNss( |
47 pk11_key.Pass(), CryptoData(key_data->data, key_data->len))); | 52 pk11_key.Pass(), CryptoData(key_data->data, key_data->len))); |
48 | 53 |
49 result->AssignSecretKey( | 54 result->AssignSecretKey( |
50 blink::WebCryptoKey::create(handle.release(), | 55 blink::WebCryptoKey::create(handle.release(), |
51 blink::WebCryptoKeyTypeSecret, | 56 blink::WebCryptoKeyTypeSecret, |
52 extractable, | 57 extractable, |
53 algorithm, | 58 algorithm, |
54 usages)); | 59 usages)); |
55 | 60 |
(...skipping 29 matching lines...) Expand all Loading... | |
85 blink::WebCryptoKeyTypeSecret, | 90 blink::WebCryptoKeyTypeSecret, |
86 extractable, | 91 extractable, |
87 algorithm, | 92 algorithm, |
88 usages); | 93 usages); |
89 return Status::Success(); | 94 return Status::Success(); |
90 } | 95 } |
91 | 96 |
92 } // namespace webcrypto | 97 } // namespace webcrypto |
93 | 98 |
94 } // namespace content | 99 } // namespace content |
OLD | NEW |