Uploaded image for project: 'Percona Server for MySQL'
  1. Percona Server for MySQL
  2. PS-8147

Generated RSA keys from openssl genrsa does not match the keys generated from UDF


    • Yes


      While working on encryption UDFs a mismatch is found while generating public key from openssl genrsa from the terminal and create_asymmetric_pub_key().

      Please find the steps to repeat the problem

      1/* Generated private key */
      openssl genrsa -out rsa.private 1024
      2/*Generated public key*/
      openssl rsa -in rsa.private -out rsa.public -pubout -outform PEM
      3/* Created a table to store the generated keys */
      create table key_holder(priv varchar(2000), pub varchar(2000));
      4/* Inserted the keys */
      insert into key_holder values (LOAD_FILE('/home/mohit.joshi/PS-7044/bld_01apr_2022/install/rsa.private'), LOAD_FILE('/home/mohit.joshi/PS-7044/bld_01apr_2022/install/rsa.public'));
      5/* Saving the private key in a session variable */
      SELECT priv from key_holder into @priv;
      6/* Saving the public key in a session variable */
      SELECT pub from key_holder into @pub
      7/* Generate public key  from UDF */
      select create_asymmetric_pub_key('RSA',@priv);
      When the key generated in step 6 is matched with key generated in Step 7, a mismatch is found.
      This needs to be fixed.


      When same steps are followed to generate external DSA private/public key pair, no mismatch is found.

      1/* Generate DSA private key */
      openssl dsaparam -out dsaparam.pem 1024
      openssl gendsa -out dsaprivkey.pem dsaparam.pem
      2/* Generate DSA public key */
      openssl dsa -in dsaprivkey.pem -outform PEM -pubout -out dsapubkey.pem
      3/* Create a table to load the content from the generated key files */ 
      CREATE TABLE key_holder(priv varchar(2000), pub varchar(2000));
      INSERT INTO key_holder VALUES (LOAD_FILE('/home/mohit.joshi/PS-7044/bld_01apr_2022/install/dsaprivkey.pem'), LOAD_FILE('/home/mohit.joshi/PS-7044/bld_01apr_2022/install/dsapubkey.pem'));
      4/* Store the values of generated private/public keys in local variables */ 
      SELECT priv from key_holder into @priv;
      SELECT pub from key_holder into @pub;
      5/* Generate public key from UDF using external Private key */
      SELECT create_asymmetric_pub_key('DSA',@priv);
      DSA public key generated from Step 5 exactly matches key stored in Step 4


        Issue Links



              yura.sorokin Yura Sorokin
              mohit.joshi Mohit Joshi
              0 Vote for this issue
              2 Start watching this issue



                Time Tracking

                  Original Estimate - Not Specified
                  Not Specified
                  Remaining Estimate - Not Specified
                  Not Specified
                  Time Spent - 4 hours

                  Smart Checklist