This repository has been archived by the owner on Oct 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
isolate.h
61 lines (46 loc) · 1.79 KB
/
isolate.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef P11NET_ISOLATE_H_
#define P11NET_ISOLATE_H_
#include <string>
#include <base/macros.h>
#include <brillo/secure_blob.h>
#include "p11net.h"
namespace p11net {
const size_t kIsolateCredentialBytes = 16;
// Manages a user's isolate credentials, including saving and retrieval of
// isolate credentials. Sample usage:
// IsolateCredentialManager isolate_manager;
// SecureBlob isolate_credential;
// isolate_manager.GetCurrentUserIsolateCredential(&isolate_credential);
//
// Only virtual to enable mocking in tests.
class IsolateCredentialManager {
public:
IsolateCredentialManager();
virtual ~IsolateCredentialManager();
// Get the well known credential for the default isolate.
static brillo::SecureBlob GetDefaultIsolateCredential() {
// Default isolate credential is all zeros.
return brillo::SecureBlob(kIsolateCredentialBytes);
}
// Get the isolate credential for the current user, returning true if it
// exists.
virtual bool GetCurrentUserIsolateCredential(
brillo::SecureBlob* isolate_credential);
// Get the isolate credential for the given user name, returning true if it
// exists.
virtual bool GetUserIsolateCredential(
const std::string& user,
brillo::SecureBlob* isolate_credential);
// Save the isolate credential such that it can be retrieved with
// GetUserIsolateCredential. Return true on success and false on failure.
virtual bool SaveIsolateCredential(
const std::string& user,
const brillo::SecureBlob& isolate_credential);
private:
DISALLOW_COPY_AND_ASSIGN(IsolateCredentialManager);
};
} // namespace p11net
#endif // P11NET_ISOLATE_H_