Issue Details (XML | Word | Printable)

Key: DERBY-746
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Kristian Waagan
Reporter: Kristian Waagan
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Derby

NullPointerException when 'encryptionKey' length is an odd number, or it contains invalid chars

Created: 07/Dec/05 10:54 PM   Updated: 30/Jun/09 12:14 AM
Return to search
Component/s: None
Affects Version/s: 10.1.2.1, 10.1.3.1, 10.2.1.6
Fix Version/s: 10.1.3.1, 10.2.1.6

Time Tracking:
Not Specified

File Attachments:
  Size
File Licensed for inclusion in ASF works derby-746.diff 2006-01-04 12:05 AM Kristian Waagan 6 kB
File Licensed for inclusion in ASF works derby-746.stat 2006-01-04 12:05 AM Kristian Waagan 0.4 kB
File Licensed for inclusion in ASF works derby-746a.diff 2006-01-05 03:47 AM Kristian Waagan 2 kB
File Licensed for inclusion in ASF works derby-746a.stat 2006-01-05 03:47 AM Kristian Waagan 0.2 kB
Environment: All environments.

Bug behavior facts: Security
Resolution Date: 15/Sep/06 01:06 PM


 Description  « Hide
When booting/creating an encrypted database, a NullPointerException is thrown if the length of the connection string attribute 'encryptionKey' is an odd number, or the encryption key contains invalid characters for hexadecimal numbers (char not in the set [0-9a-fA-F]).

The reason for the exception being thrown, is that the method 'iapi.util.StringUtil.fromHexString(String, int, int)' returns null for the cases described above. The code calling the method in 'JCECipherFactory.boot(boolean, Properties)' does not check that the return value is not null.

A related trivial issue is that 'fromHexString' does not allow the caller to see the distinction between a string with invalid length and a string containing invalid characters (both cases return null).

[To reproduce]
(connection string copied from test 'store/encryptionKey.sql' and then modified)
Supply the following connection string, for instance in ij:
connect 'jdbc:derby:encdbcbc_key;create=true;dataEncryption=true;encryptionAlgorithm=DES/CBC/NoPadding;encryptionKey=6162636465666768696162636465656';
(deleted the last digit in the encryption key)
'jdbc:derby:encdbcbc_key;create=true;dataEncryption=true;encryptionAlgorithm=DES/CBC/NoPadding;encryptionKey=6162636465666768696162636465656X';
(replaced last digit with an X)

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
No work has yet been logged on this issue.