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

asymmetric_encrypt() UDF does not work with external RSA public key

Details

    • Yes

    Description

      asymmetric_encrypt() can be used to encrypt a string using both RSA public and private keys. If the public key is generated using create_asymmetric_pub_key(), it works fine, but if an external RSA public key generated from openssl rsa is used, it throws an error.

      Please find steps below to repeat the problem:

       

      mysql> CREATE TABLE key_holder (priv varchar(2000), pub varchar(2000));
      Query OK, 0 rows affected (0.06 sec)
      
      mysql> 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'));
      Query OK, 1 row affected (0.03 sec)
      
      mysql> SELECT priv FROM key_holder INTO @external_priv;
      Query OK, 1 row affected (0.01 sec)
      
      mysql> SELECT pub FROM key_holder INTO @external_pub;
      Query OK, 1 row affected (0.00 sec)
      
      mysql> SET @str='Aaa';
      Query OK, 0 rows affected (0.00 sec)
      
      mysql> SET @ciphertext=asymmetric_encrypt('RSA',@str,@external_pub);
      ERROR 3200 (HY000): asymmetric_encrypt<string> UDF failed; cannot import RSA key from PEM PUBLIC KEY: error:0909006C:PEM routines:get_name:no start line
      
      mysql> SET @pub=create_asymmetric_pub_key('RSA',@external_priv);
      Query OK, 0 rows affected (0.00 sec)
      
      mysql> SET @ciphertext=asymmetric_encrypt('RSA',@str,@pub);
      Query OK, 0 rows affected (0.00 sec)

       

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - Not Specified
                  Not Specified
                  Logged:
                  Time Spent - 30 minutes
                  30m

                  Smart Checklist