blob: bb0e275ed0e72344e6840fdfa8837bd7a3bf9829 [file] [log] [blame]
David Zeuthenab3e5652019-10-28 13:32:48 -04001/*
2 * Copyright (c) 2019, The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef SYSTEM_SECURITY_IDENTITY_UTIL_H_
18#define SYSTEM_SECURITY_IDENTITY_UTIL_H_
19
20#include <string>
21#include <vector>
22
23#include <android/hardware/identity/1.0/IIdentityCredentialStore.h>
24#include <android/hardware/identity/1.0/types.h>
25#include <binder/Status.h>
26
27namespace android {
28namespace security {
29namespace identity {
30
31using ::std::optional;
32using ::std::string;
33using ::std::vector;
34
35using ::android::binder::Status;
36using ::android::hardware::identity::V1_0::Result;
37
38Status halResultToGenericError(const Result& result);
39
40// Helper function to atomically write |data| into file at |path|.
41//
42// Returns true on success, false on error.
43//
44bool fileSetContents(const string& path, const vector<uint8_t>& data);
45
46// Helper function which reads contents offile at |path| into |data|.
47//
48// Returns nothing on error, the content on success.
49//
50optional<vector<uint8_t>> fileGetContents(const string& path);
51
52} // namespace identity
53} // namespace security
54} // namespace android
55
56#endif // SYSTEM_SECURITY_IDENTITY_UTIL_H_