1 /* 2 * Copyright (c) 2021 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 #include "net/dcsctp/packet/crc32c.h" 11 12 #include <cstdint> 13 14 #include "third_party/crc32c/src/include/crc32c/crc32c.h" 15 16 namespace dcsctp { 17 GenerateCrc32C(rtc::ArrayView<const uint8_t> data)18uint32_t GenerateCrc32C(rtc::ArrayView<const uint8_t> data) { 19 uint32_t crc32c = crc32c_value(data.data(), data.size()); 20 21 // Byte swapping for little endian byte order: 22 uint8_t byte0 = crc32c; 23 uint8_t byte1 = crc32c >> 8; 24 uint8_t byte2 = crc32c >> 16; 25 uint8_t byte3 = crc32c >> 24; 26 crc32c = ((byte0 << 24) | (byte1 << 16) | (byte2 << 8) | byte3); 27 return crc32c; 28 } 29 } // namespace dcsctp 30