mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-05 20:30:57 +00:00
Add test that decompressing an invalid point with serde fails
This commit is contained in:
parent
69fd268aa4
commit
d3515e8cbf
1 changed files with 8 additions and 11 deletions
19
src/curve.rs
19
src/curve.rs
|
|
@ -1643,19 +1643,16 @@ mod test {
|
||||||
assert_eq!(parsed.compress_edwards(), constants::BASE_CMPRSSD);
|
assert_eq!(parsed.compress_edwards(), constants::BASE_CMPRSSD);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
use serde_json;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn serde_json_basepoint_roundtrip() {
|
#[cfg(feature = "serde")]
|
||||||
let output = serde_json::to_string(&constants::ED25519_BASEPOINT).unwrap();
|
fn serde_cbor_decode_invalid_fails() {
|
||||||
println!("{:?}", output);
|
let mut output = serde_cbor::to_vec(&constants::ED25519_BASEPOINT).unwrap();
|
||||||
println!("{:?}", constants::BASE_CMPRSSD);
|
// CBOR apparently has two bytes of overhead for a 32-byte string.
|
||||||
let parsed: ExtendedPoint = serde_json::from_str(&output).unwrap();
|
// Set the low byte of the compressed point to 1 to make it invalid.
|
||||||
println!("{:?}", parsed);
|
output[2] = 1;
|
||||||
panic!();
|
let parsed: Result<ExtendedPoint,_> = serde_cbor::from_slice(&output);
|
||||||
|
assert!(parsed.is_err());
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue