blob: 93a04a99473fffa6cb08e9bc966efaf01b87a803 [file] [log] [blame]
Shawn Willden2c8dd3e2014-09-18 15:16:31 -06001/*
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_DSA_KEY_H_
18#define SYSTEM_KEYMASTER_DSA_KEY_H_
19
20#include <openssl/dsa.h>
21
22#include "asymmetric_key.h"
23
24namespace keymaster {
25
26class DsaKey : public AsymmetricKey {
27 public:
28 static DsaKey* GenerateKey(const AuthorizationSet& key_description, const Logger& logger,
29 keymaster_error_t* error);
30 static DsaKey* ImportKey(const AuthorizationSet& key_description, EVP_PKEY* pkey,
31 const Logger& logger, keymaster_error_t* error);
32 DsaKey(const UnencryptedKeyBlob& blob, const Logger& logger, keymaster_error_t* error);
33
Shawn Willden96599212014-09-26 12:07:44 -060034 virtual Operation* CreateOperation(keymaster_purpose_t purpose, keymaster_error_t* error);
Shawn Willden2c8dd3e2014-09-18 15:16:31 -060035
36 private:
37 DsaKey(DSA* dsa_key, const AuthorizationSet auths, const Logger& logger)
38 : AsymmetricKey(auths, logger), dsa_key_(dsa_key) {}
39
40 virtual int evp_key_type() { return EVP_PKEY_DSA; }
41 virtual bool InternalToEvp(EVP_PKEY* pkey) const;
42 virtual bool EvpToInternal(const EVP_PKEY* pkey);
43
44 struct DSA_Delete {
45 void operator()(DSA* p) { DSA_free(p); }
46 };
47
48 UniquePtr<DSA, DSA_Delete> dsa_key_;
49};
50
51} // namespace keymaster
52
53#endif // SYSTEM_KEYMASTER_DSA_KEY_H_