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
use crate::TimestampInSeconds;
use ockam_vault::SigningSecretKeyHandle;

/// Options to create an Identity key
pub struct IdentityOptions {
    pub(super) signing_secret_key_handle: SigningSecretKeyHandle,
    pub(super) revoke_all_purpose_keys: bool,
    pub(super) created_at: TimestampInSeconds,
    pub(super) expires_at: TimestampInSeconds,
}

impl IdentityOptions {
    /// Constructor
    pub fn new(
        signing_secret_key_handle: SigningSecretKeyHandle,
        revoke_all_purpose_keys: bool,
        created_at: TimestampInSeconds,
        expires_at: TimestampInSeconds,
    ) -> Self {
        Self {
            signing_secret_key_handle,
            revoke_all_purpose_keys,
            created_at,
            expires_at,
        }
    }

    /// New key
    pub fn signing_secret_key_handle(&self) -> &SigningSecretKeyHandle {
        &self.signing_secret_key_handle
    }

    /// Revoke all PurposeKeys issued by previous Identity keys
    pub fn revoke_all_purpose_keys(&self) -> bool {
        self.revoke_all_purpose_keys
    }

    /// Creation timestamp
    pub fn created_at(&self) -> TimestampInSeconds {
        self.created_at
    }

    /// Expiration timestamp
    pub fn expires_at(&self) -> TimestampInSeconds {
        self.expires_at
    }
}