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

Side by Side Diff: crypto/signature_creator_nss.cc

Issue 1870233002: Convert crypto to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « crypto/sha2.cc ('k') | crypto/signature_creator_openssl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "crypto/signature_creator.h" 5 #include "crypto/signature_creator.h"
6 6
7 #include <cryptohi.h> 7 #include <cryptohi.h>
8 #include <keyhi.h> 8 #include <keyhi.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <stdlib.h> 10 #include <stdlib.h>
11 11
12 #include <memory>
13
12 #include "base/logging.h" 14 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "crypto/nss_util.h" 15 #include "crypto/nss_util.h"
15 #include "crypto/rsa_private_key.h" 16 #include "crypto/rsa_private_key.h"
16 17
17 namespace crypto { 18 namespace crypto {
18 19
19 namespace { 20 namespace {
20 21
21 SECOidTag ToNSSSigOid(SignatureCreator::HashAlgorithm hash_alg) { 22 SECOidTag ToNSSSigOid(SignatureCreator::HashAlgorithm hash_alg) {
22 switch (hash_alg) { 23 switch (hash_alg) {
23 case SignatureCreator::SHA1: 24 case SignatureCreator::SHA1:
(...skipping 19 matching lines...) Expand all
43 SignatureCreator::~SignatureCreator() { 44 SignatureCreator::~SignatureCreator() {
44 if (sign_context_) { 45 if (sign_context_) {
45 SGN_DestroyContext(sign_context_, PR_TRUE); 46 SGN_DestroyContext(sign_context_, PR_TRUE);
46 sign_context_ = NULL; 47 sign_context_ = NULL;
47 } 48 }
48 } 49 }
49 50
50 // static 51 // static
51 SignatureCreator* SignatureCreator::Create(RSAPrivateKey* key, 52 SignatureCreator* SignatureCreator::Create(RSAPrivateKey* key,
52 HashAlgorithm hash_alg) { 53 HashAlgorithm hash_alg) {
53 scoped_ptr<SignatureCreator> result(new SignatureCreator); 54 std::unique_ptr<SignatureCreator> result(new SignatureCreator);
54 result->sign_context_ = SGN_NewContext(ToNSSSigOid(hash_alg), key->key()); 55 result->sign_context_ = SGN_NewContext(ToNSSSigOid(hash_alg), key->key());
55 if (!result->sign_context_) { 56 if (!result->sign_context_) {
56 NOTREACHED(); 57 NOTREACHED();
57 return NULL; 58 return NULL;
58 } 59 }
59 60
60 SECStatus rv = SGN_Begin(result->sign_context_); 61 SECStatus rv = SGN_Begin(result->sign_context_);
61 if (rv != SECSuccess) { 62 if (rv != SECSuccess) {
62 NOTREACHED(); 63 NOTREACHED();
63 return NULL; 64 return NULL;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 signature_item.data + signature_item.len); 111 signature_item.data + signature_item.len);
111 SECITEM_FreeItem(&signature_item, PR_FALSE); 112 SECITEM_FreeItem(&signature_item, PR_FALSE);
112 return true; 113 return true;
113 } 114 }
114 115
115 SignatureCreator::SignatureCreator() : sign_context_(NULL) { 116 SignatureCreator::SignatureCreator() : sign_context_(NULL) {
116 EnsureNSSInit(); 117 EnsureNSSInit();
117 } 118 }
118 119
119 } // namespace crypto 120 } // namespace crypto
OLDNEW
« no previous file with comments | « crypto/sha2.cc ('k') | crypto/signature_creator_openssl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698