Server IP : 185.86.78.101 / Your IP : 216.73.216.213 Web Server : Apache System : Linux 675867-vds-valikoshka1996.gmhost.pp.ua 5.4.0-150-generic #167-Ubuntu SMP Mon May 15 17:35:05 UTC 2023 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /www/server/mysql/mysql-test/r/ |
Upload File : |
############################################## #### Tests for ECB Mode ############################################## SET @IV='abcd1234efgh5678'; SET @KEYS=REPEAT('c', 16); SET @ENCSTR=REPEAT('d', 256); "--------------------------------------------" ##################### Testing with mode : aes-128-ecb SET SESSION block_encryption_mode="aes-128-ecb"; SELECT @@global.block_encryption_mode; @@global.block_encryption_mode aes-128-ecb SELECT @@session.block_encryption_mode; @@session.block_encryption_mode aes-128-ecb ####Test without tables should return 1 SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR; AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR 1 should return 1 SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR; AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR 1 Warnings: Warning 1618 <IV> option ignored Warning 1618 <IV> option ignored ####Test with InnoDB tables DROP TABLE IF EXISTS t1; Warnings: Note 1051 Unknown table 'test.t1' CREATE TABLE t1(f1 varchar(256)); INSERT INTO t1 values(@ENCSTR); should return 1 SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR FROM t1; AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR 1 should return 1 SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR FROM t1; AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR 1 Warnings: Warning 1618 <IV> option ignored Warning 1618 <IV> option ignored ####Test with MyISAM tables DROP TABLE IF EXISTS t1; CREATE TABLE t1(f1 varchar(256)) engine=MyISAM; INSERT INTO t1 values(@ENCSTR); should return 1 SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR FROM t1; AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR 1 should return 1 SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR FROM t1; AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR 1 Warnings: Warning 1618 <IV> option ignored Warning 1618 <IV> option ignored "--------------------------------------------" ##################### Testing with mode : aes-192-ecb SET SESSION block_encryption_mode="aes-192-ecb"; SELECT @@global.block_encryption_mode; @@global.block_encryption_mode aes-128-ecb SELECT @@session.block_encryption_mode; @@session.block_encryption_mode aes-192-ecb ####Test without tables should return 1 SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR; AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR 1 should return 1 SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR; AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR 1 Warnings: Warning 1618 <IV> option ignored Warning 1618 <IV> option ignored ####Test with InnoDB tables DROP TABLE IF EXISTS t1; CREATE TABLE t1(f1 varchar(256)); INSERT INTO t1 values(@ENCSTR); should return 1 SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR FROM t1; AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR 1 should return 1 SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR FROM t1; AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR 1 Warnings: Warning 1618 <IV> option ignored Warning 1618 <IV> option ignored ####Test with MyISAM tables DROP TABLE IF EXISTS t1; CREATE TABLE t1(f1 varchar(256)) engine=MyISAM; INSERT INTO t1 values(@ENCSTR); should return 1 SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR FROM t1; AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR 1 should return 1 SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR FROM t1; AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR 1 Warnings: Warning 1618 <IV> option ignored Warning 1618 <IV> option ignored "--------------------------------------------" ##################### Testing with mode : aes-256-ecb SET SESSION block_encryption_mode="aes-256-ecb"; should return 1 SELECT @@global.block_encryption_mode; @@global.block_encryption_mode aes-128-ecb should return 1 SELECT @@session.block_encryption_mode; @@session.block_encryption_mode aes-256-ecb ####Test without tables should return 1 SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR; AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR 1 should return 1 SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR; AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR 1 Warnings: Warning 1618 <IV> option ignored Warning 1618 <IV> option ignored ####Test with InnoDB tables DROP TABLE IF EXISTS t1; CREATE TABLE t1(f1 varchar(256)); INSERT INTO t1 values(@ENCSTR); should return 1 SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR FROM t1; AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR 1 should return 1 SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR FROM t1; AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR 1 Warnings: Warning 1618 <IV> option ignored Warning 1618 <IV> option ignored ####Test with MyISAM tables DROP TABLE IF EXISTS t1; CREATE TABLE t1(f1 varchar(256)) engine=MyISAM; INSERT INTO t1 values(@ENCSTR); should return 1 SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR FROM t1; AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR 1 should return 1 SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR FROM t1; AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR 1 Warnings: Warning 1618 <IV> option ignored Warning 1618 <IV> option ignored DROP TABLE IF EXISTS t1; "--------------------------------------------" ############################################## "Tests related to RANDOM_BYTES()" ############################################## should return 1 select LENGTH(RANDOM_BYTES(1))=1; LENGTH(RANDOM_BYTES(1))=1 1 should return 1 select LENGTH(RANDOM_BYTES(1024))=1024; LENGTH(RANDOM_BYTES(1024))=1024 1 SET @KEYS=RANDOM_BYTES(1); SET @KEYS=RANDOM_BYTES(1024); select RANDOM_BYTES(0); ERROR 22003: length value is out of range in 'random_bytes' select RANDOM_BYTES(1025); ERROR 22003: length value is out of range in 'random_bytes' ############################################## "Tests related to boundary values of IV" ############################################## SET @IV='abcdefghijklmnophelloworldworldisgreat'; SET @IV1='abcdefghijklmnopqrstuvwxyz'; SET @KEYS='helloworld'; SET @ENCSTR=REPEAT('K',100); SET @@session.block_encryption_mode = 'aes-256-cbc'; should return 1 select AES_ENCRYPT(@ENCSTR, @KEYS, @IV)=AES_ENCRYPT(@ENCSTR, @KEYS, @IV1); AES_ENCRYPT(@ENCSTR, @KEYS, @IV)=AES_ENCRYPT(@ENCSTR, @KEYS, @IV1) 1 ############################################## "Few negative tests with invalid/different keys and IV" ############################################## SET @IV='ijkl8765mnop2345'; SET @KEYS='helloworld1234567890'; SET @ENCSTR=REPEAT('J',255); SET @@session.block_encryption_mode = 'aes-128-ecb'; DROP TABLE IF EXISTS t1; Warnings: Note 1051 Unknown table 'test.t1' CREATE TABLE t1(f1 varchar(256)); INSERT INTO t1 values(AES_ENCRYPT(@ENCSTR, @KEYS, @IV)); Warnings: Warning 1618 <IV> option ignored Warning 3237 AES key size should be 16 bytes length or secure KDF methods hkdf or pbkdf2_hmac should be used, please provide exact AES key size or use KDF methods for better security. Combination1.............. SET @@session.block_encryption_mode = 'aes-192-ecb'; should return NULL SELECT AES_DECRYPT(f1, @KEYS, @IV)=@ENCSTR FROM t1; AES_DECRYPT(f1, @KEYS, @IV)=@ENCSTR NULL Warnings: Warning 1618 <IV> option ignored Combination2.............. SET @@session.block_encryption_mode = 'aes-256-ecb'; should return NULL SELECT AES_DECRYPT(f1, @KEYS, @IV)=@ENCSTR FROM t1; AES_DECRYPT(f1, @KEYS, @IV)=@ENCSTR NULL Warnings: Warning 1618 <IV> option ignored Combination3.............. SET @@session.block_encryption_mode = 'aes-128-cbc'; should return 0 or NULL SELECT COALESCE (AES_DECRYPT(f1, @KEYS, @IV)=@ENCSTR,0) FROM t1; COALESCE (AES_DECRYPT(f1, @KEYS, @IV)=@ENCSTR,0) 0 Combination4.............. SET @@session.block_encryption_mode = 'aes-192-cbc'; should return NULL SELECT AES_DECRYPT(f1, @KEYS, @IV)=@ENCSTR FROM t1; AES_DECRYPT(f1, @KEYS, @IV)=@ENCSTR NULL Combination5.............. SET @@session.block_encryption_mode = 'aes-256-cbc'; should return NULL SELECT AES_DECRYPT(f1, @KEYS, @IV)=@ENCSTR FROM t1; AES_DECRYPT(f1, @KEYS, @IV)=@ENCSTR NULL Combination6.............. SET @@session.block_encryption_mode = 'aes-128-ecb'; should return 1 SELECT AES_DECRYPT(f1, @KEYS, @IV)=@ENCSTR FROM t1; AES_DECRYPT(f1, @KEYS, @IV)=@ENCSTR 1 Warnings: Warning 1618 <IV> option ignored SET @@session.block_encryption_mode = DEFAULT; DROP TABLE IF EXISTS t1; # # End of 5.7 tests #