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/platform_crypto.h" | 5 #include "content/child/webcrypto/platform_crypto.h" |
6 | 6 |
7 #include <cryptohi.h> | 7 #include <cryptohi.h> |
8 #include <pk11pub.h> | 8 #include <pk11pub.h> |
9 #include <secerr.h> | 9 #include <secerr.h> |
10 #include <sechash.h> | 10 #include <sechash.h> |
(...skipping 1591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1602 | 1602 |
1603 // The ID isn't guaranteed to be set by PKCS#11. However it is by softtoken so | 1603 // The ID isn't guaranteed to be set by PKCS#11. However it is by softtoken so |
1604 // this should work. | 1604 // this should work. |
1605 SECItem object_id = {}; | 1605 SECItem object_id = {}; |
1606 if (PK11_ReadRawAttribute( | 1606 if (PK11_ReadRawAttribute( |
1607 PK11_TypeGeneric, key_object.get(), CKA_ID, &object_id) != SECSuccess) | 1607 PK11_TypeGeneric, key_object.get(), CKA_ID, &object_id) != SECSuccess) |
1608 return Status::OperationError(); | 1608 return Status::OperationError(); |
1609 | 1609 |
1610 crypto::ScopedSECKEYPrivateKey private_key( | 1610 crypto::ScopedSECKEYPrivateKey private_key( |
1611 PK11_FindKeyByKeyID(slot.get(), &object_id, NULL)); | 1611 PK11_FindKeyByKeyID(slot.get(), &object_id, NULL)); |
| 1612 |
| 1613 SECITEM_FreeItem(&object_id, PR_FALSE); |
| 1614 |
1612 if (!private_key) | 1615 if (!private_key) |
1613 return Status::OperationError(); | 1616 return Status::OperationError(); |
1614 | 1617 |
1615 blink::WebCryptoKeyAlgorithm key_algorithm; | 1618 blink::WebCryptoKeyAlgorithm key_algorithm; |
1616 if (!CreatePrivateKeyAlgorithm(algorithm, private_key.get(), &key_algorithm)) | 1619 if (!CreatePrivateKeyAlgorithm(algorithm, private_key.get(), &key_algorithm)) |
1617 return Status::ErrorUnexpected(); | 1620 return Status::ErrorUnexpected(); |
1618 | 1621 |
1619 scoped_ptr<PrivateKey> key_handle; | 1622 scoped_ptr<PrivateKey> key_handle; |
1620 Status status = | 1623 Status status = |
1621 PrivateKey::Create(private_key.Pass(), key_algorithm, &key_handle); | 1624 PrivateKey::Create(private_key.Pass(), key_algorithm, &key_handle); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1811 key_algorithm, | 1814 key_algorithm, |
1812 usage_mask); | 1815 usage_mask); |
1813 return Status::Success(); | 1816 return Status::Success(); |
1814 } | 1817 } |
1815 | 1818 |
1816 } // namespace platform | 1819 } // namespace platform |
1817 | 1820 |
1818 } // namespace webcrypto | 1821 } // namespace webcrypto |
1819 | 1822 |
1820 } // namespace content | 1823 } // namespace content |
OLD | NEW |