Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-35382

Inconsistent Results with AES_ENCRYPT Across Different Column Orders in MariaDB

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Not a Bug
    • 11.4.0
    • N/A
    • Encryption
    • None

    Description

      In MariaDB, a discrepancy is observed when using AES_ENCRYPT with different column orders in a SELECT query. Although both queries involve the same columns, changing only the order of AES_ENCRYPT(c0, c1) results in different values being returned.

      Reproduce Steps:

      -- Step 1: Create table t0 and insert data
      CREATE TABLE t0 (c0 FLOAT, c1 TINYTEXT, c2 BIGINT, c3 JSON);
      INSERT INTO t0 (c0, c1, c2, c3) VALUES (7.067433631098911e+36, '1TGAacOFset8W4YVv5R1ooLqy5SoaufBPU4Jc9rYa3OZRG7hmnv8f2wjA0CjFbBWaY5DY1ulYnR3jK5cWf68QkmeOPNEk2otH9bZaZ03qEeNal6ENGlPUX3vT9EwDPIKqde1Q96f66VjNGbTcRFIz0ErIZPPpbvflcFH7OyYKMLdSTxMgQKpIqK7qQNvWtkQVWfxrBGbaWU2aOkP', 2967729209041341472, 'true');
       
      -- Step 2: Query AES_ENCRYPT with different column orders
      MariaDB [test]> SELECT (AES_ENCRYPT(c0,c1)), c2, c3 FROM t0;
      +----------------------+---------------------+------+
      | (AES_ENCRYPT(c0,c1)) | c2                  | c3   |
      +----------------------+---------------------+------+
      cS!Nhk%           | 2967729209041341472 | true |
      +----------------------+---------------------+------+
      1 row in set (0.042 sec)
       
      MariaDB [test]> SELECT c2, c3, (AES_ENCRYPT(c0,c1)) FROM t0;
      +---------------------+------+----------------------+
      | c2                  | c3   | (AES_ENCRYPT(c0,c1)) |
      +---------------------+------+----------------------+
      cS!Nhk%           |72 | true | 
      +---------------------+------+----------------------+
      1 row in set (0.013 sec)
      

      Expected Result:
      Both queries should return the same values in the corresponding columns, as the AES_ENCRYPT(c0, c1) function and other columns are identical.

      Actual Result:
      The two queries return different results for (AES_ENCRYPT(c0, c1)). In the first query.

      Attachments

        Activity

          People

            serg Sergei Golubchik
            dwenking Wenqian Deng
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.