Alexandre Lision | 51140e1 | 2013-12-02 10:54:09 -0500 | [diff] [blame] | 1 | /* |
Alexandre Lision | 7fd5d3d | 2013-12-04 13:06:40 -0500 | [diff] [blame] | 2 | Copyright (C) 2006-2013 Werner Dittmann |
Alexandre Lision | 51140e1 | 2013-12-02 10:54:09 -0500 | [diff] [blame] | 3 | |
| 4 | This program is free software: you can redistribute it and/or modify |
Alexandre Lision | 7fd5d3d | 2013-12-04 13:06:40 -0500 | [diff] [blame] | 5 | it under the terms of the GNU Lesser General Public License as published by |
Alexandre Lision | 51140e1 | 2013-12-02 10:54:09 -0500 | [diff] [blame] | 6 | the Free Software Foundation, either version 3 of the License, or |
| 7 | (at your option) any later version. |
| 8 | |
| 9 | This program is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | GNU General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU General Public License |
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | |
| 18 | #ifndef _ZRTPCRC32_H_ |
| 19 | #define _ZRTPCRC32_H_ |
| 20 | |
| 21 | /** |
| 22 | * |
| 23 | * @file ZrtpCrc32.h |
| 24 | * @brief Methods to compute the CRC32 checksum for ZRTP packets |
| 25 | * |
| 26 | * @ingroup GNU_ZRTP |
| 27 | * @{ |
| 28 | * |
| 29 | * @see ZrtpCallback |
| 30 | */ |
| 31 | |
| 32 | /** |
| 33 | * Check if a buffer matches a given CRC32 checksum. |
| 34 | * |
| 35 | * @param buffer |
| 36 | * Pointer to the data buffer. |
| 37 | * @param length |
| 38 | * Length in bytes of the data buffer. |
| 39 | * @param crc32 |
| 40 | * The CRC32 checksum. |
| 41 | * |
| 42 | * @return |
| 43 | * @c true if the CRC32 checksum matches the computed checksum of the |
| 44 | * buffer, @c false otherwise. |
| 45 | */ |
| 46 | bool zrtpCheckCksum(uint8_t *buffer, uint16_t length, uint32_t crc32); |
| 47 | |
| 48 | /** |
| 49 | * Generate a CRC32 checksum of a data buffer |
| 50 | * |
| 51 | * @param buffer |
| 52 | * Pointer to the buffer. |
| 53 | * @param length |
| 54 | * Lenght of the buffer in bytes. |
| 55 | * |
| 56 | * @return |
| 57 | * A preliminary CRC32 checksum |
| 58 | */ |
| 59 | uint32_t zrtpGenerateCksum(uint8_t *buffer, uint16_t length); |
| 60 | |
| 61 | /** |
| 62 | * Close CRC32 computation. |
| 63 | * |
| 64 | * @param crc32 |
| 65 | * A preliminary CRC32 checksum. |
| 66 | * |
| 67 | * @return |
| 68 | * The ready to use CRC32 checksum in host order. |
| 69 | */ |
| 70 | uint32_t zrtpEndCksum(uint32_t crc32); |
| 71 | |
| 72 | /** |
| 73 | * @} |
| 74 | */ |
| 75 | #endif |