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

Side by Side Diff: crypto/rsa_private_key_openssl.cc

Issue 18697003: Introduce RSAPrivateKey::SignDigest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
« crypto/rsa_private_key.h ('K') | « crypto/rsa_private_key_nss.cc ('k') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/rsa_private_key.h" 5 #include "crypto/rsa_private_key.h"
6 6
7 #include <openssl/evp.h> 7 #include <openssl/evp.h>
8 #include <openssl/pkcs12.h> 8 #include <openssl/pkcs12.h>
9 #include <openssl/rsa.h> 9 #include <openssl/rsa.h>
10 10
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } 116 }
117 117
118 bool RSAPrivateKey::ExportPrivateKey(std::vector<uint8>* output) const { 118 bool RSAPrivateKey::ExportPrivateKey(std::vector<uint8>* output) const {
119 return ExportKey(key_, i2d_PKCS8PrivateKeyInfo_bio, output); 119 return ExportKey(key_, i2d_PKCS8PrivateKeyInfo_bio, output);
120 } 120 }
121 121
122 bool RSAPrivateKey::ExportPublicKey(std::vector<uint8>* output) const { 122 bool RSAPrivateKey::ExportPublicKey(std::vector<uint8>* output) const {
123 return ExportKey(key_, i2d_PUBKEY_bio, output); 123 return ExportKey(key_, i2d_PUBKEY_bio, output);
124 } 124 }
125 125
126 bool RSAPrivateKey::SignDigest(const std::vector<uint8>& digest,
127 std::vector<uint8>* output) const {
128 RSA* rsa = EVP_PKEY_get1_RSA(key_);
129 if (!rsa)
130 return false;
131 output->resize(RSA_size(rsa));
132 unsigned int size;
133 return RSA_sign(NID_sha1, &digest[0], digest.size(), &(*output)[0], &size,
134 rsa);
135 }
136
126 } // namespace crypto 137 } // namespace crypto
OLDNEW
« crypto/rsa_private_key.h ('K') | « crypto/rsa_private_key_nss.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698