blob: c68025234941df3b4ab38aef45384cda4efc160e [file] [log] [blame]
Shawn Willden63ac0432014-12-29 14:07:08 -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#include "operation.h"
18
19namespace keymaster {
20
21DEFINE_ABSTRACT_FACTORY_REGISTRY_INSTANCE(OperationFactory);
22
Shawn Willdend92591d2014-12-30 18:19:10 -070023bool OperationFactory::supported(keymaster_padding_t padding) const {
24 size_t padding_count;
25 const keymaster_padding_t* supported_paddings = SupportedPaddingModes(&padding_count);
26 for (size_t i = 0; i < padding_count; ++i)
27 if (padding == supported_paddings[i])
28 return true;
29 return false;
30}
31
32bool OperationFactory::supported(keymaster_block_mode_t block_mode) const {
33 size_t block_mode_count;
34 const keymaster_block_mode_t* supported_block_modes = SupportedBlockModes(&block_mode_count);
35 for (size_t i = 0; i < block_mode_count; ++i)
36 if (block_mode == supported_block_modes[i])
37 return true;
38 return false;
39}
40
41bool OperationFactory::supported(keymaster_digest_t digest) const {
42 size_t digest_count;
43 const keymaster_digest_t* supported_digests = SupportedDigests(&digest_count);
44 for (size_t i = 0; i < digest_count; ++i)
45 if (digest == supported_digests[i])
46 return true;
47 return false;
48}
49
Shawn Willden63ac0432014-12-29 14:07:08 -070050} // namespace keymaster