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

Side by Side Diff: crypto/signature_creator_openssl.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/signature_creator_nss.cc ('k') | crypto/signature_creator_unittest.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 <openssl/evp.h> 7 #include <openssl/evp.h>
8 #include <openssl/rsa.h> 8 #include <openssl/rsa.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.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/openssl_util.h" 15 #include "crypto/openssl_util.h"
15 #include "crypto/rsa_private_key.h" 16 #include "crypto/rsa_private_key.h"
16 #include "crypto/scoped_openssl_types.h" 17 #include "crypto/scoped_openssl_types.h"
17 18
18 namespace crypto { 19 namespace crypto {
19 20
20 namespace { 21 namespace {
21 22
22 const EVP_MD* ToOpenSSLDigest(SignatureCreator::HashAlgorithm hash_alg) { 23 const EVP_MD* ToOpenSSLDigest(SignatureCreator::HashAlgorithm hash_alg) {
23 switch (hash_alg) { 24 switch (hash_alg) {
(...skipping 14 matching lines...) Expand all
38 } 39 }
39 return NID_undef; 40 return NID_undef;
40 } 41 }
41 42
42 } // namespace 43 } // namespace
43 44
44 // static 45 // static
45 SignatureCreator* SignatureCreator::Create(RSAPrivateKey* key, 46 SignatureCreator* SignatureCreator::Create(RSAPrivateKey* key,
46 HashAlgorithm hash_alg) { 47 HashAlgorithm hash_alg) {
47 OpenSSLErrStackTracer err_tracer(FROM_HERE); 48 OpenSSLErrStackTracer err_tracer(FROM_HERE);
48 scoped_ptr<SignatureCreator> result(new SignatureCreator); 49 std::unique_ptr<SignatureCreator> result(new SignatureCreator);
49 const EVP_MD* const digest = ToOpenSSLDigest(hash_alg); 50 const EVP_MD* const digest = ToOpenSSLDigest(hash_alg);
50 DCHECK(digest); 51 DCHECK(digest);
51 if (!digest) { 52 if (!digest) {
52 return NULL; 53 return NULL;
53 } 54 }
54 if (!EVP_DigestSignInit(result->sign_context_, NULL, digest, NULL, 55 if (!EVP_DigestSignInit(result->sign_context_, NULL, digest, NULL,
55 key->key())) { 56 key->key())) {
56 return NULL; 57 return NULL;
57 } 58 }
58 return result.release(); 59 return result.release();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // Sign it. 107 // Sign it.
107 if (!EVP_DigestSignFinal(sign_context_, signature->data(), &len)) { 108 if (!EVP_DigestSignFinal(sign_context_, signature->data(), &len)) {
108 signature->clear(); 109 signature->clear();
109 return false; 110 return false;
110 } 111 }
111 signature->resize(len); 112 signature->resize(len);
112 return true; 113 return true;
113 } 114 }
114 115
115 } // namespace crypto 116 } // namespace crypto
OLDNEW
« no previous file with comments | « crypto/signature_creator_nss.cc ('k') | crypto/signature_creator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698