| OLD | NEW |
| 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/signature_creator.h" | 5 #include "crypto/signature_creator.h" |
| 6 | 6 |
| 7 #include <openssl/evp.h> | 7 #include <openssl/evp.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "crypto/openssl_util.h" | 12 #include "crypto/openssl_util.h" |
| 13 #include "crypto/rsa_private_key.h" |
| 13 | 14 |
| 14 namespace crypto { | 15 namespace crypto { |
| 15 | 16 |
| 16 // static | 17 // static |
| 17 SignatureCreator* SignatureCreator::Create(RSAPrivateKey* key) { | 18 SignatureCreator* SignatureCreator::Create(RSAPrivateKey* key) { |
| 18 OpenSSLErrStackTracer err_tracer(FROM_HERE); | 19 OpenSSLErrStackTracer err_tracer(FROM_HERE); |
| 19 scoped_ptr<SignatureCreator> result(new SignatureCreator); | 20 scoped_ptr<SignatureCreator> result(new SignatureCreator); |
| 20 result->key_ = key; | 21 result->key_ = key; |
| 21 if (!EVP_SignInit_ex(result->sign_context_, EVP_sha1(), NULL)) | 22 if (!EVP_SignInit_ex(result->sign_context_, EVP_sha1(), NULL)) |
| 22 return NULL; | 23 return NULL; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 45 int rv = EVP_SignFinal(sign_context_, vector_as_array(signature), &len, key); | 46 int rv = EVP_SignFinal(sign_context_, vector_as_array(signature), &len, key); |
| 46 if (!rv) { | 47 if (!rv) { |
| 47 signature->clear(); | 48 signature->clear(); |
| 48 return false; | 49 return false; |
| 49 } | 50 } |
| 50 signature->resize(len); | 51 signature->resize(len); |
| 51 return true; | 52 return true; |
| 52 } | 53 } |
| 53 | 54 |
| 54 } // namespace crypto | 55 } // namespace crypto |
| OLD | NEW |