Skip to content
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion Sources/ObliviousX/Errors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2023 Apple Inc. and the SwiftNIO project authors
// Copyright (c) 2025 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
Expand All @@ -11,6 +11,7 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import Foundation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import seems unnecessary.


/// An error occured when adding oblivious encapsulation.
public struct ObliviousXError: Error, Hashable {
Expand All @@ -26,10 +27,28 @@ public struct ObliviousXError: Error, Hashable {
public static func unsupportedHPKEParameters() -> ObliviousXError {
Self.init(backing: .unsupportedHPKEParameters)
}

@inline(never)
public static func invalidODoHData() -> ObliviousXError {
Self.init(backing: .invalidODoHData)
}

@inline(never)
public static func invalidMessageType(expected: UInt8, actual: UInt8) -> ObliviousXError {
Self.init(backing: .invalidMessageType(expected, actual))
}

@inline(never)
public static func invalidPublicKey(kemID: UInt16, key: Data) -> ObliviousXError {
Self.init(backing: .invalidPublicKey(kemID, key))
}
}

extension ObliviousXError {
enum Backing: Hashable, Sendable {
case unsupportedHPKEParameters
case invalidODoHData
case invalidMessageType(UInt8, UInt8)
case invalidPublicKey(UInt16, Data)
}
}
Loading