blob: 2519f61214fb78d860aaab14e94f8cff6d161ade [file] [log] [blame]
Shawn Willden19fca882015-01-22 16:35:30 -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
Shawn Willden95e13822014-12-15 16:12:16 -070017#include "aes_key.h"
18
Shawn Willden907c3012014-12-08 15:51:55 -070019#include <assert.h>
20
Shawn Willden19fca882015-01-22 16:35:30 -070021#include <openssl/err.h>
22#include <openssl/rand.h>
23
Shawn Willden907c3012014-12-08 15:51:55 -070024#include "aes_operation.h"
25#include "unencrypted_key_blob.h"
Shawn Willden19fca882015-01-22 16:35:30 -070026
27namespace keymaster {
28
Shawn Willdena278f612014-12-23 11:22:21 -070029class AesKeyFactory : public SymmetricKeyFactory {
30 public:
31 keymaster_algorithm_t registry_key() const { return KM_ALGORITHM_AES; }
32
Shawn Willden567a4a02014-12-31 12:14:46 -070033 virtual Key* LoadKey(const UnencryptedKeyBlob& blob, keymaster_error_t* error) {
34 return new AesKey(blob, error);
Shawn Willdena278f612014-12-23 11:22:21 -070035 }
36
Shawn Willden567a4a02014-12-31 12:14:46 -070037 virtual SymmetricKey* CreateKey(const AuthorizationSet& auths) { return new AesKey(auths); }
Shawn Willdena278f612014-12-23 11:22:21 -070038};
Shawn Willdena278f612014-12-23 11:22:21 -070039static KeyFactoryRegistry::Registration<AesKeyFactory> registration;
40
Shawn Willden19fca882015-01-22 16:35:30 -070041} // namespace keymaster