prople_crypto/keysecure/
objects.rs1use rst_common::standard::serde::{self, Deserialize, Serialize};
3
4use crate::keysecure::types::constants::*;
5use crate::passphrase::kdf_params::KdfParams as PassphraseKDFParams;
6
7#[derive(Debug, Serialize, Deserialize, Clone)]
9#[serde(crate = "self::serde")]
10pub struct KeySecureCryptoParams {
11 pub nonce: String,
12}
13
14#[derive(Debug, Serialize, Deserialize, Clone)]
24#[serde(crate = "self::serde")]
25pub struct KeySecureCrypto {
26 pub cipher: String,
27
28 #[serde(rename = "cipherText")]
29 pub cipher_text: String,
30
31 #[serde(rename = "cipherParams")]
32 pub cipher_params: KeySecureCryptoParams,
33
34 pub kdf: String,
35
36 #[serde(rename = "kdfParams")]
37 pub kdf_params: KdfParams,
38}
39
40impl KeySecureCrypto {
41 pub fn new(nonce: String, ciphertext: String, kdf_params: KdfParams) -> Self {
42 let params = KeySecureCryptoParams { nonce };
43 Self {
44 cipher: CRYPTO_CIPHER_ALGO.to_string(),
45 cipher_text: ciphertext,
46 cipher_params: params,
47 kdf: KDF_ALGO.to_string(),
48 kdf_params,
49 }
50 }
51}
52
53#[derive(Debug, Serialize, Deserialize, Clone)]
55#[serde(crate = "self::serde")]
56pub struct KdfParams {
57 pub params: PassphraseKDFParams,
58 pub salt: String,
59}
60
61impl KdfParams {
62 pub fn new(params: PassphraseKDFParams, salt: String) -> Self {
63 Self { params, salt }
64 }
65}