-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve tests and error handling, add C interface meant to parse cert…
…ificates
- Loading branch information
Showing
8 changed files
with
233 additions
and
139 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,2 +1,3 @@ | ||
pub const BLS_PUBLIC_KEY_SIZE: usize = 96; | ||
pub const BLS_SIGNATURE_SIZE: usize = 48; | ||
pub const CBOR_CERTIFICATE_TAG: u64 = 55799; |
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,8 +1,57 @@ | ||
use minicbor::decode::Error; | ||
|
||
#[repr(u32)] | ||
#[derive(Debug, PartialEq)] | ||
pub enum ParserError { | ||
// Generic errors | ||
Ok = 0, | ||
CborError = 7, | ||
InvalidLabel = 27, | ||
InvalidDelegation = 28, | ||
InvalidCert = 29, | ||
NoData, | ||
InitContextEmpty, | ||
DisplayIdxOutOfRange, | ||
DisplayPageOutOfRange, | ||
UnexpectedError, | ||
NotImplemented, | ||
// Cbor | ||
CborUnexpected, | ||
CborUnexpectedEOF, | ||
CborNotCanonical, | ||
// Coin specific | ||
UnexpectedTxVersion, | ||
UnexpectedType, | ||
UnexpectedMethod, | ||
UnexpectedBufferEnd, | ||
UnexpectedValue, | ||
UnexpectedNumberItems, | ||
UnexpectedCharacters, | ||
UnexpectedField, | ||
ValueOutOfRange, | ||
InvalidAddress, | ||
// Context related errors | ||
ContextMismatch, | ||
ContextUnexpectedSize, | ||
ContextInvalidChars, | ||
ContextUnknownPrefix, | ||
// Required fields | ||
RequiredNonce, | ||
RequiredMethod, | ||
// Special codes | ||
TypeNotFound, | ||
InvalidLabel, | ||
InvalidDelegation, | ||
InvalidCertificate, | ||
InvalidTree, | ||
MiniCborError, | ||
RecursionLimitReached, | ||
} | ||
|
||
// minicibor error provides a reach | ||
// error context and also the index | ||
// at which the error occurred, | ||
// we can not handle it here, as ParserError | ||
// is send to C callers | ||
impl From<Error> for ParserError { | ||
fn from(_: Error) -> Self { | ||
Self::MiniCborError | ||
} | ||
} | ||
|
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
Oops, something went wrong.