Skip to Main Content

Database Software

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!

DBMS.CRYPTO issue

Jcgo-OracleSep 7 2018 — edited Sep 13 2018

Hi this is the PL/SQL code I am using, using AES256. When I run this, I get an 

ORA-28817: PL/SQL function returned an error.

********************

create or replace PACKAGE BODY "ENC_DEC"

AS

     encryption_type    PLS_INTEGER := DBMS_CRYPTO.ENCRYPT_AES256 -- total encryption type

                                    + DBMS_CRYPTO.CHAIN_CBC

                                    + DBMS_CRYPTO.PAD_PKCS5;

     /*

       ENCRYPT_AES256 is the encryption algorithem. Data Encryption Standard. Block cipher.

       Uses key length of 256 bits.

       CHAIN_CBC Cipher Block Chaining. Plaintext is XORed with the previous ciphertext

       block before it is encrypted.

       PAD_PKCS5 Provides padding which complies with the PKCS #5: Password-Based

       Cryptography Standard

     */

     encryption_key     RAW(32) := UTL_RAW.cast_to_raw('MyEncryptionKeyyyyyyyyyyyyyyyyyy');

     -- The encryption key for DES algorithem, should be 8 bytes or more.

     FUNCTION encrypt (p_plainText VARCHAR2) RETURN RAW

     IS

        encrypted_raw      RAW (2000);

     BEGIN

        encrypted_raw := DBMS_CRYPTO.ENCRYPT

        (

           src => UTL_RAW.CAST_TO_RAW (p_plainText),

           typ => encryption_type,

           key => encryption_key

        );

       RETURN encrypted_raw;

     END encrypt;

     FUNCTION decrypt (p_encryptedText RAW) RETURN VARCHAR2

     IS

        decrypted_raw      RAW (2000);

     BEGIN

        decrypted_raw := DBMS_CRYPTO.DECRYPT

        (

            src => p_encryptedText,

            typ => encryption_type,

            key => encryption_key

        );

        RETURN (UTL_RAW.CAST_TO_VARCHAR2 (decrypted_raw));

     END decrypt;

END;

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 11 2018
Added on Sep 7 2018
2 comments
871 views