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

Unified Diff: crypto/encryptor_mac.cc

Issue 10543146: Use NSS for symmetric key crypto operations on Windows and Mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removed DEPS; rebased Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « crypto/encryptor.h ('k') | crypto/encryptor_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto/encryptor_mac.cc
diff --git a/crypto/encryptor_mac.cc b/crypto/encryptor_mac.cc
deleted file mode 100644
index 6be373a5d92028052b1de94d5f1d85739b54ffcf..0000000000000000000000000000000000000000
--- a/crypto/encryptor_mac.cc
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "crypto/encryptor.h"
-
-#include <CommonCrypto/CommonCryptor.h>
-
-#include "base/logging.h"
-#include "base/string_util.h"
-#include "crypto/symmetric_key.h"
-
-namespace crypto {
-
-Encryptor::Encryptor()
- : key_(NULL),
- mode_(CBC) {
-}
-
-Encryptor::~Encryptor() {
-}
-
-bool Encryptor::Init(SymmetricKey* key,
- Mode mode,
- const base::StringPiece& iv) {
- DCHECK(key);
- DCHECK_EQ(CBC, mode) << "Unsupported mode of operation";
- CSSM_DATA raw_key = key->cssm_data();
- if (raw_key.Length != kCCKeySizeAES128 &&
- raw_key.Length != kCCKeySizeAES192 &&
- raw_key.Length != kCCKeySizeAES256)
- return false;
- if (iv.size() != kCCBlockSizeAES128)
- return false;
-
- key_ = key;
- mode_ = mode;
- iv.CopyToString(&iv_);
- return true;
-}
-
-bool Encryptor::Crypt(int /*CCOperation*/ op,
- const base::StringPiece& input,
- std::string* output) {
- DCHECK(key_);
- CSSM_DATA raw_key = key_->cssm_data();
- // CommonCryptor.h: "A general rule for the size of the output buffer which
- // must be provided by the caller is that for block ciphers, the output
- // length is never larger than the input length plus the block size."
-
- size_t output_size = input.size() + iv_.size();
- CHECK_GT(output_size, 0u);
- CHECK_GT(output_size + 1, input.size());
- CCCryptorStatus err = CCCrypt(op,
- kCCAlgorithmAES128,
- kCCOptionPKCS7Padding,
- raw_key.Data, raw_key.Length,
- iv_.data(),
- input.data(), input.size(),
- WriteInto(output, output_size + 1),
- output_size,
- &output_size);
- if (err) {
- output->clear();
- LOG(ERROR) << "CCCrypt returned " << err;
- return false;
- }
- output->resize(output_size);
- return true;
-}
-
-bool Encryptor::Encrypt(const base::StringPiece& plaintext,
- std::string* ciphertext) {
- CHECK(!plaintext.empty() || (mode_ == CBC));
- return Crypt(kCCEncrypt, plaintext, ciphertext);
-}
-
-bool Encryptor::Decrypt(const base::StringPiece& ciphertext,
- std::string* plaintext) {
- CHECK(!ciphertext.empty());
- return Crypt(kCCDecrypt, ciphertext, plaintext);
-}
-
-} // namespace crypto
« no previous file with comments | « crypto/encryptor.h ('k') | crypto/encryptor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698