I'm looking for deterministic asymmetric encryption (The "database search" example given in the wikipedia article is very closely related to mine):
A deterministic encryption scheme (as opposed to a probabilistic encryption scheme) is a cryptosystem which always produces the same ciphertext for a given plaintext and key, even over separate executions of the encryption algorithm. Examples of deterministic encryption algorithms include the RSA cryptosystem (without encryption padding)
The documentation for Crypt::RSA specifically says:
[..] there exists a scheme called Simple RSA[16] that provides security without padding. However, Crypt::RSA doesn't implement this scheme yet.
Is there a CPAN module that implements deterministic asymmetric encryption?
$ perl -l use strict; use warnings; use Log::Log4perl; use Crypt::RSA; my $rsa = new Crypt::RSA; my ($public, $private) = $rsa->keygen( Identity => 'Lord Macbeth <macbeth@glamis.com>', Size => 1024, Password => 'A day so foul & fair', Verbosity => 0, ) or die $rsa->errstr(); my $secret = q{Thanks for all the fish}; my $ciphertext1 = $rsa->encrypt(Message => $secret, Key => $public, Armour => 1,) || die $rsa->errstr(); my $ciphertext2 = $rsa->encrypt(Message => $secret, Key => $public, Armour => 1,) || die $rsa->errstr(); $ciphertext1 eq $ciphertext2 ? print q{deterministic} : print q{not de +terministic}; __END__ not deterministic $
Update: What would the consequences be if I disregarded the advise in the documentation:
In any event, Crypt::RSA::Primitives (without padding) should never be used directly.
my $prim = new Crypt::RSA::Primitives; my $ctxt1 = $prim->core_encrypt (Key => $public, Plaintext => $pan); my $ctxt2 = $prim->core_encrypt (Key => $public, Plaintext => $pan); $ctxt1 eq $ctxt2 ? print q{deterministic} : print q{not deterministic} +;
Prints "deterministic".
--
No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. [1]

In reply to Deterministic asymmetric encryption [Crypt::RSA] by andreas1234567

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.