1 /* 2 * Copyright (c) 2020-2022 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 SECURITY_APP_VERIFY_HAP_H 17 #define SECURITY_APP_VERIFY_HAP_H 18 19 #include "app_centraldirectory.h" 20 #include "app_common.h" 21 #include "app_file.h" 22 #include "app_verify.h" 23 #include "app_verify_pub.h" 24 #include "mbedtls/pk.h" 25 26 #ifdef __cplusplus 27 #if __cplusplus 28 extern "C" { 29 #endif 30 #endif 31 32 #define ALGORITHM_MASK 0x000f 33 #define ALGORITHM_SHA256 0x01 34 #define ALGORITHM_SHA384 0x02 35 #define ALGORITHM_SHA512 0x03 36 #define ALGORITHM_PKCS1_SHA256 0x04 37 #define ALGORITHM_PKCS1_SHA384 0x05 38 #define ALGORITHM_PKCS1_SHA512 0x06 39 40 #define HAP_DIGEST_PRIFIX_LEN 5 41 #define MAX_OID_LENGTH 128 42 #define HASH_BLOB_LEN (1024 * 1024) 43 #define ONCE_READ_LEN (1024 * 64) 44 #define HASH_ALG_SHA256 MBEDTLS_MD_SHA256 /* sha256 */ 45 #define HASH_ALG_SHA384 MBEDTLS_MD_SHA384 /* sha384 */ 46 #define HASH_ALG_SHA512 MBEDTLS_MD_SHA512 /* sha512 */ 47 48 bool VerifyIntegrityChunk(int digestAlgorithm, int fp, const SignatureInfo *signInfo, const HapBuf *actualDigest); 49 int GetDigestAlgorithmId(unsigned int signAlgorithm); 50 51 #ifdef __cplusplus 52 #if __cplusplus 53 } 54 #endif 55 #endif 56 57 #endif 58