-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
d90c41b
commit 14af663
Showing
34 changed files
with
964 additions
and
736 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
File renamed without changes.
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
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
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// | ||
// CryptoError.swift | ||
// Biscuit | ||
// | ||
// Created by Rémi Bardon on 15/09/2021. | ||
// | ||
|
||
import Foundation | ||
import BiscuitShared | ||
|
||
extension BiscuitError { | ||
|
||
internal static func crypto(_ error: CryptoError) -> Self { | ||
return Self.error(prefix: "Error in the token's cryptographic signature", error: error) | ||
} | ||
|
||
} | ||
|
||
/// Errors related to the token's cryptographic signature | ||
public enum CryptoError: Error, CustomStringConvertible { | ||
|
||
case signature(SignatureError) | ||
case sealed | ||
|
||
public var description: String { | ||
switch self { | ||
case .signature(let error): | ||
return "Failed verifying the signature: \(error)" | ||
case .sealed: | ||
return "Tried to append a block to a sealed token" | ||
} | ||
} | ||
|
||
} | ||
|
||
/// Signature errors | ||
public enum SignatureError: Error, CustomStringConvertible { | ||
|
||
// case invalidFormat | ||
case invalidSignature(String) | ||
case invalidSignatureGeneration(Error) | ||
|
||
public var description: String { | ||
switch self { | ||
// case .invalidFormat: | ||
// return "Could not parse the signature elements" | ||
case .invalidSignature(let error): | ||
return "The signature did not match: \(error)" | ||
case .invalidSignatureGeneration(let error): | ||
return "Could not sign: \(error)" | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.