1 /* 2 * Copyright (c) 2025-2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef ATTESTATION_CERT_EXT_H 17 #define ATTESTATION_CERT_EXT_H 18 #include <stdbool.h> 19 20 #include "openssl/x509.h" 21 #include "openssl/asn1t.h" 22 #include "cf_result.h" 23 #include "attestation_common.h" 24 #include "hm_attestation_cert_ext_type.h" 25 26 typedef struct AttestationRecord AttestationRecord; 27 28 typedef struct DeviceCertSecureLevel DeviceCertSecureLevel; 29 30 typedef struct AttestationRecord DeviceActivationCertExt; 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 CfResult GetHmAttestationRecord(const X509 *cert, AttestationRecord **record); 37 38 CfResult GetDeviceCertSecureLevel(const X509 *cert, DeviceCertSecureLevel **devSecLevel); 39 40 CfResult GetDeviceActivationCertExt(const X509 *cert, DeviceActivationCertExt **record); 41 42 CfResult GetDeviceSecureLevel(DeviceCertSecureLevel *record, int *version, int *level); 43 44 void FreeHmAttestationRecord(AttestationRecord *record); 45 46 void FreeAttestationDevSecLevel(DeviceCertSecureLevel *record); 47 48 void FreeDeviveActiveCertExt(DeviceActivationCertExt *record); 49 50 CfResult GetAttestCertExt(AttestationRecord *record, HmAttestationCertExtType type, HmAttestationCertExt *ext); 51 52 #ifdef __cplusplus 53 } 54 #endif 55 56 #endif // ATTESTATION_CERT_EXT_H 57