NAME

Crypt::Bear::RSA - An RSA helper module in BearSSL

VERSION

version 0.002

SYNOPSIS

my ($public, $private) = Crypt::Bear::RSA::generate_keypair($prng, 2048);

my $ciphertext = $public_key->oaep_encrypt('sha256', $input, $prng, '');
my $plaintext = $private_key->oaep_decrypt('sha256', $ciphertext, '');

my $signature = $private_key->pkcs1_sign('sha256', $hash);
if ($public_key->pkcs1_verify('sha256', $signature) eq $hash) {
    ...
}

DESCRIPTION

RSA is supported by two classes, PublicKey and PrivateKey, each implementing half of it.

METHODS

generate_keypair($prng, $size, $exponent = 0)

This uses the given PRNG to generate a new pair of public and private RSA key of size $size, and returns both. The $exponent of the public key may be explicitly set, if not a sensible value will be picked automatically.

AUTHOR

Leon Timmermans <fawaka@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2024 by Leon Timmermans.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.