Lines Matching +full:input +full:- +full:src
9 * SPDX-License-Identifier: Apache-2.0
34 /* Initial value expected to be used at the beginning of the OpenPGP CRC-24 computation. */
37 * The CRC-24 value is stored on a 32-bit value, only the 3 least significant bytes
38 * are meaningful. Use the following mask to only keep the CRC-24 value.
75 * @brief Generic function for computing a CRC-16 without input or output
78 * Compute CRC-16 by passing in the address of the input, the input length
88 * @param src Input bytes for the computation
89 * @param len Length of the input in bytes
93 uint16_t crc16(uint16_t poly, uint16_t seed, const uint8_t *src, size_t len);
96 * @brief Generic function for computing a CRC-16 with input and output
99 * Compute CRC-16 by passing in the address of the input, the input length
101 * is the length of the buffer provided. Both input and output are reflected.
110 * - CRC-16/ANSI, CRC-16/MODBUS, CRC-16/USB, CRC-16/IBM
111 * https://reveng.sourceforge.io/crc-catalogue/16.htm#crc.cat.crc-16-modbus
116 * use 0xA001 instead of 0x8005 for CRC-16-MODBUS.
118 * @param src Input bytes for the computation
119 * @param len Length of the input in bytes
123 uint16_t crc16_reflect(uint16_t poly, uint16_t seed, const uint8_t *src, size_t len);
127 * Compute CRC 8 by passing in the address of the input, the input length
130 * @param src Input bytes for the computation
131 * @param len Length of the input in bytes
139 uint8_t crc8(const uint8_t *src, size_t len, uint8_t polynomial, uint8_t initial_value,
144 * input and output.
147 * and requires reflecting both the input and the output. It is a fast variant
148 * that runs in O(n) time, where n is the length of the input buffer.
154 * - CRC-16/CCITT, CRC-16/CCITT-TRUE, CRC-16/KERMIT
155 * https://reveng.sourceforge.io/crc-catalogue/16.htm#crc.cat.crc-16-kermit
158 * - CRC-16/X-25, CRC-16/IBM-SDLC, CRC-16/ISO-HDLC
159 * https://reveng.sourceforge.io/crc-catalogue/16.htm#crc.cat.crc-16-ibm-sdlc
162 * @note To calculate the CRC across non-contiguous blocks use the return
163 * value from block N-1 as the seed for block N.
165 * See ITU-T Recommendation V.41 (November 1988).
168 * @param src Input bytes for the computation
169 * @param len Length of the input in bytes
173 uint16_t crc16_ccitt(uint16_t seed, const uint8_t *src, size_t len);
177 * reflection of input or output.
180 * and requires no reflection on both the input and the output. It is a fast
181 * variant that runs in O(n) time, where n is the length of the input buffer.
187 * - CRC-16/XMODEM, CRC-16/ACORN, CRC-16/LTE
188 * https://reveng.sourceforge.io/crc-catalogue/16.htm#crc.cat.crc-16-xmodem
191 * - CRC16/CCITT-FALSE, CRC-16/IBM-3740, CRC-16/AUTOSAR
192 * https://reveng.sourceforge.io/crc-catalogue/16.htm#crc.cat.crc-16-ibm-3740
195 * - CRC-16/GSM
196 * https://reveng.sourceforge.io/crc-catalogue/16.htm#crc.cat.crc-16-gsm
199 * @note To calculate the CRC across non-contiguous blocks use the return
200 * value from block N-1 as the seed for block N.
202 * See ITU-T Recommendation V.41 (November 1988) (MSB first).
205 * @param src Input bytes for the computation
206 * @param len Length of the input in bytes
210 uint16_t crc16_itu_t(uint16_t seed, const uint8_t *src, size_t len);
213 * @brief Compute the ANSI (or Modbus) variant of CRC-16
215 * The ANSI variant of CRC-16 uses 0x8005 (0xA001 reflected) as its polynomial
218 * @param src Input bytes for the computation
219 * @param len Length of the input in bytes
223 static inline uint16_t crc16_ansi(const uint8_t *src, size_t len) in crc16_ansi() argument
225 return crc16_reflect(0xA001, 0xffff, src, len); in crc16_ansi()
272 * @param buf Input bytes for the computation
273 * @param len Length of the input in bytes
286 * @param buf Input bytes for the computation
287 * @param len Length of the input in bytes
294 * @brief Compute the CRC-7 checksum of a buffer.
296 * See JESD84-A441. Used by the MMC protocol. Uses 0x09 as the
301 * @param src Input bytes for the computation
302 * @param len Length of the input in bytes
306 uint8_t crc7_be(uint8_t seed, const uint8_t *src, size_t len);
309 * @brief Compute the CRC-4 checksum of a buffer.
316 * @param src Input bytes for the computation
317 * @param len Length of the input in bytes
321 uint8_t crc4_ti(uint8_t seed, const uint8_t *src, size_t len);
326 * Compute CRC 4 by passing in the address of the input, the input length
327 * and polynomial used in addition to the initial value. The input buffer
331 * @param src Input bytes for the computation
332 * @param len Length of the input in bytes
340 uint8_t crc4(const uint8_t *src, size_t len, uint8_t polynomial, uint8_t initial_value,
344 * @brief Generate an OpenPGP CRC-24 checksum as defined in RFC 4880 section 6.1.
349 * @return The CRC-24 value.
354 * @brief Update an OpenPGP CRC-24 checksum.
356 * @param crc The CRC-24 checksum that needs to be updated. The full 32-bit value of the CRC needs
361 * @return The CRC-24 value. When the last buffer of data has been processed, mask the value
372 * For 7, 8, 16 and 24-bit CRCs, the relevant @p seed and @p poly values should
373 * be passed in via the least-significant byte(s).
375 * Similarly, for 7, 8, 16 and 24-bit CRCs, the relevant result is stored in the
376 * least-significant byte(s) of the returned value.
379 * @param src Input bytes for the computation
380 * @param len Length of the input in bytes
388 static inline uint32_t crc_by_type(enum crc_type type, const uint8_t *src, size_t len, in crc_by_type() argument
394 return crc4(src, len, poly, seed, reflect); in crc_by_type()
396 return crc4_ti(seed, src, len); in crc_by_type()
398 return crc7_be(seed, src, len); in crc_by_type()
400 return crc8(src, len, poly, seed, reflect); in crc_by_type()
402 return crc8_ccitt(seed, src, len); in crc_by_type()
404 return crc8_rohc(seed, src, len); in crc_by_type()
407 return crc16_reflect(poly, seed, src, len); in crc_by_type()
409 return crc16(poly, seed, src, len); in crc_by_type()
412 return crc16_ansi(src, len); in crc_by_type()
414 return crc16_ccitt(seed, src, len); in crc_by_type()
416 return crc16_itu_t(seed, src, len); in crc_by_type()
418 uint32_t crc = crc24_pgp_update(seed, src, len); in crc_by_type()
425 return crc32_c(seed, src, len, first, last); in crc_by_type()
427 return crc32_ieee_update(seed, src, len); in crc_by_type()
433 return -1; in crc_by_type()