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

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

Issue 3078001: Update OwnerKeyUtils API (Closed)
Patch Set: address comments Created 10 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
« 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
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_KEY_UTILS_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_KEY_UTILS_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_KEY_UTILS_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_KEY_UTILS_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 10
11 // Forward declarations of NSS data structures. 11 // Forward declarations of NSS data structures.
12 struct SECKEYPrivateKeyStr; 12 struct SECKEYPrivateKeyStr;
13 struct SECKEYPublicKeyStr; 13 struct SECKEYPublicKeyStr;
14 struct SECItemStr; 14 struct SECItemStr;
15 15
16 typedef struct SECKEYPrivateKeyStr SECKEYPrivateKey; 16 typedef struct SECKEYPrivateKeyStr SECKEYPrivateKey;
17 typedef struct SECKEYPublicKeyStr SECKEYPublicKey; 17 typedef struct SECKEYPublicKeyStr SECKEYPublicKey;
18 typedef struct SECItemStr SECItem; 18 typedef struct SECItemStr SECItem;
19 19
20 class FilePath; 20 class FilePath;
21 21
22 namespace chromeos {
23
22 class OwnerKeyUtils { 24 class OwnerKeyUtils {
23 public: 25 public:
24 class Factory { 26 class Factory {
25 public: 27 public:
26 virtual OwnerKeyUtils* CreateOwnerKeyUtils() = 0; 28 virtual OwnerKeyUtils* CreateOwnerKeyUtils() = 0;
27 }; 29 };
28 30
29 OwnerKeyUtils(); 31 OwnerKeyUtils();
30 virtual ~OwnerKeyUtils(); 32 virtual ~OwnerKeyUtils();
31 33
(...skipping 14 matching lines...) Expand all
46 // 48 //
47 // Returns false on error. 49 // Returns false on error.
48 // 50 //
49 // The caller takes ownership of both objects, which are allocated by libnss. 51 // The caller takes ownership of both objects, which are allocated by libnss.
50 // To free them, call 52 // To free them, call
51 // SECKEY_DestroyPrivateKey(*private_key_out); 53 // SECKEY_DestroyPrivateKey(*private_key_out);
52 // SECKEY_DestroyPublicKey(*public_key_out); 54 // SECKEY_DestroyPublicKey(*public_key_out);
53 virtual bool GenerateKeyPair(SECKEYPrivateKey** private_key_out, 55 virtual bool GenerateKeyPair(SECKEYPrivateKey** private_key_out,
54 SECKEYPublicKey** public_key_out) = 0; 56 SECKEYPublicKey** public_key_out) = 0;
55 57
58 // DER encodes |key| and exports it via DBus.
59 // The data sent is a DER-encoded X509 SubjectPublicKeyInfo object.
60 // Returns false on error.
61 virtual bool ExportPublicKeyViaDbus(SECKEYPublicKey* key) = 0;
62
56 // DER encodes |key| and writes it out to |key_file|. 63 // DER encodes |key| and writes it out to |key_file|.
57 // The blob on disk is a DER-encoded X509 SubjectPublicKeyInfo object. 64 // The blob on disk is a DER-encoded X509 SubjectPublicKeyInfo object.
58 // Returns false on error. 65 // Returns false on error.
59 virtual bool ExportPublicKey(SECKEYPublicKey* key, 66 virtual bool ExportPublicKeyToFile(SECKEYPublicKey* key,
60 const FilePath& key_file) = 0; 67 const FilePath& key_file) = 0;
61 68
62 // Assumes that the file at |key_file| exists. 69 // Assumes that the file at |key_file| exists.
63 // Caller takes ownership of returned object; returns NULL on error. 70 // Caller takes ownership of returned object; returns NULL on error.
64 // To free, call SECKEY_DestroyPublicKey. 71 // To free, call SECKEY_DestroyPublicKey.
65 virtual SECKEYPublicKey* ImportPublicKey(const FilePath& key_file) = 0; 72 virtual SECKEYPublicKey* ImportPublicKey(const FilePath& key_file) = 0;
66 73
74
75 // Looks for the private key associated with |key| in the default slot,
76 // and returns it if it can be found. Returns NULL otherwise.
77 // To free, call SECKEY_DestroyPrivateKey.
78 virtual SECKEYPrivateKey* FindPrivateKey(SECKEYPublicKey* key) = 0;
79
80 // If something's gone wrong with key generation or key exporting, the
81 // caller may wish to nuke some keys. This will destroy key objects in
82 // memory and ALSO remove them from the NSS database.
83 virtual void DestroyKeys(SECKEYPrivateKey* private_key,
84 SECKEYPublicKey* public_key) = 0;
85
86 virtual FilePath GetOwnerKeyFilePath() = 0;
87
67 private: 88 private:
68 static Factory* factory_; 89 static Factory* factory_;
69 }; 90 };
70 91
92 } // namespace chromeos
93
71 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OWNER_KEY_UTILS_H_ 94 #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