Skip to content

Cannot encrypt/decrypt larger payload #2

@stsrki

Description

@stsrki

Hello, I found your project while searching for a pure C# RSA library. It works well for smaller payloads like strings and byte arrays. But as soon as the payload is larger, I get an error.

"Bytes given are longer than length of key element n (129 bytes)."

Code to reproduce:

KeyPair kp = RSA.GenerateKeyPair( 1024 );
var raw = "Private keys cannot be passed over, as they are set to private, readonly and are not part of the DataContract specified. This is to prevent incorrect asymmetric key usage.";

//These bytes are now encrypted using RSA, of the bitlength specified before.
var encrypted = RSA.Encrypt( raw, kp.public_ );
var decrypted = RSA.Decrypt( encrypted, kp.private_ );

I have tried to split it into smaller chunks and then do the EncryptBytes separately, but when I try to decrypt, I get mismatches saying

"Marker byte for padding (0xFF) not found in plain bytes...


Is there any workaround that I need to do to make it possible to encrypt and decrypt larger content?

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