Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run dbms_crypto functions in Oracle as regular user?

I have problem with using dbms_crypto.hash() function in Oracle.

I connected to database server using sqlplus as "sys/passwd as sysdba", then I installed dbms_crypto package:

@/home/oracle/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/dbmsobtk.sql
@/home/oracle/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/prvtobtk.plb
Grant execute on dbms_crypto to public;
Grant execute on dbms_sqlhash to public;
Grant execute on dbms_obfuscation_toolkit to public;
Grant execute on dbms_obfuscation_toolkit_ffi to public;
Grant execute on dbms_crypto_ffi to public;

Everything looks good, so I tested hash() function:

SQL> select dbms_crypto.hash(utl_raw.cast_to_raw('zorg'), 3) from dual;

DBMS_CRYPTO.HASH(UTL_RAW.CAST_TO_RAW('ZORG'),3)
--------------------------------------------------------------------------------
60C440F9954CA4744204CDA9CC93567059C1EC82

I disconnected and connected to that database as regular user, but then I got error:

SQL> select dbms_crypto.hash(utl_raw.cast_to_raw('zorg'), 3) from dual;
select dbms_crypto.hash(utl_raw.cast_to_raw('zorg'), 3) from dual
             *
ERROR at line 1:
ORA-06521: PL/SQL: Error mapping function
ORA-06512: at "MN.DBMS_CRYPTO_FFI", line 131
ORA-06512: at "MN.DBMS_CRYPTO", line 72

Why I cannot use this function as regular user? How to allow other users to use it?

I work with:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
like image 857
Michał Niklas Avatar asked Nov 20 '12 12:11

Michał Niklas


People also ask

Is DBMS_CRYPTO installed by default?

I think dbms_crypto is not installed by default, you might have to install it using $ORACLE_HOME/rdbms/admin/dbmsoctk. sql and $ORACLE_HOME/rdbms/admin/prvtobtk. plb scripts.

What is Oracle DBMS_CRYPTO?

DBMS_CRYPTO provides an interface to encrypt and decrypt stored data, and can be used in conjunction with PL/SQL programs running network communications. It provides support for several industry-standard encryption and hashing algorithms, including the Advanced Encryption Standard (AES) encryption algorithm.

How do I decrypt in Oracle?

You can return an encrypted database to an unencrypted state by specifying attributes on the connection URL. To decrypt an encrypted database, specify the decryptDatabase=true attribute in conjunction with either the bootPassword=key attribute or the encryptionKey=key attribute.

How do I decrypt a column in Oracle?

To decrypt an existing column in a table in the database, ALTER TABLE customer MODIFY (cust_name decrypt); To add SALT to an encrypted column in a table in the database, ALTER TABLE customer MODIFY (cust_email encrypt salt);


1 Answers

Problem solved. I created package as wrong user. Proper way:

  1. connect using:

    sqlplus / as sysdba
    
  2. Install packages:

    @/home/oracle/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/dbmsobtk.sql
    @/home/oracle/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/prvtobtk.plb
    
  3. Connect as regular user and use functions from dbms_crypto package.

like image 189
Michał Niklas Avatar answered Sep 22 '22 18:09

Michał Niklas