Home » RDBMS Server » Security » Spanish character encryption problem in UTF8 (oracle 10g - 10.2.0.4 , Linux)
Spanish character encryption problem in UTF8 [message #538769] Mon, 09 January 2012 06:27 Go to next message
sanei05
Messages: 104
Registered: September 2008
Senior Member
Hi,
Recently the Oracle10g database has been migrated to UTF8 character set and the following have failed.

1. The password applied is not getting encrypted and the password contains a spanish characters.
Gettign the below error.

"10057:ERROR WHILE ENCRYPTING GIVEN STRING:String:Uñomasuño5.::ORA-28232: invalid input length for obfuscation toolkit:-28232:ORA-28232: invalid input length for obfuscation toolkit"


The algorithm used for encryption DES. I tried with DESENCRYPT , DES3ENCRPYT and MD5 and it failing.

Can anyone help me on this.
Re: Spanish character encryption problem in UTF8 [message #538772 is a reply to message #538769] Mon, 09 January 2012 06:33 Go to previous messageGo to next message
Michel Cadot
Messages: 68728
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
The input string must have a length of multiple of 8 bytes as stated by the error message:
ORA-28232: invalid input length for obfuscation toolkit
 *Cause:  Length of data submitted for encryption or decryption is not a
          multiple of 8 bytes.
 *Action: Make sure that the length of the data to be encrypted or decrypted
          is a multiple of 8 bytes.

Regards
Michel

[Updated on: Mon, 09 January 2012 06:33]

Report message to a moderator

Re: Spanish character encryption problem in UTF8 [message #538774 is a reply to message #538772] Mon, 09 January 2012 06:37 Go to previous messageGo to next message
sanei05
Messages: 104
Registered: September 2008
Senior Member
Thanks for the reply.
But the spanish character takes the byte length of 26 in AL32UTF8 character set db. but its fine with default charset.


select lengthb(rpad('Uñomasuño5.',24,';')) from dual;

gives 26 as byte length.

What is the solution to encrypt the byte length which not a multiple of 8.


-----------------------

DECLARE
input_string NVARCHAR2(32) := 'Uñomasuño5.';
key_string NVARCHAR2(32) := 'Magickey';

encrypted_string VARCHAR2(2048);
decrypted_string VARCHAR2(2048);

error_in_input_buffer_length EXCEPTION;

PRAGMA EXCEPTION_INIT(error_in_input_buffer_length, -28232);
INPUT_BUFFER_LENGTH_ERR_MSG VARCHAR2(100) :=
'*** DES INPUT BUFFER NOT A MULTIPLE OF 8 BYTES ***';

BEGIN
dbms_output.put_line('> ========= BEGIN TEST =========');
dbms_output.put_line('> Input string : ' ||
input_string);
--BEGIN <-- ignore this, typo in Oracle's documentation
dbms_obfuscation_toolkit.DESEncrypt(
input_string => input_string,
key_string => key_string,
encrypted_string => encrypted_string );
dbms_output.put_line('> Encrypted string : ' ||
encrypted_string);
-- Add DESDecrypt as shown, change raw to key_string
dbms_obfuscation_toolkit.DESDecrypt(
input_string => encrypted_string,
key_string => key_string,
decrypted_string => decrypted_string);
dbms_output.put_line('> Decrypted output : ' ||
decrypted_string);
dbms_output.put_line('> ');
if input_string =
decrypted_string THEN
dbms_output.put_line('> DES Encryption and Decryption successful');
END IF;
EXCEPTION

WHEN error_in_input_buffer_length THEN
dbms_output.put_line('> ' || INPUT_BUFFER_LENGTH_ERR_MSG);
END;
Re: Spanish character encryption problem in UTF8 [message #538776 is a reply to message #538774] Mon, 09 January 2012 06:42 Go to previous messageGo to next message
Michel Cadot
Messages: 68728
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Quote:
What is the solution to encrypt the byte length which not a multiple of 8


Compute the size of your string and pad it with dummy 0 (or spaces as you want) to fit the multiple of 8.

Regards
Michel

[Updated on: Mon, 09 January 2012 06:43]

Report message to a moderator

Re: Spanish character encryption problem in UTF8 [message #550488 is a reply to message #538776] Mon, 09 April 2012 14:22 Go to previous messageGo to next message
sanei05
Messages: 104
Registered: September 2008
Senior Member
Thanks..
We modified the procedure and it worked fine..
Re: Spanish character encryption problem in UTF8 [message #550515 is a reply to message #550488] Tue, 10 April 2012 00:59 Go to previous message
Michel Cadot
Messages: 68728
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Thanks for the feedback.

Regards
Michel
Previous Topic: Audit Destination Problem
Next Topic: Auditing at table level in 11g
Goto Forum:
  


Current Time: Sun Dec 22 00:52:14 CST 2024