mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
Revert "Keystore 2.0 SPI: Move keymint spec to security namespace." Revert "Keystore 2.0: Move keymint spec to security namespace." Revert "Keystore 2.0: Move keymint spec to security namespace." Revert "Move keymint to android.hardware.security." Revert "Configure CF to start KeyMint service by default." Revert "Move keymint to android.hardware.security." Revert "Move keymint to android.hardware.security." Revert submission 1522123-move_keymint Reason for revert: Build breakage Bug: 175345910 Bug: 171429297 Reverted Changes: Ief0e9884a:Keystore 2.0: Move keymint spec to security namesp... Idb54e8846:Keystore 2.0: Move keymint spec to security namesp... I9f70db0e4:Remove references to keymint1 I2b4ce3349:Keystore 2.0 SPI: Move keymint spec to security na... I2498073aa:Move keymint to android.hardware.security. I098711e7d:Move keymint to android.hardware.security. I3ec8d70fe:Configure CF to start KeyMint service by default. Icbb373c50:Move keymint to android.hardware.security. I86bccf40e:Move keymint to android.hardware.security. Change-Id: I160cae568ed6b15698bd0af0b19c6c949528762d
64 lines
2.2 KiB
C++
64 lines
2.2 KiB
C++
/*
|
|
* Copyright 2017 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#ifndef HARDWARE_INTERFACES_KEYMINT_1_0_SUPPORT_OPENSSL_UTILS_H_
|
|
#define HARDWARE_INTERFACES_KEYMINT_1_0_SUPPORT_OPENSSL_UTILS_H_
|
|
|
|
#include <android/hardware/keymint/Digest.h>
|
|
|
|
#include <openssl/evp.h>
|
|
#include <openssl/x509.h>
|
|
|
|
template <typename T, void (*F)(T*)>
|
|
struct UniquePtrDeleter {
|
|
void operator()(T* p) const { F(p); }
|
|
};
|
|
|
|
typedef UniquePtrDeleter<EVP_PKEY, EVP_PKEY_free> EVP_PKEY_Delete;
|
|
|
|
#define MAKE_OPENSSL_PTR_TYPE(type) \
|
|
typedef std::unique_ptr<type, UniquePtrDeleter<type, type##_free>> type##_Ptr;
|
|
|
|
MAKE_OPENSSL_PTR_TYPE(ASN1_OBJECT)
|
|
MAKE_OPENSSL_PTR_TYPE(EVP_PKEY)
|
|
MAKE_OPENSSL_PTR_TYPE(RSA)
|
|
MAKE_OPENSSL_PTR_TYPE(X509)
|
|
MAKE_OPENSSL_PTR_TYPE(BN_CTX)
|
|
|
|
typedef std::unique_ptr<BIGNUM, UniquePtrDeleter<BIGNUM, BN_free>> BIGNUM_Ptr;
|
|
|
|
inline const EVP_MD* openssl_digest(android::hardware::keymint::Digest digest) {
|
|
switch (digest) {
|
|
case android::hardware::keymint::Digest::NONE:
|
|
return nullptr;
|
|
case android::hardware::keymint::Digest::MD5:
|
|
return EVP_md5();
|
|
case android::hardware::keymint::Digest::SHA1:
|
|
return EVP_sha1();
|
|
case android::hardware::keymint::Digest::SHA_2_224:
|
|
return EVP_sha224();
|
|
case android::hardware::keymint::Digest::SHA_2_256:
|
|
return EVP_sha256();
|
|
case android::hardware::keymint::Digest::SHA_2_384:
|
|
return EVP_sha384();
|
|
case android::hardware::keymint::Digest::SHA_2_512:
|
|
return EVP_sha512();
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
#endif // HARDWARE_INTERFACES_KEYMINT_1_0_SUPPORT_OPENSSL_UTILS_H_
|