| Index: crypto/secure_hash_default.cc
|
| diff --git a/crypto/secure_hash_openssl.cc b/crypto/secure_hash_default.cc
|
| similarity index 67%
|
| copy from crypto/secure_hash_openssl.cc
|
| copy to crypto/secure_hash_default.cc
|
| index a2997b4d03e35542d51a5640c88e742fe0991f2e..262beb7fd18329c48c66978ec3a85e04fba45570 100644
|
| --- a/crypto/secure_hash_openssl.cc
|
| +++ b/crypto/secure_hash_default.cc
|
| @@ -4,50 +4,45 @@
|
|
|
| #include "crypto/secure_hash.h"
|
|
|
| -#include <openssl/crypto.h>
|
| -#include <openssl/sha.h>
|
| -
|
| -#include "base/basictypes.h"
|
| #include "base/logging.h"
|
| #include "base/pickle.h"
|
| -#include "crypto/openssl_util.h"
|
| +#include "crypto/third_party/nss/chromium-blapi.h"
|
| +#include "crypto/third_party/nss/chromium-sha256.h"
|
|
|
| namespace crypto {
|
|
|
| namespace {
|
|
|
| -const char kSHA256Descriptor[] = "OpenSSL";
|
| +const char kSHA256Descriptor[] = "NSS";
|
|
|
| -class SecureHashSHA256OpenSSL : public SecureHash {
|
| +class SecureHashSHA256NSS : public SecureHash {
|
| public:
|
| static const int kSecureHashVersion = 1;
|
|
|
| - SecureHashSHA256OpenSSL() {
|
| - SHA256_Init(&ctx_);
|
| + SecureHashSHA256NSS() {
|
| + SHA256_Begin(&ctx_);
|
| }
|
|
|
| - ~SecureHashSHA256OpenSSL() override {
|
| - OPENSSL_cleanse(&ctx_, sizeof(ctx_));
|
| - }
|
| + ~SecureHashSHA256NSS() override { memset(&ctx_, 0, sizeof(ctx_)); }
|
|
|
| + // SecureHash implementation:
|
| void Update(const void* input, size_t len) override {
|
| SHA256_Update(&ctx_, static_cast<const unsigned char*>(input), len);
|
| }
|
|
|
| void Finish(void* output, size_t len) override {
|
| - ScopedOpenSSLSafeSizeBuffer<SHA256_DIGEST_LENGTH> result(
|
| - static_cast<unsigned char*>(output), len);
|
| - SHA256_Final(result.safe_buffer(), &ctx_);
|
| + SHA256_End(&ctx_, static_cast<unsigned char*>(output), NULL,
|
| + static_cast<unsigned int>(len));
|
| }
|
|
|
| bool Serialize(Pickle* pickle) override;
|
| bool Deserialize(PickleIterator* data_iterator) override;
|
|
|
| private:
|
| - SHA256_CTX ctx_;
|
| + SHA256Context ctx_;
|
| };
|
|
|
| -bool SecureHashSHA256OpenSSL::Serialize(Pickle* pickle) {
|
| +bool SecureHashSHA256NSS::Serialize(Pickle* pickle) {
|
| if (!pickle)
|
| return false;
|
|
|
| @@ -60,10 +55,7 @@ bool SecureHashSHA256OpenSSL::Serialize(Pickle* pickle) {
|
| return true;
|
| }
|
|
|
| -bool SecureHashSHA256OpenSSL::Deserialize(PickleIterator* data_iterator) {
|
| - if (!data_iterator)
|
| - return false;
|
| -
|
| +bool SecureHashSHA256NSS::Deserialize(PickleIterator* data_iterator) {
|
| int version;
|
| if (!data_iterator->ReadInt(&version))
|
| return false;
|
| @@ -92,7 +84,7 @@ bool SecureHashSHA256OpenSSL::Deserialize(PickleIterator* data_iterator) {
|
| SecureHash* SecureHash::Create(Algorithm algorithm) {
|
| switch (algorithm) {
|
| case SHA256:
|
| - return new SecureHashSHA256OpenSSL();
|
| + return new SecureHashSHA256NSS();
|
| default:
|
| NOTIMPLEMENTED();
|
| return NULL;
|
|
|