Bump dependencies

This commit is contained in:
asonix
2021-08-01 15:12:06 -05:00
parent 0f370de1a0
commit 8474640278
8 changed files with 256 additions and 225 deletions
+4 -4
View File
@@ -11,13 +11,13 @@ use async_rwlock::RwLock;
use log::info;
use lru::LruCache;
use rand::thread_rng;
use rsa::{RSAPrivateKey, RSAPublicKey};
use rsa::{RsaPrivateKey, RsaPublicKey};
use std::sync::Arc;
#[derive(Clone)]
pub struct State {
pub(crate) public_key: RSAPublicKey,
private_key: RSAPrivateKey,
pub(crate) public_key: RsaPublicKey,
private_key: RsaPrivateKey,
config: Config,
object_cache: Arc<RwLock<LruCache<Url, Url>>>,
node_cache: NodeCache,
@@ -81,7 +81,7 @@ impl State {
info!("Generating new keys");
let key = web::block(move || {
let mut rng = thread_rng();
RSAPrivateKey::new(&mut rng, 4096)
RsaPrivateKey::new(&mut rng, 4096)
})
.await??;
+8 -6
View File
@@ -1,8 +1,10 @@
use crate::{config::Config, error::MyError};
use activitystreams::url::Url;
use actix_web::web::Bytes;
use rsa::RSAPrivateKey;
use rsa_pem::KeyExt;
use rsa::{
pkcs8::{FromPrivateKey, ToPrivateKey},
RsaPrivateKey,
};
use sled::Tree;
use std::{collections::HashMap, sync::Arc, time::SystemTime};
use uuid::Uuid;
@@ -582,11 +584,11 @@ impl Db {
.await
}
pub(crate) async fn private_key(&self) -> Result<Option<RSAPrivateKey>, MyError> {
pub(crate) async fn private_key(&self) -> Result<Option<RsaPrivateKey>, MyError> {
self.unblock(|inner| {
if let Some(ivec) = inner.settings.get("private-key")? {
let key_str = String::from_utf8_lossy(&ivec);
let key = RSAPrivateKey::from_pem_pkcs8(&key_str)?;
let key = RsaPrivateKey::from_pkcs8_pem(&key_str)?;
Ok(Some(key))
} else {
@@ -598,9 +600,9 @@ impl Db {
pub(crate) async fn update_private_key(
&self,
private_key: &RSAPrivateKey,
private_key: &RsaPrivateKey,
) -> Result<(), MyError> {
let pem_pkcs8 = private_key.to_pem_pkcs8()?;
let pem_pkcs8 = private_key.to_pkcs8_pem()?;
self.unblock(move |inner| {
inner
+1 -2
View File
@@ -6,7 +6,6 @@ use actix_web::{
};
use http_signature_normalization_actix::PrepareSignError;
use log::error;
use rsa_pem::KeyError;
use std::{convert::Infallible, fmt::Debug, io::Error};
#[derive(Debug, thiserror::Error)]
@@ -18,7 +17,7 @@ pub(crate) enum MyError {
Config(#[from] config::ConfigError),
#[error("Couldn't parse key, {0}")]
Key(#[from] KeyError),
Pkcs8(#[from] rsa::pkcs8::Error),
#[error("Couldn't parse URI, {0}")]
Uri(#[from] ParseError),
+2 -3
View File
@@ -8,8 +8,7 @@ use activitystreams::{base::BaseExt, uri, url::Url};
use actix_web::web;
use http_signature_normalization_actix::{prelude::*, verify::DeprecatedAlgorithm};
use log::error;
use rsa::{hash::Hash, padding::PaddingScheme, PublicKey, RSAPublicKey};
use rsa_pem::KeyExt;
use rsa::{hash::Hash, padding::PaddingScheme, pkcs8::FromPublicKey, PublicKey, RsaPublicKey};
use sha2::{Digest, Sha256};
use std::{future::Future, pin::Pin};
@@ -108,7 +107,7 @@ async fn do_verify(
signature: String,
signing_string: String,
) -> Result<(), MyError> {
let public_key = RSAPublicKey::from_pem_pkcs8(public_key)?;
let public_key = RsaPublicKey::from_public_key_pem(public_key)?;
web::block(move || {
let decoded = base64::decode(signature)?;
+4 -4
View File
@@ -7,7 +7,7 @@ use awc::Client;
use chrono::{DateTime, Utc};
use http_signature_normalization_actix::prelude::*;
use log::{debug, info, warn};
use rsa::{hash::Hash, padding::PaddingScheme, RSAPrivateKey};
use rsa::{hash::Hash, padding::PaddingScheme, RsaPrivateKey};
use sha2::{Digest, Sha256};
use std::{
cell::RefCell,
@@ -148,7 +148,7 @@ pub(crate) struct Requests {
error_limit: usize,
key_id: String,
user_agent: String,
private_key: RSAPrivateKey,
private_key: RsaPrivateKey,
config: Config,
breakers: Breakers,
}
@@ -156,7 +156,7 @@ pub(crate) struct Requests {
impl Requests {
pub(crate) fn new(
key_id: String,
private_key: RSAPrivateKey,
private_key: RsaPrivateKey,
user_agent: String,
breakers: Breakers,
) -> Self {
@@ -396,7 +396,7 @@ impl Requests {
}
struct Signer {
private_key: RSAPrivateKey,
private_key: RsaPrivateKey,
}
impl Signer {
+2 -2
View File
@@ -13,7 +13,7 @@ use activitystreams::{
};
use activitystreams_ext::Ext1;
use actix_web::{web, Responder};
use rsa_pem::KeyExt;
use rsa::pkcs8::ToPublicKey;
pub(crate) async fn route(
state: web::Data<State>,
@@ -25,7 +25,7 @@ pub(crate) async fn route(
public_key: PublicKeyInner {
id: config.generate_url(UrlKind::MainKey).into(),
owner: config.generate_url(UrlKind::Actor).into(),
public_key_pem: state.public_key.to_pem_pkcs8()?,
public_key_pem: state.public_key.to_public_key_pem()?,
},
},
);