Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate use of binary protocol instead of JSON for data transfer #38

Open
heartsucker opened this issue May 16, 2017 · 4 comments
Open

Comments

@heartsucker
Copy link
Contributor

A disadvantage of JSON is that in order to verify the metadata, it has to be parsed first. It would be better to use a binary protocol that lets us treat the signed field as raw bytes until after we verify it. Then, do a second round of parsing on the trusted data. For example:

message SignedRootMetadata {
  repeated Signature signature = 1;
  bytes signed = 2;   
}

message Signature {
    bytes keyid = 1;
    bytes sig = 2;
}

Followed by

let signed_root = parse_signed_root(bytes_from_network)?;
let root = if verify(signed_root) {
    parse_root(signed_root.signed)?
} else {
    return Err("oh dear")
}
// do stuff with root

Protobufs were used in the example here, but they may not be deterministic, so something like ASN.1 / DER would need to be used.

This is motivated by my dislike of parsers being allowed to work on any more untrusted data than necessary.

@tarcieri
Copy link

For what it's worth, I've been working on a "Merkelized Protobufs" format which can be bidirectionally transcoded to (T)JSON while preserving the same content hashes:

https://github.com/zcred/zser

DER would certainly be more in line with IETF SOP.

@heartsucker
Copy link
Contributor Author

Interesting stuff. I think this ticket is a long ways off since making everything work in JSON is a pain enough as it is.

@heartsucker
Copy link
Contributor Author

Depends on #73

@heartsucker
Copy link
Contributor Author

I'm not implementing anything yet, but I had to do a huge rewrite because the current API backed me into a corner. The rewrite includes support for non-JSON formats, and implementation should be trivial now that Serialize and Deserialize are correctly implemented. Work tracked in rewrite branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants