forked from theupdateframework/rust-tuf
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hex encode signature and file hash values
According to theupdateframework/specification#42, the signature and file hash values should be hex encoded. Change-Id: I14710a062fae3adfc4bc6b86fbbf533ce1b97070
- Loading branch information
Showing
5 changed files
with
45 additions
and
59 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
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,18 @@ | ||
use data_encoding::HEXLOWER; | ||
use serde::{self, Deserialize, Deserializer, Serializer}; | ||
use std::result::Result; | ||
|
||
pub fn serialize<S>(value: &Vec<u8>, serializer: S) -> Result<S::Ok, S::Error> | ||
where | ||
S: Serializer, | ||
{ | ||
serializer.serialize_str(&HEXLOWER.encode(value)) | ||
} | ||
|
||
pub fn deserialize<'de, D>(deserializer: D) -> Result<Vec<u8>, D::Error> | ||
where | ||
D: Deserializer<'de>, | ||
{ | ||
let s = String::deserialize(deserializer)?; | ||
HEXLOWER.decode(s.as_bytes()).map_err(serde::de::Error::custom) | ||
} |
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 |
---|---|---|
|
@@ -119,6 +119,7 @@ pub mod metadata; | |
pub mod repository; | ||
pub mod tuf; | ||
|
||
mod format_hex; | ||
mod shims; | ||
mod util; | ||
|
||
|
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