• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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 
17 #ifndef CHPP_CRC_H_
18 #define CHPP_CRC_H_
19 
20 #include <stddef.h>
21 #include <stdint.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /**
28  * Calculates IEEE CRC-32, initialized to (~crc), on an input data buffer.
29  *
30  * It is expected that the implementation be optimized based on individual
31  * platforms, e.g. by reusing HW/SW optimized CRC functionality.
32  *
33  * @param crc CRC initialization value. This may be used to calculate a CRC on
34  * daisy-chained input data. Otherwise, it can be set to zero to initialize to
35  * 0xFFFFFFFF.
36  * @param buf Input data.
37  * @param len Input data length in bytes.
38  *
39  * @return Calculated CRC-32.
40  */
41 uint32_t chppCrc32(uint32_t crc, const uint8_t *buf, size_t len);
42 
43 #ifdef __cplusplus
44 }
45 #endif
46 
47 #endif  // CHPP_CRC_H_
48