Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SYS.DBMS_CRYPTO error while decrypting the encrypted password

user12251389Nov 3 2016 — edited Nov 3 2016

I have the below function in package where i am trying to decrpyt the encrypted password but getting the below error message:

ORA-28817: PL/SQL function returned an error.
ORA-06512
: at "SYS.DBMS_CRYPTO_FFI",
ORA-06512
: at "SYS.DBMS_CRYPTO",
ORA-06512
: at "RATOR_MONITORING_CONFIGURATION.ENCRYPT_DECRYPT_PASSWORD", line 11  
28817. 00000 -  "PL/SQL function returned an error."
*Cause:  A PL/SQL function returned an error unexpectedly.
*Action:  This is an internal error. Enable tracing to find more information. Contact Oracle customer support if needed.
*Document: NO

Below is my package:

create or replace PACKAGE BODY "ENCRYPT_DECRYPT_PASSWORD"
AS

  l_key RAW
(128) := utl_raw.cast_to_raw('abcdefgh');

FUNCTION decrypt_val( p_val IN varchar2 ) RETURN VARCHAR2
 
IS
  l_decrypted RAW
(2048);
  l_val RAW
(2048) := utl_raw.cast_to_raw(p_val);
  
BEGIN
  l_decrypted
:= dbms_crypto.decrypt
  
( src =>  l_val,
  typ
=> dbms_crypto.des_cbc_pkcs5,
  
key => l_key );

  
return utl_raw.cast_to_varchar2(l_decrypted);

 
END decrypt_val;


FUNCTION get_decrypted_password( table_name IN varchar2,column_name IN varchar2,table_id IN varchar2,table_id_val IN varchar2 ) RETURN VARCHAR2
 
IS
  encrypted_pas varchar2
(100);
  decrypted_pas varchar2
(100);

  
BEGIN
  
EXECUTE IMMEDIATE 'select ' || column_name || ' from ' || table_name || ' where ' || table_id || ' = ' || table_id_val
  
INTO encrypted_pas;
  
Select decrypt_val(encrypted_pas) into decrypted_pas from dual;
  
return decrypt_val(encrypted_pas);
 
END get_decrypted_password;

END encrypt_decrypt_password;

I also tried giving DBMS_CRYPTO permission to the user and my package has also been compiled but when i tried to run the below command to decrypt the password then i am getting the error.

Select ENCRYPT_DECRYPT_PASSWORD.get_decrypted_password('DB_CONNECTION','PASSWORD','DB_CONNECTION_ID',11) from dual;

When i run this package in different server and machine then i am able to execute the package and able to decrypt the password.

This post has been answered by user12251389 on Nov 3 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 1 2016
Added on Nov 3 2016
5 comments
1,829 views