blob: 278fa6db3ef38a1445680d460babc15f9a682774 [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 Willdena278f612014-12-23 11:22:21 -070026class HmacKeyFactory : public SymmetricKeyFactory {
27 public:
28 keymaster_algorithm_t registry_key() const { return KM_ALGORITHM_HMAC; }
29
30 virtual Key* LoadKey(const UnencryptedKeyBlob& blob, const Logger& logger,
31 keymaster_error_t* error) {
32 return new HmacKey(blob, logger, error);
33 }
34
35 virtual SymmetricKey* CreateKey(const AuthorizationSet& auths, const Logger& logger) {
36 return new HmacKey(auths, logger);
37 }
38};
39
40static KeyFactoryRegistry::Registration<HmacKeyFactory> registration;
41
Shawn Willden0d560bf2014-12-15 17:44:02 -070042} // namespace keymaster