Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

These methods can just use Self #11

Merged
merged 2 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/linux-pr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Rust
name: Rust PR Linux

on:
pull_request:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows-pr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Rust
name: Rust PR Windows

on:
pull_request:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cas-lib"
version = "0.2.42"
version = "0.2.43"
edition = "2021"
description = "Core lib for CAS"
license = "Apache-2.0"
Expand Down
15 changes: 3 additions & 12 deletions src/asymmetric/cas_rsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ impl CASRSAEncryption for CASRSA {
fn sign_threadpool(private_key: String, hash: Vec<u8>) -> Vec<u8> {
let (sender, receiver) = mpsc::channel();
rayon::spawn(move || {
let private_key =
RsaPrivateKey::from_pkcs8_pem(&private_key).expect("failed to generate a key");
let signed_data = private_key
.sign(Pkcs1v15Sign::new_unprefixed(), &hash)
.unwrap();
let signed_data = Self::sign(private_key, hash);
sender.send(signed_data);
});
let signed_data = receiver.recv().unwrap();
Expand All @@ -89,13 +85,8 @@ impl CASRSAEncryption for CASRSA {
fn verify_threadpool(public_key: String, hash: Vec<u8>, signed_text: Vec<u8>) -> bool {
let (sender, receiver) = mpsc::channel();
rayon::spawn(move || {
let public_key = RsaPublicKey::from_pkcs1_pem(&public_key).unwrap();
let verified = public_key.verify(
Pkcs1v15Sign::new_unprefixed(),
&hash,
&signed_text,
);
sender.send(verified.is_err());
let verified = Self::verify(public_key, hash, signed_text);
sender.send(verified);
});
let verified = receiver.recv().unwrap();
if verified == false {
Expand Down
Loading