#public-key #rsa #encryption #asn-1 #encryption-key #pkcs1

rsa_public_encrypt_pkcs1

RSA PKCS#1 encryption from ASN.1 DER encoded public key in pure Rust

4 releases (breaking)

Uses old Rust 2015

0.4.0 Jul 18, 2021
0.3.0 Dec 28, 2020
0.2.0 Nov 6, 2018
0.1.0 Nov 4, 2018

#1583 in Cryptography

Download history 128/week @ 2024-03-13 293/week @ 2024-03-20 147/week @ 2024-03-27 127/week @ 2024-04-03 102/week @ 2024-04-10 144/week @ 2024-04-17 159/week @ 2024-04-24 135/week @ 2024-05-01 123/week @ 2024-05-08 111/week @ 2024-05-15 136/week @ 2024-05-22 156/week @ 2024-05-29 115/week @ 2024-06-05 134/week @ 2024-06-12 126/week @ 2024-06-19 110/week @ 2024-06-26

509 downloads per month
Used in 8 crates (3 directly)

ISC license

10KB
80 lines

rsa_public_encrypt_pkcs1

crate documentation Travis status

RSA PKCS#1 public key encryption using an ASN.1 DER encoded public key.

Implemented in pure Rust based on RFC8017: PKCS #1: RSA Cryptography Specifications Version 2.2, section 7.2.1 RSAES-PKCS1-v1_5.

Warning: Use at your own risk. Not extensively tested or reviewed. May contain serious bugs.

See also: rust-openssl. Example code written for rust-openssl:

        let mut shared_e = vec![0; rsa.size() as usize];
        let mut token_e = vec![0; rsa.size() as usize];
        rsa.public_encrypt(&shared, &mut shared_e, Padding::PKCS1)?;
        rsa.public_encrypt(&packet.verify_token.data, &mut token_e, Padding::PKCS1)?;

could be rewritten using this crate as follows:

        let shared_e = rsa_public_encrypt_pkcs1::encrypt(&packet.public_key.data, &shared)?;
        let token_e = rsa_public_encrypt_pkcs1::encrypt(&packet.public_key.data, &packet.verify_token.data)?;

Dependencies

~2–2.9MB
~55K SLoC