1 /* 2 * Copyright (c) 2023 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 CF_CERT_CHAIN_VALIDATOR_H 17 #define CF_CERT_CHAIN_VALIDATOR_H 18 19 #include <stddef.h> 20 #include <stdint.h> 21 #include "cf_blob.h" 22 #include "cf_object_base.h" 23 #include "cf_result.h" 24 25 typedef struct HcfCertChainValidator HcfCertChainValidator; 26 27 typedef struct { 28 /* data format: len-value-len-value..., size of len is 2 bytes. */ 29 uint8_t *data; 30 uint32_t dataLen; 31 uint8_t count; 32 enum CfEncodingFormat format; 33 } HcfCertChainData; 34 35 struct HcfCertChainValidator { 36 struct CfObjectBase base; 37 38 /** verify the cert chain. */ 39 CfResult (*validate)(HcfCertChainValidator *self, const HcfCertChainData *certChainData); 40 41 /** Get algorithm name. */ 42 const char *(*getAlgorithm)(HcfCertChainValidator *self); 43 }; 44 45 #ifdef __cplusplus 46 extern "C" { 47 #endif 48 49 /** 50 * @brief Generate cert chain validator instance. 51 */ 52 CfResult HcfCertChainValidatorCreate(const char *algorithm, HcfCertChainValidator **pathValidator); 53 54 #ifdef __cplusplus 55 } 56 #endif 57 58 #endif // CF_CERT_CHAIN_VALIDATOR_H 59