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

Side by Side Diff: chrome/browser/chromeos/login/owner_key_utils.h

Issue 10824112: Move Chrome OS device settings stuff to chrome/browser/chromeos/settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 years, 4 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
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 CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_KEY_UTILS_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_KEY_UTILS_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/gtest_prod_util.h"
13 #include "base/memory/ref_counted.h"
14
15 class FilePath;
16
17 namespace crypto {
18 class RSAPrivateKey;
19 }
20
21 namespace chromeos {
22
23 class OwnerKeyUtilsTest;
24
25 class OwnerKeyUtils : public base::RefCounted<OwnerKeyUtils> {
26 public:
27 class Factory {
28 public:
29 virtual OwnerKeyUtils* CreateOwnerKeyUtils() = 0;
30 };
31
32 OwnerKeyUtils();
33
34 // Sets the factory used by the static method Create to create an
35 // OwnerKeyUtils. OwnerKeyUtils does not take ownership of
36 // |factory|. A value of NULL results in an OwnerKeyUtils being
37 // created directly.
38 #if defined(UNIT_TEST)
39 static void set_factory(Factory* factory) { factory_ = factory; }
40 #endif
41
42 // Creates an OwnerKeyUtils, ownership returns to the caller. If there is no
43 // Factory (the default) this creates and returns a new OwnerKeyUtils.
44 static OwnerKeyUtils* Create();
45
46 // Assumes that the file at |key_file| exists.
47 // Upon success, returns true and populates |output|. False on failure.
48 virtual bool ImportPublicKey(const FilePath& key_file,
49 std::vector<uint8>* output) = 0;
50
51 // Verfiy that |signature| is a Sha1-with-RSA signature over |data| with
52 // |public_key|
53 // Returns true if so, false on bad signature or other error.
54 virtual bool Verify(const std::string& data,
55 const std::vector<uint8> signature,
56 const std::vector<uint8> public_key) = 0;
57
58 // Sign |data| with |key| using Sha1 with RSA. If successful, return true
59 // and populate |OUT_signature|.
60 virtual bool Sign(const std::string& data,
61 std::vector<uint8>* OUT_signature,
62 crypto::RSAPrivateKey* key) = 0;
63
64 // Looks for the private key associated with |key| in the default slot,
65 // and returns it if it can be found. Returns NULL otherwise.
66 // Caller takes ownership.
67 virtual crypto::RSAPrivateKey* FindPrivateKey(
68 const std::vector<uint8>& key) = 0;
69
70 virtual FilePath GetOwnerKeyFilePath() = 0;
71
72 protected:
73 virtual ~OwnerKeyUtils();
74
75 // DER encodes public half of |pair| and writes it out to |key_file|.
76 // The blob on disk is a DER-encoded X509 SubjectPublicKeyInfo object.
77 // Returns false on error.
78 virtual bool ExportPublicKeyToFile(crypto::RSAPrivateKey* pair,
79 const FilePath& key_file) = 0;
80
81 private:
82 friend class base::RefCounted<OwnerKeyUtils>;
83 static Factory* factory_;
84
85 FRIEND_TEST_ALL_PREFIXES(OwnerKeyUtilsTest, ExportImportPublicKey);
86 };
87
88 } // namespace chromeos
89
90 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_KEY_UTILS_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/mock_signed_settings_helper.cc ('k') | chrome/browser/chromeos/login/owner_key_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698