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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
use super::output_request::*;
use crate::base::*;
use crate::non::*;
use cyfs_base::*;

use std::fmt;

#[derive(Debug, Clone)]
pub struct CryptoInputRequestCommon {
    // 请求路径,可为空
    pub req_path: Option<String>,

    pub source: RequestSourceInfo,

    // 用以默认行为
    pub target: Option<ObjectId>,

    pub flags: u32,
}

impl fmt::Display for CryptoInputRequestCommon {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "req_path: {:?}", self.req_path)?;
        write!(f, ", {}", self.source)?;

        if let Some(target) = &self.target {
            write!(f, ", target: {}", target.to_string())?;
        }

        write!(f, ", flags: {}", self.flags)?;

        Ok(())
    }
}

#[derive(Debug, Clone)]
pub struct CryptoSignObjectInputRequest {
    pub common: CryptoInputRequestCommon,

    pub object: NONObjectInfo,

    pub flags: u32,
}

impl fmt::Display for CryptoSignObjectInputRequest {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "common: {}", self.common)?;
        write!(f, ", object: {}", self.object)?;

        write!(f, ", flags: {}", self.flags)
    }
}

pub type CryptoSignObjectInputResponse = CryptoSignObjectOutputResponse;

#[derive(Debug, Clone)]
pub struct CryptoVerifyObjectInputRequest {
    pub common: CryptoInputRequestCommon,

    // 校验的签名位置
    pub sign_type: VerifySignType,

    // 被校验对象
    pub object: NONObjectInfo,

    // 签名来源对象
    pub sign_object: VerifyObjectType,
}

impl fmt::Display for CryptoVerifyObjectInputRequest {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "common: {}", self.common)?;

        write!(f, ", object: {}", self.object)?;
        write!(f, ", sign_type: {:?}", self.sign_type)?;
        write!(f, ", sign_object: {:?}", self.sign_object)
    }
}

pub type CryptoVerifyObjectInputResponse = CryptoVerifyObjectOutputResponse;