EloiStree / HelloRustBending

(V) ( ' ;,,;) (V)
0 stars 0 forks source link

Topic: How to sign and verified RSA key 1024 in Rust? #30

Open EloiStree opened 3 months ago

EloiStree commented 3 months ago

Fail 1: https://github.com/EloiStree/HelloRustBending/tree/main/RustEveryDay/2024_06_17_D8_SignRSA Fail 2: https://github.com/EloiStree/HelloRustBending/tree/main/RustEveryDay/2024_06_21_D12_SignVerifiedFailed

I am blocked... I just try to do this in C#

public static byte[] SignData(byte[] data, RSAParameters privateKey)
{

    using (RSA rsa = RSA.Create())
    {
        rsa.ImportParameters(privateKey);
         return rsa.SignData(data, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
    }
}
public static bool VerifySignature(byte[] data, byte[] signature, RSAParameters publicKey)
{
    using (RSA rsa = RSA.Create())
    {
        rsa.ImportParameters(publicKey);
        return rsa.VerifyData(data, signature, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
    }
}

But RSA on Crate is ... tricky.

EloiStree commented 3 months ago

Ring ? https://docs.rs/ring/latest/ring/index.html Open SSL ? https://docs.rs/openssl/latest/openssl/

EloiStree commented 3 months ago

Maybe call C# or Java code

image

https://youtu.be/1H9FHhRntAk

EloiStree commented 3 months ago

Or... Maybe do a Websocket server with all the RSA tools in usable from Rust.