ij> -- -- Licensed to the Apache Software Foundation (ASF) under one or more -- contributor license agreements. See the NOTICE file distributed with -- this work for additional information regarding copyright ownership. -- The ASF licenses this file to You under the Apache License, Version 2.0 -- (the "License"); you may not use this file except in compliance with -- the License. You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- ------------------------------------------------------------------------------------ -- beetle6023 : support for AES encryption algorithm -- Top level testcases grp. -- Case 1.x different feedback modes (valid - CBC,ECB,OFB,unsupported - ABC) -- 2 cases for each - creating db and recovery mode -- Case 2.x padding ( unsupported padding ) -- Case 3.x key lengths with bootpassword -- case of 128 bits, 192 bits and 256 bits and unsupported 512 bits -- mismatch keylengths (case of one keylength during creation and another -- during connecting) -- Case 4.x case of changing boot password ( covered by test - store/encryptDatabase.sql) -- Also see store/access.sql for other cases that are run with AES encryption -- Case 5.x give external encryptionKey instead of bootpassword ------------------------------------------------------------------------------------ -- 1.1.1 AES - CBC connect 'jdbc:derby:encdb;create=true;dataEncryption=true;encryptionAlgorithm=AES/CBC/NoPadding;bootPassword=Thursday'; ij> autocommit off; ij> create table t1(i1 int); 0 rows inserted/updated/deleted ij> insert into t1 values ( 1); 1 row inserted/updated/deleted ij> select * from t1; I1 ----------- 1 1 row selected ij> commit; ij> disconnect; ij> ----------------------------------- -- 1.1.2 AES - CBC, recover connect 'jdbc:derby:encdb;create=true;dataEncryption=true;encryptionAlgorithm=AES/CBC/NoPadding;bootPassword=Thursday'; WARNING 01J01: Database 'encdb' not created, connection made to existing database instead. ij> autocommit off; ij> create table t1(i1 int); ERROR X0Y32: Table/View 'T1' already exists in Schema 'APP'. ij> insert into t1 values ( 1); 1 row inserted/updated/deleted ij> select * from t1; I1 ----------- 1 1 2 rows selected ij> commit; ij> disconnect; ij> ----------------------------------- -- 1.2.1 AES - ECB connect 'jdbc:derby:encdb_ecb;create=true;dataEncryption=true;encryptionAlgorithm=AES/ECB/NoPadding;bootPassword=Thursday'; ij> autocommit off; ij> create table t1(i1 int); 0 rows inserted/updated/deleted ij> insert into t1 values ( 1); 1 row inserted/updated/deleted ij> select * from t1; I1 ----------- 1 1 row selected ij> commit; ij> disconnect; ij> ----------------------------------- -- 1.2.2 AES - ECB, recover connect 'jdbc:derby:encdb_ecb;create=true;dataEncryption=true;encryptionAlgorithm=AES/ECB/NoPadding;bootPassword=Thursday'; WARNING 01J01: Database 'encdb_ecb' not created, connection made to existing database instead. ij> autocommit off; ij> create table t1(i1 int); ERROR X0Y32: Table/View 'T1' already exists in Schema 'APP'. ij> insert into t1 values ( 1); 1 row inserted/updated/deleted ij> select * from t1; I1 ----------- 1 1 2 rows selected ij> commit; ij> disconnect; ij> ----------------------------------- -- 1.3.1 AES - OFB connect 'jdbc:derby:encdb_ofb;create=true;dataEncryption=true;encryptionAlgorithm=AES/OFB/NoPadding;bootPassword=Thursday'; ij> autocommit off; ij> create table t1(i1 int); 0 rows inserted/updated/deleted ij> insert into t1 values ( 1); 1 row inserted/updated/deleted ij> select * from t1; I1 ----------- 1 1 row selected ij> commit; ij> disconnect; ij> ----------------------------------- -- 1.3.2 AES - OFB, recover connect 'jdbc:derby:encdb_ofb;create=true;dataEncryption=true;encryptionAlgorithm=AES/OFB/NoPadding;bootPassword=Thursday'; WARNING 01J01: Database 'encdb_ofb' not created, connection made to existing database instead. ij> autocommit off; ij> create table t1(i1 int); ERROR X0Y32: Table/View 'T1' already exists in Schema 'APP'. ij> insert into t1 values ( 1); 1 row inserted/updated/deleted ij> select * from t1; I1 ----------- 1 1 2 rows selected ij> commit; ij> disconnect; ij> ----------------------------------- -- 1.4.1 AES - CFB connect 'jdbc:derby:encdb_cfb;create=true;dataEncryption=true;encryptionAlgorithm=AES/CFB/NoPadding;bootPassword=Thursday'; ij> autocommit off; ij> create table t1(i1 int); 0 rows inserted/updated/deleted ij> insert into t1 values ( 1); 1 row inserted/updated/deleted ij> select * from t1; I1 ----------- 1 1 row selected ij> commit; ij> disconnect; ij> ----------------------------------- -- 1.4.2 AES - CFB, recover connect 'jdbc:derby:encdb_cfb;create=true;dataEncryption=true;encryptionAlgorithm=AES/CFB/NoPadding;bootPassword=Thursday'; WARNING 01J01: Database 'encdb_cfb' not created, connection made to existing database instead. ij> autocommit off; ij> create table t1(i1 int); ERROR X0Y32: Table/View 'T1' already exists in Schema 'APP'. ij> insert into t1 values ( 1); 1 row inserted/updated/deleted ij> select * from t1; I1 ----------- 1 1 2 rows selected ij> commit; ij> disconnect; ij> ----------------------------------- -- 1.5.1 -ve cases: AES - unsupported feedback mode connect 'jdbc:derby:encdb_abc;create=true;dataEncryption=true;encryptionAlgorithm=AES/ABC/NoPadding;bootPassword=Thursday'; ERROR XJ041: Failed to create database 'encdb_abc', see the next exception for details. ERROR XBM01: Startup failed due to an exception. See next exception for details. ERROR XBCXI: The feedback mode 'ABC' is not supported. Supported feedback modes are CBC, CFB, OFB and ECB. ij> autocommit off; IJ ERROR: Unable to establish connection ij> create table t1(i1 int); IJ ERROR: Unable to establish connection ij> insert into t1 values ( 1); IJ ERROR: Unable to establish connection ij> ----------------------------------- -- 2.1 -ve cases: AES - unsupported padding mode connect 'jdbc:derby:encdb_pkcs5;create=true;dataEncryption=true;encryptionAlgorithm=AES/ECB/PKCS5Padding;bootPassword=Thursday'; ERROR XJ041: Failed to create database 'encdb_pkcs5', see the next exception for details. ERROR XBM01: Startup failed due to an exception. See next exception for details. ERROR XBCXB: Bad encryption padding 'PKCS5Padding' or padding not specified. 'NoPadding' must be used. ij> autocommit off; IJ ERROR: Unable to establish connection ij> create table t1(i1 int); IJ ERROR: Unable to establish connection ij> insert into t1 values ( 1); IJ ERROR: Unable to establish connection ij> ------------------------------------ -- 3.x key lengths -- 128,192,256 and also unsupported key length -- 3.1 , 128 key length connect 'jdbc:derby:encdbcbc_128;create=true;dataEncryption=true;encryptionKeyLength=128 ;encryptionAlgorithm=AES/CBC/NoPadding;bootPassword=Thursday'; ij> autocommit off; ij> create table t1(i1 int); 0 rows inserted/updated/deleted ij> insert into t1 values ( 1); 1 row inserted/updated/deleted ij> select * from t1; I1 ----------- 1 1 row selected ij> commit; ij> disconnect; ij> connect 'jdbc:derby:encdbcbc_128;create=true;dataEncryption=true;encryptionKeyLength=128; encryptionAlgorithm=AES/CBC/NoPadding;bootPassword=Thursday'; WARNING 01J01: Database 'encdbcbc_128' not created, connection made to existing database instead. ij> autocommit off; ij> create table t1(i1 int); ERROR X0Y32: Table/View 'T1' already exists in Schema 'APP'. ij> insert into t1 values ( 1); 1 row inserted/updated/deleted ij> select * from t1; I1 ----------- 1 1 2 rows selected ij> commit; ij> disconnect; ij> -------------------------- -------------------------- -- 3.4 unsupported key length connect 'jdbc:derby:encdbcbc_512;create=true;dataEncryption=true;encryptionKeyLength=512;encryptionAlgorithm=AES/CBC/NoPadding;bootPassword=Thursday'; ERROR XJ041: Failed to create database 'encdbcbc_512', see the next exception for details. ERROR XBM01: Startup failed due to an exception. See next exception for details. ERROR XJ001: Java exception: 'Wrong keysize: must be equal to 128, 192 or 256: java.security.InvalidParameterException'. ij> autocommit off; IJ ERROR: Unable to establish connection ij> create table t1(i1 int); IJ ERROR: Unable to establish connection ij> insert into t1 values ( 1); IJ ERROR: Unable to establish connection ij> select * from t1; IJ ERROR: Unable to establish connection ij> commit; IJ ERROR: Unable to establish connection ij> disconnect; IJ ERROR: Unable to establish connection ij> ------------------------- ------------------------- -- 5.1 give external encryptionKey instead of bootpassword connect 'jdbc:derby:encdbcbc_key;create=true;dataEncryption=true;encryptionAlgorithm=AES/CBC/NoPadding;encryptionKey=61626364656667686961626364656568'; ij> create table t1(i1 int); 0 rows inserted/updated/deleted ij> insert into t1 values(1); 1 row inserted/updated/deleted ij> select * from t1; I1 ----------- 1 1 row selected ij> commit; ij> disconnect; ij> connect 'jdbc:derby:encdbcbc_key;create=true;dataEncryption=true;encryptionAlgorithm=AES/CBC/NoPadding;encryptionKey=61626364656667686961626364656568'; WARNING 01J01: Database 'encdbcbc_key' not created, connection made to existing database instead. ij> select * from t1; I1 ----------- 1 1 row selected ij>