Bring over the WWDC 2023 CryptoKit API (#181)

Motivation

WWDC has arrived! 🎉 As part of the celebration, let's
bring Crypto up to speed with the new CryptoKit API surface.

Modifications

Substantial new docstrings
HPKE support

Result

WWDC 2023 support.
This commit is contained in:
Cory Benfield authored and GitHub committed 2023-06-13 18:27:01 +01:00
1 parent 940a631a68
commit c433cd3341
58 files changed
+3989 -502

No files matched your search

@@ -16,16 +16,35 @@
#else
import Foundation
/// A protocol defining requirements for Message Authentication Codes
/// A type that represents a message authentication code.
public protocol MessageAuthenticationCode: Hashable, ContiguousBytes, CustomStringConvertible, Sequence where Element == UInt8 {
/// The number of bytes in the message authentication code.
var byteCount: Int { get }
}
extension MessageAuthenticationCode {
/// Returns a Boolean value indicating whether two message authentication
/// codes are equal.
///
/// - Parameters:
/// - lhs: The first message authentication code to compare.
/// - rhs: The second message authentication code to compare.
///
/// - Returns: A Boolean value that’s `true` if the message authentication
/// codes are equivalent.
public static func == (lhs: Self, rhs: Self) -> Bool {
return safeCompare(lhs, rhs)
}
/// Returns a Boolean value indicating whether a message authentication code
/// is equivalent to a collection of binary data.
///
/// - Parameters:
/// - lhs: A message authentication code to compare.
/// - rhs: A collection of binary data to compare.
///
/// - Returns: A Boolean value that’s `true` if the message authentication
/// code and the collection of binary data are equivalent.
public static func == <D: DataProtocol>(lhs: Self, rhs: D) -> Bool {
if rhs.regions.count != 1 {
let rhsContiguous = Data(rhs)