blob: 969cb619d014b5e2c3958b2216ec84cefb396700 [file] [log] [blame]
Shawn Willden0a4df7e2014-08-28 16:09:05 -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_OPERATION_H_
18#define SYSTEM_KEYMASTER_DSA_OPERATION_H_
19
20#include <openssl/dsa.h>
21
22#include <UniquePtr.h>
23
24#include <keymaster/key_blob.h>
25
26#include "operation.h"
27
28namespace keymaster {
29
30class DsaOperation : public Operation {
31 public:
Shawn Willdenf6ca3a32014-09-11 15:11:32 -060032 DsaOperation(keymaster_purpose_t purpose, const Logger& logger, keymaster_digest_t digest,
Shawn Willden0a4df7e2014-08-28 16:09:05 -060033 keymaster_padding_t padding, DSA* key)
Shawn Willdenf6ca3a32014-09-11 15:11:32 -060034 : Operation(purpose, logger), dsa_key_(key), digest_(digest), padding_(padding) {}
Shawn Willden0a4df7e2014-08-28 16:09:05 -060035 ~DsaOperation();
36
37 virtual keymaster_error_t Begin() { return KM_ERROR_OK; }
38 virtual keymaster_error_t Update(const Buffer& input, Buffer* output);
39 virtual keymaster_error_t Abort() { return KM_ERROR_OK; }
40
41 protected:
42 keymaster_error_t StoreData(const Buffer& input);
43
44 DSA* dsa_key_;
45 keymaster_digest_t digest_;
46 keymaster_padding_t padding_;
47 Buffer data_;
48};
49
50class DsaSignOperation : public DsaOperation {
51 public:
Shawn Willdenf6ca3a32014-09-11 15:11:32 -060052 DsaSignOperation(keymaster_purpose_t purpose, const Logger& logger, keymaster_digest_t digest,
Shawn Willden0a4df7e2014-08-28 16:09:05 -060053 keymaster_padding_t padding, DSA* key)
Shawn Willdenf6ca3a32014-09-11 15:11:32 -060054 : DsaOperation(purpose, logger, digest, padding, key) {}
Shawn Willden0a4df7e2014-08-28 16:09:05 -060055 virtual keymaster_error_t Finish(const Buffer& signature, Buffer* output);
56};
57
58class DsaVerifyOperation : public DsaOperation {
59 public:
Shawn Willdenf6ca3a32014-09-11 15:11:32 -060060 DsaVerifyOperation(keymaster_purpose_t purpose, const Logger& logger, keymaster_digest_t digest,
Shawn Willden0a4df7e2014-08-28 16:09:05 -060061 keymaster_padding_t padding, DSA* key)
Shawn Willdenf6ca3a32014-09-11 15:11:32 -060062 : DsaOperation(purpose, logger, digest, padding, key) {}
Shawn Willden0a4df7e2014-08-28 16:09:05 -060063 virtual keymaster_error_t Finish(const Buffer& signature, Buffer* output);
64};
65
66} // namespace keymaster
67
68#endif // SYSTEM_KEYMASTER_DSA_OPERATION_H_