32 lines
653 B
Swift
32 lines
653 B
Swift
import Foundation
|
|
|
|
/**
|
|
An authenticated message to or from the device.
|
|
*/
|
|
struct SignedMessage: Equatable, Hashable {
|
|
|
|
/// The message authentication code for the message (32 bytes)
|
|
let mac: Data
|
|
|
|
/// The message content
|
|
let message: Message
|
|
|
|
/**
|
|
Create an authenticated message
|
|
- Parameter mac: The message authentication code
|
|
- Parameter content: The message content
|
|
*/
|
|
init(mac: Data, message: Message) {
|
|
self.mac = mac
|
|
self.message = message
|
|
}
|
|
}
|
|
|
|
extension SignedMessage: Codable {
|
|
|
|
enum CodingKeys: Int, CodingKey {
|
|
case mac = 1
|
|
case message = 2
|
|
}
|
|
}
|