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

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

Issue 3017020: Refactoring key generation and export util code to make mocking possible. (Closed)
Patch Set: address comments per davemoore Created 10 years, 5 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/owner_key_utils.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) 2010 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 "base/basictypes.h"
9
10 // Forward declarations of NSS data structures.
11 struct SECKEYPrivateKeyStr;
12 struct SECKEYPublicKeyStr;
13 struct SECItemStr;
14
15 typedef struct SECKEYPrivateKeyStr SECKEYPrivateKey;
16 typedef struct SECKEYPublicKeyStr SECKEYPublicKey;
17 typedef struct SECItemStr SECItem;
18
19 class FilePath;
20
21 class OwnerKeyUtils {
22 public:
23 class Factory {
24 public:
25 virtual OwnerKeyUtils* CreateOwnerKeyUtils() = 0;
26 };
27
28 OwnerKeyUtils();
29 virtual ~OwnerKeyUtils();
30
31 // Sets the factory used by the static method Create to create an
32 // OwnerKeyUtils. OwnerKeyUtils does not take ownership of
33 // |factory|. A value of NULL results in an OwnerKeyUtils being
34 // created directly.
35 #if defined(UNIT_TEST)
36 static void set_factory(Factory* factory) { factory_ = factory; }
37 #endif
38
39 // Creates an OwnerKeyUtils, ownership returns to the caller. If there is no
40 // Factory (the default) this creates and returns a new OwnerKeyUtils.
41 static OwnerKeyUtils* Create();
42
43 // Generate a public/private RSA keypair and store them in the NSS database.
44 // The keys will be kKeySizeInBits in length (Recommend >= 2048 bits).
45 //
46 // Returns false on error.
47 //
48 // The caller takes ownership of both objects, which are allocated by libnss.
49 // To free them, call
50 // SECKEY_DestroyPrivateKey(*private_key_out);
51 // SECKEY_DestroyPublicKey(*public_key_out);
52 virtual bool GenerateKeyPair(SECKEYPrivateKey** private_key_out,
53 SECKEYPublicKey** public_key_out) = 0;
54
55 // DER encodes |key| and writes it out to |key_file|.
56 // The blob on disk is a DER-encoded X509 SubjectPublicKeyInfo object.
57 // Returns false on error.
58 virtual bool ExportPublicKey(SECKEYPublicKey* key,
59 const FilePath& key_file) = 0;
60
61 // Assumes that the file at |key_file| exists.
62 // Caller takes ownership of returned object; returns NULL on error.
63 // To free, call SECKEY_DestroyPublicKey.
64 virtual SECKEYPublicKey* ImportPublicKey(const FilePath& key_file) = 0;
65
66 private:
67 static Factory* factory_;
68 };
69
70 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_KEY_UTILS_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/owner_key_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698