1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use std::time::SystemTime;
use ssh_keys::PrivateKey;
use time_util::to_ms;
use index::ImageId;
use proto::{Signature, sign, SigData};
use {VPath};
#[derive(Debug, Clone)]
pub struct SignedUpload {
#[doc(hidden)]
pub path: VPath,
#[doc(hidden)]
pub image_id: ImageId,
#[doc(hidden)]
pub timestamp: SystemTime,
#[doc(hidden)]
pub signatures: Vec<Signature>,
}
pub fn sign_upload(path: &VPath, image: &ImageId, timestamp: SystemTime,
keys: &[PrivateKey])
-> SignedUpload
{
let signatures = sign(SigData {
path: path.as_ref().to_str().expect("path is string"),
image: image.as_ref(),
timestamp: to_ms(timestamp),
}, &keys);
return SignedUpload {
path: path.clone(),
image_id: image.clone(),
timestamp,
signatures,
}
}