blob: 96c2635f7fb5dc7644c93bd29d54d04d8fd85a00 [file] [log] [blame]
Thai Duongf862a762015-03-18 14:10:56 -07001/*
2 * Copyright 2014 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_KEYMASTER_EC_KEY_H_
18#define SYSTEM_KEYMASTER_EC_KEY_H_
19
20#include <openssl/ec.h>
21
22#include "asymmetric_key.h"
Shawn Willden398c1582015-05-28 00:04:06 -060023#include "openssl_utils.h"
Thai Duongf862a762015-03-18 14:10:56 -070024
25namespace keymaster {
26
Shawn Willden13e29e02015-05-08 11:02:46 -060027class EcdsaOperationFactory;
Thai Duongf862a762015-03-18 14:10:56 -070028
29class EcKey : public AsymmetricKey {
Shawn Willden0cb69422015-05-26 08:31:37 -060030 public:
31 EcKey(const AuthorizationSet& hw_enforced, const AuthorizationSet& sw_enforced,
32 keymaster_error_t* error)
33 : AsymmetricKey(hw_enforced, sw_enforced, error) {}
Thai Duongf862a762015-03-18 14:10:56 -070034
Shawn Willden0cb69422015-05-26 08:31:37 -060035 bool InternalToEvp(EVP_PKEY* pkey) const override;
36 bool EvpToInternal(const EVP_PKEY* pkey) override;
Thai Duongf862a762015-03-18 14:10:56 -070037
Shawn Willden2612fb52015-07-27 16:58:30 -060038 EC_KEY* key() const { return ec_key_.get(); }
Thai Duongf862a762015-03-18 14:10:56 -070039
Shawn Willden6270aca2015-05-26 13:12:24 -060040 protected:
41 EcKey(EC_KEY* ec_key, const AuthorizationSet& hw_enforced, const AuthorizationSet& sw_enforced,
42 keymaster_error_t* error)
43 : AsymmetricKey(hw_enforced, sw_enforced, error), ec_key_(ec_key) {}
44
45 private:
Thai Duongf862a762015-03-18 14:10:56 -070046 UniquePtr<EC_KEY, EC_Delete> ec_key_;
47};
48
49} // namespace keymaster
50
51#endif // SYSTEM_KEYMASTER_EC_KEY_H_