Revert "add signing support"
It turns out we don't need this.
This reverts commit e92fc0628b.
This commit is contained in:
69
Cargo.lock
generated
69
Cargo.lock
generated
@@ -1074,15 +1074,6 @@ version = "0.4.6"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6"
|
checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "js-sys"
|
|
||||||
version = "0.3.45"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ca059e81d9486668f12d455a4ea6daa600bd408134cd17e3d3fb5a32d1f016f8"
|
|
||||||
dependencies = [
|
|
||||||
"wasm-bindgen",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kernel32-sys"
|
name = "kernel32-sys"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
@@ -1753,21 +1744,6 @@ dependencies = [
|
|||||||
"quick-error",
|
"quick-error",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ring"
|
|
||||||
version = "0.16.17"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c5911690c9b773bab7e657471afc207f3827b249a657241327e3544d79bcabdd"
|
|
||||||
dependencies = [
|
|
||||||
"cc",
|
|
||||||
"libc",
|
|
||||||
"once_cell",
|
|
||||||
"spin",
|
|
||||||
"untrusted",
|
|
||||||
"web-sys",
|
|
||||||
"winapi 0.3.9",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rmp"
|
name = "rmp"
|
||||||
version = "0.8.9"
|
version = "0.8.9"
|
||||||
@@ -1950,12 +1926,6 @@ dependencies = [
|
|||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "spin"
|
|
||||||
version = "0.5.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "standback"
|
name = "standback"
|
||||||
version = "0.2.13"
|
version = "0.2.13"
|
||||||
@@ -2031,17 +2001,6 @@ dependencies = [
|
|||||||
"unicode-xid",
|
"unicode-xid",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "sync-server"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"actix-rt",
|
|
||||||
"actix-web",
|
|
||||||
"failure",
|
|
||||||
"futures",
|
|
||||||
"taskchampion",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "synstructure"
|
name = "synstructure"
|
||||||
version = "0.12.4"
|
version = "0.12.4"
|
||||||
@@ -2063,7 +2022,6 @@ dependencies = [
|
|||||||
"kv",
|
"kv",
|
||||||
"lmdb-rkv",
|
"lmdb-rkv",
|
||||||
"proptest",
|
"proptest",
|
||||||
"ring",
|
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"tempdir",
|
"tempdir",
|
||||||
@@ -2082,6 +2040,17 @@ dependencies = [
|
|||||||
"taskchampion",
|
"taskchampion",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "taskchampion-sync-server"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"actix-rt",
|
||||||
|
"actix-web",
|
||||||
|
"failure",
|
||||||
|
"futures",
|
||||||
|
"taskchampion",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tempdir"
|
name = "tempdir"
|
||||||
version = "0.3.7"
|
version = "0.3.7"
|
||||||
@@ -2390,12 +2359,6 @@ version = "0.2.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "untrusted"
|
|
||||||
version = "0.7.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "url"
|
name = "url"
|
||||||
version = "2.2.0"
|
version = "2.2.0"
|
||||||
@@ -2505,16 +2468,6 @@ version = "0.2.68"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1d649a3145108d7d3fbcde896a468d1bd636791823c9921135218ad89be08307"
|
checksum = "1d649a3145108d7d3fbcde896a468d1bd636791823c9921135218ad89be08307"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "web-sys"
|
|
||||||
version = "0.3.45"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4bf6ef87ad7ae8008e15a355ce696bed26012b7caa21605188cfd8214ab51e2d"
|
|
||||||
dependencies = [
|
|
||||||
"js-sys",
|
|
||||||
"wasm-bindgen",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "widestring"
|
name = "widestring"
|
||||||
version = "0.4.3"
|
version = "0.4.3"
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ chrono = { version = "0.4.10", features = ["serde"] }
|
|||||||
failure = {version = "0.1.5", features = ["derive"] }
|
failure = {version = "0.1.5", features = ["derive"] }
|
||||||
kv = {version = "0.10.0", features = ["msgpack-value"]}
|
kv = {version = "0.10.0", features = ["msgpack-value"]}
|
||||||
lmdb-rkv = {version = "0.12.3"}
|
lmdb-rkv = {version = "0.12.3"}
|
||||||
ring = { version = "0.16.17", features = ["std"] }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
proptest = "0.9.4"
|
proptest = "0.9.4"
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
pub(crate) mod test;
|
pub(crate) mod test;
|
||||||
|
|
||||||
mod local;
|
mod local;
|
||||||
mod signing;
|
|
||||||
mod types;
|
mod types;
|
||||||
|
|
||||||
pub use local::LocalServer;
|
pub use local::LocalServer;
|
||||||
|
|||||||
@@ -1,87 +0,0 @@
|
|||||||
#![allow(dead_code)] // TODO: temporary until this module is used
|
|
||||||
//! This is a general wrapper around an asymmetric-key signature system.
|
|
||||||
|
|
||||||
use failure::Fallible;
|
|
||||||
use ring::{
|
|
||||||
rand,
|
|
||||||
signature::{Ed25519KeyPair, KeyPair, Signature, UnparsedPublicKey, ED25519},
|
|
||||||
};
|
|
||||||
|
|
||||||
type PublicKey = Vec<u8>;
|
|
||||||
type PrivateKey = Vec<u8>;
|
|
||||||
|
|
||||||
/// Generate a pair of (public, private) key material (in fact the private key is a keypair)
|
|
||||||
pub fn new_keypair() -> Fallible<(PublicKey, PrivateKey)> {
|
|
||||||
let rng = rand::SystemRandom::new();
|
|
||||||
let key_pkcs8 = Ed25519KeyPair::generate_pkcs8(&rng)?;
|
|
||||||
let key_pair = Ed25519KeyPair::from_pkcs8(key_pkcs8.as_ref())?;
|
|
||||||
let pub_key = key_pair.public_key();
|
|
||||||
Ok((
|
|
||||||
pub_key.as_ref().to_vec() as PublicKey,
|
|
||||||
key_pkcs8.as_ref().to_vec() as PrivateKey,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Signer {
|
|
||||||
key_pair: Ed25519KeyPair,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Signer {
|
|
||||||
/// Create a new signer, given a pkcs#8 v2 document containing the keypair.
|
|
||||||
fn new(priv_key: PrivateKey) -> Fallible<Self> {
|
|
||||||
Ok(Self {
|
|
||||||
key_pair: Ed25519KeyPair::from_pkcs8(&priv_key)?,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn sign<B: AsRef<[u8]>>(&self, message: B) -> Fallible<Signature> {
|
|
||||||
Ok(self.key_pair.sign(message.as_ref()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Verifier {
|
|
||||||
pub_key: PublicKey,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Verifier {
|
|
||||||
fn new(pub_key: PublicKey) -> Fallible<Self> {
|
|
||||||
Ok(Self { pub_key })
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn verify<B1: AsRef<[u8]>, B2: AsRef<[u8]>>(
|
|
||||||
&self,
|
|
||||||
message: B1,
|
|
||||||
signature: B2,
|
|
||||||
) -> Fallible<()> {
|
|
||||||
let pub_key = UnparsedPublicKey::new(&ED25519, &self.pub_key);
|
|
||||||
Ok(pub_key.verify(message.as_ref(), signature.as_ref())?)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod test {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_verify_ok() -> Fallible<()> {
|
|
||||||
let (public, private) = new_keypair()?;
|
|
||||||
let signer = Signer::new(private)?;
|
|
||||||
let verifier = Verifier::new(public)?;
|
|
||||||
|
|
||||||
let message = b"Hello, world";
|
|
||||||
let signature = signer.sign(message)?;
|
|
||||||
verifier.verify(message, signature)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_verify_bad_message() -> Fallible<()> {
|
|
||||||
let (public, private) = new_keypair()?;
|
|
||||||
let signer = Signer::new(private)?;
|
|
||||||
let verifier = Verifier::new(public)?;
|
|
||||||
|
|
||||||
let message = b"Hello, world";
|
|
||||||
let signature = signer.sign(message)?;
|
|
||||||
assert!(verifier.verify(b"Hello, cruel world", signature).is_err());
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user