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

Side by Side Diff: base/crypto/encryptor.h

Issue 6805019: Move crypto files out of base, to a top level directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fixes comments by eroman Created 9 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 | Annotate | Revision Log
« no previous file with comments | « base/crypto/cssm_init.cc ('k') | base/crypto/encryptor_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef BASE_CRYPTO_ENCRYPTOR_H_
6 #define BASE_CRYPTO_ENCRYPTOR_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/base_api.h"
12 #include "build/build_config.h"
13
14 #if defined(USE_NSS)
15 #include "base/crypto/scoped_nss_types.h"
16 #elif defined(OS_WIN)
17 #include "base/crypto/scoped_capi_types.h"
18 #endif
19
20 namespace base {
21
22 class SymmetricKey;
23
24 class BASE_API Encryptor {
25 public:
26 enum Mode {
27 CBC
28 };
29 Encryptor();
30 virtual ~Encryptor();
31
32 // Initializes the encryptor using |key| and |iv|. Returns false if either the
33 // key or the initialization vector cannot be used.
34 bool Init(SymmetricKey* key, Mode mode, const std::string& iv);
35
36 // Encrypts |plaintext| into |ciphertext|.
37 bool Encrypt(const std::string& plaintext, std::string* ciphertext);
38
39 // Decrypts |ciphertext| into |plaintext|.
40 bool Decrypt(const std::string& ciphertext, std::string* plaintext);
41
42 // TODO(albertb): Support streaming encryption.
43
44 private:
45 SymmetricKey* key_;
46 Mode mode_;
47
48 #if defined(USE_OPENSSL)
49 bool Crypt(bool encrypt, // Pass true to encrypt, false to decrypt.
50 const std::string& input,
51 std::string* output);
52 std::string iv_;
53 #elif defined(USE_NSS)
54 ScopedPK11Slot slot_;
55 ScopedSECItem param_;
56 #elif defined(OS_MACOSX)
57 bool Crypt(int /*CCOperation*/ op,
58 const std::string& input,
59 std::string* output);
60
61 std::string iv_;
62 #elif defined(OS_WIN)
63 ScopedHCRYPTKEY capi_key_;
64 DWORD block_size_;
65 #endif
66 };
67
68 } // namespace base
69
70 #endif // BASE_CRYPTO_ENCRYPTOR_H_
OLDNEW
« no previous file with comments | « base/crypto/cssm_init.cc ('k') | base/crypto/encryptor_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698