|
|
Re: Convert Number (16 bytes) to encrypted raw value [message #316875 is a reply to message #316866] |
Mon, 28 April 2008 12:43 |
fnoyer
Messages: 2 Registered: April 2008
|
Junior Member |
|
|
Hi Michel.
This is mainly the algorithm (sorry for the by hand padding
I have a number into a sequence that is limited from 0 to 2^64-1 and positive.
I want to encrypt it for scrambling.
But when I try to convert this sequence number into a raw byte (required by the encryption function), there is limitation.
For instance :
data := utl_raw.cast_from_number(17179869184); it bug -> ORA-06502: PL/SQL: numeric or value error: raw variable length too long
and 17179869184 only equals 2^34.
If I try with cast_from_binary_integer it seems to be limited to 4 bytes values and it seems to be signed.
Quote: | DECLARE
a NUMBER(19) := 18446744073709551615;
data RAW(8);
data2 VARCHAR2(16);
resultat RAW(8);
pad INTEGER;
g_key RAW(32767) := UTL_RAW.cast_to_raw('12345678');
BEGIN
data := utl_raw.cast_from_number(a);
pad := (8 - utl_raw.LENGTH(data));
DBMS_OUTPUT.PUT_LINE(' pad' || pad);
DBMS_OUTPUT.PUT_LINE(' utl_raw.LENGTH(data)' || utl_raw.LENGTH(data));
DBMS_OUTPUT.PUT_LINE(' data ' || data);
data := concat(0,data);
DBMS_OUTPUT.PUT_LINE(' data ' || data);
data := concat(0,data);
DBMS_OUTPUT.PUT_LINE(' data ' || data);
data := concat(0,data);
DBMS_OUTPUT.PUT_LINE(' data ' || data);
data := concat(0,data);
DBMS_OUTPUT.PUT_LINE(' data ' || data);
data := concat(0,data);
DBMS_OUTPUT.PUT_LINE(' data ' || data);
data := concat(0,data);
DBMS_OUTPUT.PUT_LINE(' data ' || data);
DBMS_OBFUSCATION_TOOLKIT.desencrypt(input => data ,
key => g_key,
encrypted_data => resultat);
DBMS_OUTPUT.PUT_LINE(' resultat' || resultat);
DBMS_OUTPUT.PUT_LINE(' resultat ' || resultat);
DBMS_OBFUSCATION_TOOLKIT.desdecrypt(input => resultat,
key => g_key,
decrypted_data => data2);
DBMS_OUTPUT.PUT_LINE(' data2 ' || data2);
END;
|
|
|
|
Re: Convert Number (16 bytes) to encrypted raw value [message #316882 is a reply to message #316875] |
Mon, 28 April 2008 13:12 |
|
Michel Cadot
Messages: 68728 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
SQL> select utl_raw.cast_from_number(17179869184) from dual;
C6024850575C55
SQL> declare
1 a raw(100);
2 begin
3 a := utl_raw.cast_from_number(17179869184);
4 end;
5 /
Instruction traitée.
SQL> declare
1 a raw(100);
2 begin
3 a := utl_raw.cast_from_number(18446744073709551615);
4 end;
5 /
Instruction traitée.
RAW( 8 ) is too small. Oracle does not store numbers as you think.
See my previous example 1 -> C102 not 1.
Regards
Michel
[Updated on: Mon, 28 April 2008 13:13] Report message to a moderator
|
|
|