Comments (2)
For my point of view validate
function should throw
(aka return a Result::Err) when some validations fail.
If you need to know also the info, we can split the "parse" and the "validation" phase into 2 function call. Something like
let cwt: Cwt = decode_cwt(data).unwrap();
match cwt.validate() {
Ok(_) => { },
Err(err) => { .... },
}
As shortcut
fn validate(data: &str) -> Result<(), ValidationError> {
let cwt: Cwt = decode_cwt(data).unwrap(); // this error could be transformed into a ValidationError using a dedicated variant
cwt.validate()
}
from dgc.
Regarding this problem I've seen that CwtHeader
has kid
and alg
declared as Option
s but it seems to me that if any of those information are missing it should be considered an error.
3.2 Structure of the payload
[...]
The integrity and authenticity of origin of payload data MUST be verifiable by the Verifier. To
provide this mechanism, the issuer of MUST sign the CWT using an asymmetric electronic
signature scheme as defined in the COSE specification (RFC 8152).
For the parsing and verification I agree with @allevo that they should be in two separate functions.
I would also add that given that the decode_cwt
function returns a Cwt
should be declared as a static method of the Cwt
struct. This counts also for validate
which directly interactes with its data.
I my mind, one should be able to write Cwt::decode(data)?.verify(trust_list) == SignatureValidity::Valid
Also it might be a good idea to rename the Cwt
struct as we are not parsing a generic CWT but a specific one that contains an HCERT.
EDIT: I missed the discussion on #8, I'll talk about this last part over there
from dgc.
Related Issues (20)
- Implement a method to extract the current test/vaccine/recovery data from a `DgcContainer` HOT 1
- Support tests ES/2DCode/raw/100[123].json HOT 1
- Add support for rulesets (business rules) for additional validation of certificates
- Add helpers to easily fetch public keys from the Italian trustlist HOT 1
- `fn` in `DgcCertName` should be an `Option<String>`
- Rename all "cryptic" fields into more descriptive names
- FYI: Legal use for this parser HOT 4
- Failing tests with (maybe) wrong data HOT 1
- Use ciborium impl of Value::into_ HOT 2
- C bindings HOT 3
- Support new validations for Italy HOT 1
- Remove ciborium fork from dependencies
- Use the restricted subset of validation tests HOT 2
- Inserire l'apposito header User-agent nelle richieste verso le API
- Add more examples
- Refine documentation
- Complete triage using official testing data
- Implement `FromStr` for `Cwt` HOT 11
- Implement `Display` for all the structs
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dgc.