-
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.
Add arbitrary::Arbitrary implementations
- Loading branch information
1 parent
8a48754
commit ec37876
Showing
5 changed files
with
42 additions
and
1 deletion.
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
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,31 @@ | ||
use arbitrary::{Arbitrary, Unstructured, Result}; | ||
|
||
use crate::ctap1; | ||
|
||
// cannot be derived because of missing impl for &[T; N] | ||
impl<'a> Arbitrary<'a> for ctap1::authenticate::Request<'a> { | ||
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self> { | ||
let control_byte = Arbitrary::arbitrary(u)?; | ||
let challenge = u.bytes(32)?.try_into().unwrap(); | ||
let app_id = u.bytes(32)?.try_into().unwrap(); | ||
let key_handle = Arbitrary::arbitrary(u)?; | ||
Ok(Self { | ||
control_byte, | ||
challenge, | ||
app_id, | ||
key_handle, | ||
}) | ||
} | ||
} | ||
|
||
// cannot be derived because of missing impl for &[T; N] | ||
impl<'a> Arbitrary<'a> for ctap1::register::Request<'a> { | ||
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self> { | ||
let challenge = u.bytes(32)?.try_into().unwrap(); | ||
let app_id = u.bytes(32)?.try_into().unwrap(); | ||
Ok(Self { | ||
challenge, | ||
app_id, | ||
}) | ||
} | ||
} |
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