mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-12-23 08:32:23 +03:00
Merge branch 'jf/invite' of github.com:uqbar-dao/uqbar into jf/invite
This commit is contained in:
commit
1b9c773a55
@ -66,11 +66,7 @@ pub fn encode_keyfile(
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub fn decode_keyfile(
|
||||
keyfile: Vec<u8>,
|
||||
password: &str,
|
||||
) -> Result<Keyfile, &'static str> {
|
||||
|
||||
pub fn decode_keyfile(keyfile: Vec<u8>, password: &str) -> Result<Keyfile, &'static str> {
|
||||
let (username, routers, salt, key_enc, jtw_enc, file_enc) =
|
||||
bincode::deserialize::<(String, Vec<String>, Vec<u8>, Vec<u8>, Vec<u8>, Vec<u8>)>(&keyfile)
|
||||
.map_err(|_| "failed to deserialize keyfile")?;
|
||||
@ -92,26 +88,28 @@ pub fn decode_keyfile(
|
||||
let jwt_nonce = generic_array::GenericArray::from_slice(&jtw_enc[..12]);
|
||||
let file_nonce = generic_array::GenericArray::from_slice(&file_enc[..12]);
|
||||
|
||||
let serialized_networking_keypair: Vec<u8> = cipher.decrypt(net_nonce, &key_enc[12..])
|
||||
let serialized_networking_keypair: Vec<u8> = cipher
|
||||
.decrypt(net_nonce, &key_enc[12..])
|
||||
.map_err(|_| "failed to decrypt networking keys")?;
|
||||
|
||||
let networking_keypair = signature::Ed25519KeyPair::from_pkcs8(&serialized_networking_keypair)
|
||||
.map_err(|_| "failed to parse networking keys")?;
|
||||
|
||||
let jwt_secret_bytes: Vec<u8> = cipher.decrypt(jwt_nonce, &jtw_enc[12..])
|
||||
let jwt_secret_bytes: Vec<u8> = cipher
|
||||
.decrypt(jwt_nonce, &jtw_enc[12..])
|
||||
.map_err(|_| "failed to decrypt jwt secret")?;
|
||||
|
||||
let file_key: Vec<u8> = cipher.decrypt(file_nonce, &file_enc[12..])
|
||||
let file_key: Vec<u8> = cipher
|
||||
.decrypt(file_nonce, &file_enc[12..])
|
||||
.map_err(|_| "failed to decrypt file key")?;
|
||||
|
||||
Ok(Keyfile {
|
||||
username,
|
||||
routers,
|
||||
networking_keypair,
|
||||
jwt_secret_bytes,
|
||||
username,
|
||||
routers,
|
||||
networking_keypair,
|
||||
jwt_secret_bytes,
|
||||
file_key,
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
/// # Returns
|
||||
|
@ -1,10 +1,10 @@
|
||||
use crate::kernel::component::uq_process::types as wit;
|
||||
use ring::signature;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
sync::Arc,
|
||||
};
|
||||
use ring::signature;
|
||||
use thiserror::Error;
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user