-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
33 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,43 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0. | ||
|
||
import struct Foundation.Data | ||
import AwsCChecksums | ||
|
||
import struct Foundation.Data | ||
|
||
extension Data { | ||
|
||
/// Computes the CRC32 over data. | ||
/// - Parameter previousCrc32: Pass 0 in the previousCrc32 parameter as an initial value unless continuing to update a running crc in a subsequent call. | ||
public func computeCRC32(previousCrc32: UInt32 = 0) -> UInt32 { | ||
self.withUnsafeBytes { bufferPointer in | ||
return aws_checksums_crc32(bufferPointer.baseAddress?.assumingMemoryBound(to: UInt8.self), | ||
Int32(count), | ||
previousCrc32) | ||
return aws_checksums_crc32_ex( | ||
bufferPointer.baseAddress?.assumingMemoryBound(to: UInt8.self), | ||
count, | ||
previousCrc32) | ||
} | ||
} | ||
|
||
/// Computes the crc32c over data. | ||
/// - Parameter previousCrc32c: Pass 0 in the previousCrc32c parameter as an initial value unless continuing to update a running crc in a subsequent call. | ||
public func computeCRC32C(previousCrc32c: UInt32 = 0) -> UInt32 { | ||
self.withUnsafeBytes { bufferPointer in | ||
return aws_checksums_crc32c(bufferPointer.baseAddress?.assumingMemoryBound(to: UInt8.self), | ||
Int32(count), | ||
previousCrc32c) | ||
} | ||
return aws_checksums_crc32c_ex( | ||
bufferPointer.baseAddress?.assumingMemoryBound(to: UInt8.self), | ||
count, | ||
previousCrc32c) | ||
} | ||
} | ||
|
||
|
||
/// Computes the CRC64NVME over data. | ||
/// - Parameter previousCrc64Nvme: Pass 0 in the previousCrc64Nvme parameter as an initial value unless continuing to update a running crc in a subsequent call. | ||
public func computeCRC64Nvme(previousCrc64Nvme: UInt64 = 0) -> UInt64 { | ||
self.withUnsafeBytes { bufferPointer in | ||
return aws_checksums_crc64nvme_ex( | ||
bufferPointer.baseAddress?.assumingMemoryBound(to: UInt8.self), | ||
count, | ||
previousCrc64Nvme) | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule aws-c-common
updated
16 files
Submodule aws-c-io
updated
7 files
+5 −0 | include/aws/io/socket.h | |
+8 −0 | source/posix/socket.c | |
+6 −0 | source/windows/iocp/socket.c | |
+24 −0 | source/windows/windows_pki_utils.c | |
+2 −0 | tests/CMakeLists.txt | |
+14 −0 | tests/socket_test.c | |
+36 −0 | tests/tls_handler_test.c |