Skip to content

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

@EloiStree

Description

@EloiStree

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions