Chromium Code Reviews| Index: crypto/ec_private_key_nss.cc |
| diff --git a/crypto/ec_private_key_nss.cc b/crypto/ec_private_key_nss.cc |
| index b65de955aa3265f43248e44ed39c2cc82cf29c2c..89a1d85426adce336a70c776d8a112f361a8aabf 100644 |
| --- a/crypto/ec_private_key_nss.cc |
| +++ b/crypto/ec_private_key_nss.cc |
| @@ -26,10 +26,9 @@ extern "C" { |
| namespace { |
| -// Copied from rsa_private_key_nss.cc. |
| -static bool ReadAttribute(SECKEYPrivateKey* key, |
| - CK_ATTRIBUTE_TYPE type, |
| - std::vector<uint8_t>* output) { |
| +static bool AppendAttribute(SECKEYPrivateKey* key, |
| + CK_ATTRIBUTE_TYPE type, |
| + std::vector<uint8_t>* output) { |
| SECItem item; |
| SECStatus rv; |
| rv = PK11_ReadRawAttribute(PK11_TypePrivKey, key, type, &item); |
| @@ -38,7 +37,7 @@ static bool ReadAttribute(SECKEYPrivateKey* key, |
| return false; |
| } |
| - output->assign(item.data, item.data + item.len); |
| + output->insert(output->end(), item.data, item.data + item.len); |
| SECITEM_FreeItem(&item, PR_FALSE); |
| return true; |
| } |
| @@ -311,12 +310,10 @@ bool ECPrivateKey::ExportRawPublicKey(std::string* output) { |
| return true; |
| } |
| -bool ECPrivateKey::ExportValue(std::vector<uint8_t>* output) { |
| - return ReadAttribute(key_, CKA_VALUE, output); |
| -} |
| - |
| -bool ECPrivateKey::ExportECParams(std::vector<uint8_t>* output) { |
| - return ReadAttribute(key_, CKA_EC_PARAMS, output); |
| +bool ECPrivateKey::ExportValueForTesting(std::vector<uint8_t>* output) { |
|
davidben
2016/02/26 21:51:34
(See comment on the openssl side.)
|
| + output->clear(); |
| + return AppendAttribute(key_, CKA_VALUE, output) && |
| + AppendAttribute(key_, CKA_EC_PARAMS, output); |
| } |
| ECPrivateKey::ECPrivateKey() : key_(NULL), public_key_(NULL) {} |