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

Side by Side Diff: 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 | « crypto/cssm_init.cc ('k') | 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')
Property Changes:
Added: svn:eol-style
+ LF
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 CRYPTO_ENCRYPTOR_H_
6 #define CRYPTO_ENCRYPTOR_H_
7 #pragma once
8
9 #include <string>
10
11 #include "build/build_config.h"
12
13 #if defined(USE_NSS)
14 #include "crypto/scoped_nss_types.h"
15 #elif defined(OS_WIN)
16 #include "crypto/scoped_capi_types.h"
17 #endif
18
19 namespace crypto {
20
21 class SymmetricKey;
22
23 class Encryptor {
24 public:
25 enum Mode {
26 CBC
27 };
28 Encryptor();
29 virtual ~Encryptor();
30
31 // Initializes the encryptor using |key| and |iv|. Returns false if either the
32 // key or the initialization vector cannot be used.
33 bool Init(SymmetricKey* key, Mode mode, const std::string& iv);
34
35 // Encrypts |plaintext| into |ciphertext|.
36 bool Encrypt(const std::string& plaintext, std::string* ciphertext);
37
38 // Decrypts |ciphertext| into |plaintext|.
39 bool Decrypt(const std::string& ciphertext, std::string* plaintext);
40
41 // TODO(albertb): Support streaming encryption.
42
43 private:
44 SymmetricKey* key_;
45 Mode mode_;
46
47 #if defined(USE_OPENSSL)
48 bool Crypt(bool encrypt, // Pass true to encrypt, false to decrypt.
49 const std::string& input,
50 std::string* output);
51 std::string iv_;
52 #elif defined(USE_NSS)
53 ScopedPK11Slot slot_;
54 ScopedSECItem param_;
55 #elif defined(OS_MACOSX)
56 bool Crypt(int /*CCOperation*/ op,
57 const std::string& input,
58 std::string* output);
59
60 std::string iv_;
61 #elif defined(OS_WIN)
62 ScopedHCRYPTKEY capi_key_;
63 DWORD block_size_;
64 #endif
65 };
66
67 } // namespace crypto
68
69 #endif // CRYPTO_ENCRYPTOR_H_
OLDNEW
« no previous file with comments | « crypto/cssm_init.cc ('k') | crypto/encryptor_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698