Current Path : /home/usr.opt/mysql57/mysql-test/r/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //home/usr.opt/mysql57/mysql-test/r/func_aes_cfb1.result |
# Tests of the AES CFB1 block mode #### cfb1 SET @IVA=REPEAT('a', 16); SET @IVB=REPEAT('b', 16); SET @KEY1=REPEAT('c', 16); SET @KEY2=REPEAT('d', 16); #### 128-cfb1 SET SESSION block_encryption_mode="aes-128-cfb1"; # must throw an error without an IV SELECT AES_ENCRYPT('a', @KEY1); ERROR 42000: Incorrect parameter count in the call to native function 'aes_encrypt' block mode dependent. Must be non-0 and non-null SELECT LENGTH(AES_ENCRYPT('a', @KEY1, @IVA)); LENGTH(AES_ENCRYPT('a', @KEY1, @IVA)) 1 block mode dependent SELECT TO_BASE64(AES_ENCRYPT('a', @KEY1, @IVA)); TO_BASE64(AES_ENCRYPT('a', @KEY1, @IVA)) eg== # must be equal SELECT 'a' = AES_DECRYPT(AES_ENCRYPT('a', @KEY1, @IVA), @KEY1, @IVA); 'a' = AES_DECRYPT(AES_ENCRYPT('a', @KEY1, @IVA), @KEY1, @IVA) 1 # must not be equal SELECT 'a' = AES_DECRYPT(AES_ENCRYPT('a',@KEY1, @IVA), @KEY1, @IVB); 'a' = AES_DECRYPT(AES_ENCRYPT('a',@KEY1, @IVA), @KEY1, @IVB) 0 SELECT 'a' = AES_DECRYPT(AES_ENCRYPT('a',@KEY1, @IVA), @KEY2, @IVA); 'a' = AES_DECRYPT(AES_ENCRYPT('a',@KEY1, @IVA), @KEY2, @IVA) 0 SELECT 'a' = AES_DECRYPT(AES_ENCRYPT('b',@KEY1, @IVA), @KEY1, @IVA); 'a' = AES_DECRYPT(AES_ENCRYPT('b',@KEY1, @IVA), @KEY1, @IVA) 0 #### 192-cfb1 SET SESSION block_encryption_mode="aes-192-cfb1"; # must throw an error without an IV SELECT AES_ENCRYPT('a', @KEY1); ERROR 42000: Incorrect parameter count in the call to native function 'aes_encrypt' # must be equal SELECT 'a' = AES_DECRYPT(AES_ENCRYPT('a',@KEY1, @IVA), @KEY1, @IVA); 'a' = AES_DECRYPT(AES_ENCRYPT('a',@KEY1, @IVA), @KEY1, @IVA) 1 # must not be equal SELECT 'a' = AES_DECRYPT(AES_ENCRYPT('a',@KEY1, @IVA), @KEY1, @IVB); 'a' = AES_DECRYPT(AES_ENCRYPT('a',@KEY1, @IVA), @KEY1, @IVB) 0 SELECT 'a' = AES_DECRYPT(AES_ENCRYPT('a',@KEY1, @IVA), @KEY2, @IVA); 'a' = AES_DECRYPT(AES_ENCRYPT('a',@KEY1, @IVA), @KEY2, @IVA) 0 SELECT 'a' = AES_DECRYPT(AES_ENCRYPT('b',@KEY1, @IVA), @KEY1, @IVA); 'a' = AES_DECRYPT(AES_ENCRYPT('b',@KEY1, @IVA), @KEY1, @IVA) 0 #### 256-cfb1 SET SESSION block_encryption_mode="aes-256-cfb1"; # must throw an error without an IV SELECT AES_ENCRYPT('a', @KEY1); ERROR 42000: Incorrect parameter count in the call to native function 'aes_encrypt' # must be equal SELECT 'a' = AES_DECRYPT(AES_ENCRYPT('a',@KEY1, @IVA), @KEY1, @IVA); 'a' = AES_DECRYPT(AES_ENCRYPT('a',@KEY1, @IVA), @KEY1, @IVA) 1 # must not be equal SELECT 'a' = AES_DECRYPT(AES_ENCRYPT('a',@KEY1, @IVA), @KEY1, @IVB); 'a' = AES_DECRYPT(AES_ENCRYPT('a',@KEY1, @IVA), @KEY1, @IVB) 0 SELECT 'a' = AES_DECRYPT(AES_ENCRYPT('a',@KEY1, @IVA), @KEY2, @IVA); 'a' = AES_DECRYPT(AES_ENCRYPT('a',@KEY1, @IVA), @KEY2, @IVA) 0 SELECT 'a' = AES_DECRYPT(AES_ENCRYPT('b',@KEY1, @IVA), @KEY1, @IVA); 'a' = AES_DECRYPT(AES_ENCRYPT('b',@KEY1, @IVA), @KEY1, @IVA) 0 SET SESSION block_encryption_mode=DEFAULT; #### 128, 192 and 256 bit cfb1 CREATE TABLE aes_cfb1(a VARCHAR(128), b128 VARCHAR(144), b192 VARCHAR(144), b256 CHAR(144)); INSERT INTO aes_cfb1 (a) VALUES (REPEAT('a', 128)); INSERT INTO aes_cfb1 (a) VALUES (REPEAT(0x00313233, 32)); SET SESSION block_encryption_mode="aes-128-cfb1"; UPDATE aes_cfb1 SET b128 = AES_ENCRYPT(a, @KEY1, @IVA); SET SESSION block_encryption_mode="aes-192-cfb1"; UPDATE aes_cfb1 SET b192 = AES_ENCRYPT(a, @KEY1, @IVA); SET SESSION block_encryption_mode="aes-256-cfb1"; UPDATE aes_cfb1 SET b256 = AES_ENCRYPT(a, @KEY1, @IVA); # must return 0 SELECT COUNT(*) FROM aes_cfb1 WHERE b128 = b192 OR B192 = b256 OR b128=b256; COUNT(*) 0 SET SESSION block_encryption_mode="aes-256-cfb1"; # must return 2 SELECT COUNT(*) FROM aes_cfb1 WHERE a = AES_DECRYPT(b256, @KEY1, @IVA); COUNT(*) 2 # must return 0 SELECT COUNT(*) FROM aes_cfb1 WHERE a = AES_DECRYPT(b256, 'b', @IVA); COUNT(*) 0 # must return 0 SELECT COUNT(*) FROM aes_cfb1 WHERE a = AES_DECRYPT(b256, @KEY1, @IVB); COUNT(*) 0 SET SESSION block_encryption_mode="aes-192-cfb1"; # must return 2 SELECT COUNT(*) FROM aes_cfb1 WHERE a = AES_DECRYPT(b192, @KEY1, @IVA); COUNT(*) 2 # must return 0 SELECT COUNT(*) FROM aes_cfb1 WHERE a = AES_DECRYPT(b192, @KEY2, @IVA); COUNT(*) 0 # must return 0 SELECT COUNT(*) FROM aes_cfb1 WHERE a = AES_DECRYPT(b256, @KEY1, @IVB); COUNT(*) 0 SET SESSION block_encryption_mode="aes-128-cfb1"; # must return 2 SELECT COUNT(*) FROM aes_cfb1 WHERE a = AES_DECRYPT(b128, @KEY1, @IVA); COUNT(*) 2 # must return 0 SELECT COUNT(*) FROM aes_cfb1 WHERE a = AES_DECRYPT(b128, @KEY2, @IVA); COUNT(*) 0 # must return 0 SELECT COUNT(*) FROM aes_cfb1 WHERE a = AES_DECRYPT(b256, @KEY2, @IVB); COUNT(*) 0 SET SESSION block_encryption_mode=DEFAULT; DROP TABLE aes_cfb1; SET SESSION block_encryption_mode=default; # # End of 5.7 tests #