My Oracle Support Banner

DBMS_CRYPTO.DECRYPT - ORA-28817 ORA-06512 at DBMS_CRYPTO_FFI (Doc ID 956603.1)

Last updated on APRIL 16, 2018

Applies to:

Oracle Database - Enterprise Edition - Version 10.2.0.1 to 11.2.0.0 [Release 10.2 to 11.2]
Information in this document applies to any platform.
Checked for relevance on 18-MAR-2013


Symptoms

When you use DBMS_CRYPTO for encryption and decryption, you get the below error:

SQL> create or replace function encrypt(v_string in varchar2) return varchar2 is
  2  encrypted_raw      RAW (2000);
  3  encryption_type    PLS_INTEGER :=  SYS.DBMS_CRYPTO.ENCRYPT_DES + SYS.DBMS_CRYPTO.CHAIN_CBC + SYS.DBMS_CRYPTO.PAD_PKCS5;
  4  v_key raw(128) := utl_i18n.string_to_raw( 'artos0011', 'AL32UTF8' );
  5  begin
  6       encrypted_raw := DBMS_CRYPTO.ENCRYPT
  7        (
  8           src => UTL_I18N.STRING_TO_RAW (v_string,'AL32UTF8'),
  9           typ => encryption_type,
 10           key => v_key
 11        );
 12        return  UTL_I18N.raw_to_char(encrypted_raw,'AL32UTF8');
 13  end encrypt;
 14  /

Function created.


SQL> create or replace function decrypt(v_str in varchar2) return varchar2 is
  2  decrypted_raw     raw(2000);
  3  encryption_type    PLS_INTEGER := SYS.DBMS_CRYPTO.ENCRYPT_DES + SYS.DBMS_CRYPTO.CHAIN_CBC + SYS.DBMS_CRYPTO.PAD_PKCS5;
  4  v_key raw(128) := utl_i18n.string_to_raw( 'artos001', 'AL32UTF8' );
  5  begin
  6       decrypted_raw := DBMS_CRYPTO.Decrypt
  7        (
  8           src => UTL_I18N.string_to_raw(v_str),
  9           typ => encryption_type,
 10           key => v_key
 11        );
 12  return    UTL_I18N.RAW_TO_CHAR (decrypted_raw, 'AL32UTF8');
 13  end decrypt;
 14  /

Function created.


SQL> select decrypt(encrypt('67634572')) from dual;
select decrypt(encrypt('67634572')) from dual
       *
ERROR at line 1:
ORA-28817: PL/SQL function returned an error.
ORA-06512: at "SYS.DBMS_CRYPTO_FFI", line 67
ORA-06512: at "SYS.DBMS_CRYPTO", line 41
ORA-06512: at "MOHAN.DECRYPT", line 6

Cause

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Symptoms
Cause
Solution

This document is being delivered to you via Oracle Support's Rapid Visibility (RaV) process and therefore has not been subject to an independent technical review.
My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.