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

Unified Diff: crypto/ec_private_key_nss.cc

Issue 1739403002: Cut down on usage of deprecated APIs in //crypto. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months 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 side-by-side diff with in-line comments
Download patch
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) {}

Powered by Google App Engine
This is Rietveld 408576698