-
Notifications
You must be signed in to change notification settings - Fork 6.6k
/
cryptohome_util.h
47 lines (36 loc) · 1.92 KB
/
cryptohome_util.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
// Copyright 2017 The Chromium 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 ASH_COMPONENTS_CRYPTOHOME_CRYPTOHOME_UTIL_H_
#define ASH_COMPONENTS_CRYPTOHOME_CRYPTOHOME_UTIL_H_
#include <string>
#include "ash/components/cryptohome/common_types.h"
#include "ash/components/cryptohome/cryptohome_parameters.h"
#include "base/component_export.h"
#include "chromeos/ash/components/dbus/cryptohome/key.pb.h"
#include "chromeos/ash/components/dbus/cryptohome/rpc.pb.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
namespace cryptohome {
// Converts the key metadata in a RepeatedPtrField<cryptohome::KeyData> into
// cryptohome::KeyDefinition format. Note that this is temporarily extracted
// from GetKeyDataReplyToKeyDefinitions() to facilitate the transition from
// cryptohome_util.cc to userdataauth_util.cc.
std::vector<KeyDefinition> RepeatedKeyDataToKeyDefinitions(
const google::protobuf::RepeatedPtrField<KeyData>& key_data);
// Converts the single key metadata from cryptohome::KeyData> to
// cryptohome::KeyDefinition format.
COMPONENT_EXPORT(ASH_COMPONENTS_CRYPTOHOME)
KeyDefinition KeyDataToKeyDefinition(const KeyData& key_data);
// Creates an AuthorizationRequest from the given secret and label.
COMPONENT_EXPORT(ASH_COMPONENTS_CRYPTOHOME)
AuthorizationRequest CreateAuthorizationRequest(const KeyLabel& label,
const std::string& secret);
// Creates an AuthorizationRequest from the given key definition.
COMPONENT_EXPORT(ASH_COMPONENTS_CRYPTOHOME)
AuthorizationRequest CreateAuthorizationRequestFromKeyDef(
const KeyDefinition& key_def);
// Converts the given KeyDefinition to a Key.
COMPONENT_EXPORT(ASH_COMPONENTS_CRYPTOHOME)
void KeyDefinitionToKey(const KeyDefinition& key_def, Key* key);
} // namespace cryptohome
#endif // ASH_COMPONENTS_CRYPTOHOME_CRYPTOHOME_UTIL_H_