blob: 685ec559ac51efc641f43ed5cb7a6aa4c835bfea [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:
32 DsaOperation(keymaster_purpose_t purpose, keymaster_digest_t digest,
33 keymaster_padding_t padding, DSA* key)
34 : Operation(purpose), dsa_key_(key), digest_(digest), padding_(padding) {}
35 ~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:
52 DsaSignOperation(keymaster_purpose_t purpose, keymaster_digest_t digest,
53 keymaster_padding_t padding, DSA* key)
54 : DsaOperation(purpose, digest, padding, key) {}
55 virtual keymaster_error_t Finish(const Buffer& signature, Buffer* output);
56};
57
58class DsaVerifyOperation : public DsaOperation {
59 public:
60 DsaVerifyOperation(keymaster_purpose_t purpose, keymaster_digest_t digest,
61 keymaster_padding_t padding, DSA* key)
62 : DsaOperation(purpose, digest, padding, key) {}
63 virtual keymaster_error_t Finish(const Buffer& signature, Buffer* output);
64};
65
66} // namespace keymaster
67
68#endif // SYSTEM_KEYMASTER_DSA_OPERATION_H_