Android-cuttlefish cvd tool
key.h
Go to the documentation of this file.
1/*
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
6 * in compliance with the License. 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#pragma once
18
19#include <string>
20
21#include <openssl/evp.h>
22
23#include "key_type.pb.h"
24
25namespace adb {
26namespace crypto {
27
28// Class that represents a public/private key pair.
29class Key {
30 public:
31 explicit Key(bssl::UniquePtr<EVP_PKEY>&& pkey, adb::proto::KeyType type)
32 : pkey_(std::move(pkey)), key_type_(type) {}
33 Key(Key&&) = default;
34 Key& operator=(Key&&) = default;
35
36 EVP_PKEY* GetEvpPkey() const { return pkey_.get(); }
37 adb::proto::KeyType GetKeyType() const { return key_type_; }
38 static std::string ToPEMString(EVP_PKEY* pkey);
39
40 private:
41 bssl::UniquePtr<EVP_PKEY> pkey_;
42 adb::proto::KeyType key_type_;
43}; // Key
44
45} // namespace crypto
46} // namespace adb
Definition: key.h:29
adb::proto::KeyType GetKeyType() const
Definition: key.h:37
Key(bssl::UniquePtr< EVP_PKEY > &&pkey, adb::proto::KeyType type)
Definition: key.h:31
bssl::UniquePtr< EVP_PKEY > pkey_
Definition: key.h:41
Key & operator=(Key &&)=default
static std::string ToPEMString(EVP_PKEY *pkey)
Definition: key.cpp:28
Key(Key &&)=default
EVP_PKEY * GetEvpPkey() const
Definition: key.h:36
adb::proto::KeyType key_type_
Definition: key.h:42
Definition: key.h:25
Definition: logging.h:464
uint8_t type
Definition: pairing_connection.h:0