blob: 1f2e4a438703269cf18c8ab7b223f907cec09aa2 [file] [log] [blame]
Shawn Willden0d560bf2014-12-15 17:44:02 -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 "hmac_key.h"
18
19#include <openssl/err.h>
20#include <openssl/rand.h>
21
22#include "hmac_operation.h"
23
24namespace keymaster {
25
Shawn Willden8ba2a042015-05-18 08:35:28 -060026keymaster_error_t HmacKeyFactory::LoadKey(const KeymasterKeyBlob& key_material,
27 const AuthorizationSet& hw_enforced,
28 const AuthorizationSet& sw_enforced,
29 UniquePtr<Key>* key) {
30 if (!key)
31 return KM_ERROR_OUTPUT_PARAMETER_NULL;
Shawn Willdena278f612014-12-23 11:22:21 -070032
Shawn Willden8ba2a042015-05-18 08:35:28 -060033 keymaster_error_t error;
34 key->reset(new HmacKey(key_material, hw_enforced, sw_enforced, &error));
35 if (!key->get())
36 error = KM_ERROR_MEMORY_ALLOCATION_FAILED;
37 return error;
Shawn Willdenf9239632015-05-12 06:57:37 -060038}
Shawn Willdena278f612014-12-23 11:22:21 -070039
Shawn Willden0d560bf2014-12-15 17:44:02 -070040} // namespace keymaster