__IF_EXISTS__
SELECT 1
	FROM CI_UT_INSTL_DTL
WHERE SCRIPT_FILE_NAME = 'FW45000_BPSCHEMA_OUAF-31663.SQL'
	AND END_DTTM IS NOT NULL
/
__THEN__

__EXIT__

__ENDIF__

CREATE OR REPLACE EDITIONABLE PACKAGE OUAF_SECURITY AS
PROCEDURE create_sec_inventory_tbl;
PROCEDURE put_secret     (SECRET_NAME IN VARCHAR2, SECRET_BYTES IN RAW,ENC_KEY_NAME IN VARCHAR2, ENCRYPTION_KEY_BYTES IN RAW , ENCRYPTION_ALG IN VARCHAR2 default 'ENCRYPT_AES256', VERIFICATION_HASH_ALG IN VARCHAR2 default 'HMAC_SH256',RETURN_CODE OUT NUMBER);
PROCEDURE delete_secret  (SECRET_NAME IN VARCHAR2, RETURN_CODE OUT NUMBER);
PROCEDURE update_secret  (SECRET_NAME IN VARCHAR2, SECRET_BYTES IN RAW,ENC_KEY_NAME IN VARCHAR2, ENCRYPTION_KEY_BYTES IN RAW , ENCRYPTION_ALG IN VARCHAR2 default 'ENCRYPT_AES256', VERIFICATION_HASH_ALG IN VARCHAR2 default 'HMAC_SH256',RETURN_CODE OUT NUMBER);
PROCEDURE get_key_name   (SECRET_NAME IN VARCHAR2, ENCRYPTION_KEY_NAME OUT VARCHAR2, RETURN_CODE OUT NUMBER);
PROCEDURE get_secret     (SECRET_NAME IN VARCHAR2, ENC_KEY_BYTES IN RAW, SECRET_BYTES OUT RAW, RETURN_CODE OUT NUMBER);
PROCEDURE check_secret   (SECRET_NAME IN VARCHAR2, RETURN_CODE OUT NUMBER);
FUNCTION  encrypt_secret ( p_inp IN RAW, p_key IN RAW,  p_enc_val in VARCHAR2 ) RETURN RAW;
FUNCTION  decrypt_secret ( p_inp IN RAW, p_key IN RAW, p_enc_val in VARCHAR2 ) RETURN RAW;
FUNCTION  compute_hash   ( p_inp IN RAW, p_key IN RAW, p_verification_hash_alg IN  VARCHAR2) RETURN RAW;
FUNCTION  generate_salt RETURN RAW;
END ouaf_security;
/

CREATE OR REPLACE PACKAGE BODY ouaf_security  IS
g_sec_inventory_tbl               VARCHAR2(30) := 'SEC_INVENTORY';

		PROCEDURE create_sec_inventory_tbl IS
			v_count NUMBER := 0;
			ddl_stmt varchar2(4000);
				BEGIN
					ddl_stmt := 'CREATE TABLE '||g_sec_inventory_tbl||'( SECRET_NAME VARCHAR2(200),   ENC_KEY_NAME VARCHAR2(200) NOT NULL ENABLE,    ENCRYPTED_BYTES RAW(2000) NOT NULL ENABLE ,   ENCRYPTION_ALG  VARCHAR2(30) NOT NULL ENABLE,   VERIFICATION_HASH_ALG VARCHAR2(30) NOT NULL ENABLE,     VERIFICATION_HASH RAW (2000) NOT NULL ENABLE,SALT RAW (2000) NOT NULL ENABLE, CONSTRAINT F1C920P0 PRIMARY KEY (SECRET_NAME))';
					SELECT
						COUNT(*)
					INTO v_count
					FROM
						user_tables
					WHERE
						table_name = g_sec_inventory_tbl;
					IF v_count = 0 THEN
					 EXECUTE IMMEDIATE ddl_stmt;
					END IF;
				END create_sec_inventory_tbl;	
				
			PROCEDURE put_secret 
			(SECRET_NAME IN VARCHAR2, SECRET_BYTES IN RAW,ENC_KEY_NAME IN VARCHAR2, ENCRYPTION_KEY_BYTES IN RAW , ENCRYPTION_ALG IN VARCHAR2 default 'ENCRYPT_AES256',VERIFICATION_HASH_ALG IN VARCHAR2 default 'HMAC_SH256', RETURN_CODE OUT NUMBER)
			IS 
				v_secret_name             VARCHAR2(200)  := SECRET_NAME; 
				v_secret_bytes            RAW (2000)     := SECRET_BYTES;                         
				v_enc_key_name            VARCHAR2(200)  := ENC_KEY_NAME;
				v_encrypted_bytes         RAW(2000);
				v_enc_key_bytes           RAW(2000)      := ENCRYPTION_KEY_BYTES;
				v_encryption_alg          VARCHAR2(30)   := ENCRYPTION_ALG;
				v_verification_hash_alg   VARCHAR2(30)   := VERIFICATION_HASH_ALG;
				v_verification_hash       RAW  (2000)    ;
				l_value                   NUMBER; 
				l_sql_txt                 VARCHAR2(4000);
				v_salted_secret           RAW  (2000);
				v_salt                    RAW (2000);
				
			 BEGIN
			 
			 if ( ENCRYPTION_ALG = 'ENCRYPT_AES256' ) THEN
				v_encryption_alg := ENCRYPTION_ALG ;
			 ELSIF ( ENCRYPTION_ALG = 'ENCRYPT_AES192' ) THEN
	            v_encryption_alg := ENCRYPTION_ALG ;
	         ELSIF ( ENCRYPTION_ALG = 'ENCRYPT_AES128' ) THEN
	            v_encryption_alg := ENCRYPTION_ALG ;
	         ELSIF ( ENCRYPTION_ALG = 'ENCRYPT_3DES_2KEY' ) THEN
	            v_encryption_alg := ENCRYPTION_ALG ;
 	         ELSIF ( ENCRYPTION_ALG = 'ENCRYPT_3DES' ) THEN
	            v_encryption_alg := ENCRYPTION_ALG ;
             ELSIF ( ENCRYPTION_ALG = 'ENCRYPT_RC4' ) THEN
	            v_encryption_alg := ENCRYPTION_ALG ;
	         ELSIF ( ENCRYPTION_ALG = 'ENCRYPT_DES' ) THEN
	            v_encryption_alg := ENCRYPTION_ALG ;
	         ELSE
			   
	 	       raise_application_error(-20997, 'ENCRYPTION TYPE - ' || ENCRYPTION_ALG ||' IS NOT SUPPORTED. ONLY ENCRYPTION ALGORITHMS - "ENCRYPT_AES128", "ENCRYPT_AES192", "ENCRYPT_AES256", "ENCRYPT_DES", "ENCRYPT_3DES", "ENCRYPT_3DES_2KEY" and "ENCRYPT_RC4" ARE SUPPORTED' );
		 
         	 END IF;
	        			
			
			l_sql_txt := 'SELECT	COUNT(*) FROM '  || g_sec_inventory_tbl  ||   ' WHERE SECRET_NAME =:1';
                                 
            EXECUTE IMMEDIATE l_sql_txt INTO l_value USING v_secret_name; 

						
			IF l_value = 0 THEN
						 
			 v_salt              := generate_salt ( );    
			 
			 v_salted_secret     := v_salt|| v_secret_bytes;
			 
			 			 
						 
			 v_encrypted_bytes   := encrypt_secret(v_salted_secret, v_enc_key_bytes, v_encryption_alg);
			 v_verification_hash := compute_hash(v_salted_secret, v_enc_key_bytes, v_verification_hash_alg);
			  
			  EXECUTE IMMEDIATE 'INSERT INTO '|| g_sec_inventory_tbl
										 || ' VALUES (:1,:2,:3,:4,:5,:6,:7)' USING v_secret_name, v_enc_key_name,v_encrypted_bytes,v_encryption_alg,v_verification_hash_alg,v_verification_hash,v_salt;
              
			  RETURN_CODE := 0;
			  
			ELSE 
			  update_secret  (SECRET_NAME=> v_secret_name , SECRET_BYTES=> v_secret_bytes ,ENC_KEY_NAME=>v_enc_key_name  , ENCRYPTION_KEY_BYTES=> v_enc_key_bytes , ENCRYPTION_ALG=> v_encryption_alg, RETURN_CODE=> RETURN_CODE);
			  RETURN_CODE := 4;
			END IF;
			
			  
					  
			END put_secret;
			
		    PROCEDURE update_secret  (SECRET_NAME IN VARCHAR2, SECRET_BYTES IN RAW,ENC_KEY_NAME IN VARCHAR2, ENCRYPTION_KEY_BYTES IN RAW , ENCRYPTION_ALG IN VARCHAR2 default 'ENCRYPT_AES256',VERIFICATION_HASH_ALG IN VARCHAR2 default 'HMAC_SH256', RETURN_CODE OUT NUMBER)
			IS
			v_secret_name             VARCHAR2(200)  := SECRET_NAME; 
				v_secret_bytes            RAW (2000)     := SECRET_BYTES;                         
				v_enc_key_name            VARCHAR2(200)  := ENC_KEY_NAME;
				v_encrypted_bytes         RAW(2000);
				v_enc_key_bytes           RAW(2000)      := ENCRYPTION_KEY_BYTES;
				v_encryption_alg          VARCHAR2(30)   := ENCRYPTION_ALG;
				v_verification_hash_alg   VARCHAR2(30)   := VERIFICATION_HASH_ALG;
				v_verification_hash       RAW  (2000)    ;
				l_value                   NUMBER         := 0;
				l_sql_txt                 VARCHAR2(4000);
				sql_stmt                  VARCHAR2(4000);
				v_salted_secret           RAW  (2000);
				v_salt                    RAW (2000);
			BEGIN
			
			 if ( ENCRYPTION_ALG = 'ENCRYPT_AES256' ) THEN
				v_encryption_alg := ENCRYPTION_ALG ;
			 ELSIF ( ENCRYPTION_ALG = 'ENCRYPT_AES192' ) THEN
	            v_encryption_alg := ENCRYPTION_ALG ;
	         ELSIF ( ENCRYPTION_ALG = 'ENCRYPT_AES128' ) THEN
	            v_encryption_alg := ENCRYPTION_ALG ;
	         ELSIF ( ENCRYPTION_ALG = 'ENCRYPT_3DES_2KEY' ) THEN
	            v_encryption_alg := ENCRYPTION_ALG ;
 	         ELSIF ( ENCRYPTION_ALG = 'ENCRYPT_3DES' ) THEN
	            v_encryption_alg := ENCRYPTION_ALG ;
             ELSIF ( ENCRYPTION_ALG = 'ENCRYPT_RC4' ) THEN
	            v_encryption_alg := ENCRYPTION_ALG ;
	         ELSIF ( ENCRYPTION_ALG = 'ENCRYPT_DES' ) THEN
	            v_encryption_alg := ENCRYPTION_ALG ;
	         ELSE
			   
	 	       raise_application_error(-20997, 'ENCRYPTION TYPE - ' || ENCRYPTION_ALG ||' IS NOT SUPPORTED. ONLY ENCRYPTION ALGORITHMS - "ENCRYPT_AES128", "ENCRYPT_AES192", "ENCRYPT_AES256", "ENCRYPT_DES", "ENCRYPT_3DES", "ENCRYPT_3DES_2KEY" and "ENCRYPT_RC4" ARE SUPPORTED' );
		 
         	 END IF;
			 
				
			check_secret(v_secret_name ,l_value);
			 IF l_value = 1 THEN
			  RETURN_CODE := 1;
			ELSE 
			
			v_salt              := generate_salt ( );    
			 
			v_salted_secret     := v_salt|| v_secret_bytes;
			 
			
			 
						
            v_encrypted_bytes   := encrypt_secret(v_salted_secret, v_enc_key_bytes, v_encryption_alg);
			v_verification_hash := compute_hash(v_salted_secret, v_enc_key_bytes, v_verification_hash_alg);
			
			sql_stmt := 'UPDATE '||g_sec_inventory_tbl||' SET ENC_KEY_NAME =:1, ENCRYPTED_BYTES =:2, ENCRYPTION_ALG =:3, VERIFICATION_HASH_ALG =:4, VERIFICATION_HASH=:5, SALT=:6 WHERE SECRET_NAME=:7 ';
			EXECUTE IMMEDIATE sql_stmt USING v_enc_key_name, v_encrypted_bytes, v_encryption_alg, v_verification_hash_alg, v_verification_hash, v_salt, v_secret_name;
			
			RETURN_CODE := 0;
			  
			  			 
			END IF; 
			
			 
			 			  
			
            END update_secret;			
			       			 			 
								
			 
			PROCEDURE delete_secret (SECRET_NAME IN VARCHAR2, RETURN_CODE OUT NUMBER)
			IS
			 v_secret_name             VARCHAR2(200)  := SECRET_NAME;  
			 l_value                   NUMBER         := 0;
			 l_sql_txt                 VARCHAR2(4000);
			 
			BEGIN
			 			 
            			
			check_secret(v_secret_name ,l_value);
			 IF l_value = 1 THEN
			  RETURN_CODE := 1;
		     ELSE
			  l_sql_txt := 'DELETE FROM ' || g_sec_inventory_tbl|| ' WHERE SECRET_NAME =:1';
			
			EXECUTE IMMEDIATE l_sql_txt USING v_secret_name;
							RETURN_CODE := 0;
						dbms_output.put_line( 'SECRET- ' || v_secret_name || ' SUCCESSFULLY DELETED FROM SEC_INVENTORY TABLE');
		 	END IF;
			
											
			END delete_secret;
			
			PROCEDURE check_secret   (SECRET_NAME IN VARCHAR2, RETURN_CODE OUT NUMBER)
			IS
			 v_secret_name             VARCHAR2(200)  := SECRET_NAME;  
			 l_value                   NUMBER         := 0;
			 l_sql_txt                 VARCHAR2(4000);
			 
			BEGIN
			 			 
			
		    l_sql_txt := 'SELECT	COUNT(*) FROM '  || g_sec_inventory_tbl  || ' WHERE SECRET_NAME =:1';
                                 
            EXECUTE IMMEDIATE l_sql_txt INTO l_value USING v_secret_name; 

			IF l_value = 0 THEN
			    RETURN_CODE := 1;
				dbms_output.put_line( 'SECRET NAME NOT FOUND IN SEC_INVENTORY TABLE');
			ELSE
			    RETURN_CODE := 0;
				
			END If;
			
						
			  
			
			END check_secret;
			
						
			 
			 
			PROCEDURE get_key_name (SECRET_NAME IN VARCHAR2, ENCRYPTION_KEY_NAME OUT VARCHAR2, RETURN_CODE OUT NUMBER)
			 IS
			 v_secret_name             VARCHAR2(200)  := SECRET_NAME;  
			 l_value                   NUMBER         := 0;
			 l_sql_txt                 VARCHAR2(4000);
			 
			BEGIN
			 
			
			
             check_secret(v_secret_name ,l_value);
			 IF l_value = 1 THEN
			  RETURN_CODE := 1;			
	
			ELSE
			l_sql_txt := 'SELECT ENC_KEY_NAME from ' ||g_sec_inventory_tbl || ' WHERE SECRET_NAME =:1';
                                 
			EXECUTE IMMEDIATE l_sql_txt INTO ENCRYPTION_KEY_NAME USING v_secret_name; 
			
			dbms_output.put_line('--- * * * ');
								dbms_output.put_line(' ENCRYPTION KEY NAME FOR SECRET - '||v_secret_name ||' IS "'||ENCRYPTION_KEY_NAME||'"');
			dbms_output.put_line('--- * * * ');
			RETURN_CODE := 0;
			
			END IF;
			
						  
			  
			END get_key_name;
			
			
			PROCEDURE get_secret (SECRET_NAME IN VARCHAR2, ENC_KEY_BYTES IN RAW, SECRET_BYTES OUT RAW, RETURN_CODE OUT NUMBER)
			IS
			v_secret_name             VARCHAR2(200)  := SECRET_NAME;  
			v_enc_key_bytes           VARCHAR2(200)  := ENC_KEY_BYTES;  
			v_encrypted_bytes         RAW(2000);
			v_encrypted_bytes_eval    RAW(2000);
			l_value                   NUMBER         := 0;
			v_secret_bytes            RAW(2000);
			v_verification_hash       RAW(2000);
			v_verification_eval       RAW(2000);
			v_encryption_alg          VARCHAR2(200);
			v_verification_hash_alg   VARCHAR2(200);
			l_sql_txt                 VARCHAR2(4000);
					
			
			
			BEGIN
			
						
			
			check_secret(v_secret_name ,l_value);
			 IF l_value = 1 THEN
			  RETURN_CODE := 1;			
							
			ELSE	
					
			l_sql_txt := 'SELECT ENCRYPTED_BYTES,VERIFICATION_HASH,ENCRYPTION_ALG,VERIFICATION_HASH_ALG from '|| g_sec_inventory_tbl|| ' WHERE SECRET_NAME =:1';
			
			
			EXECUTE IMMEDIATE l_sql_txt INTO  v_encrypted_bytes, v_verification_hash, v_encryption_alg,v_verification_hash_alg USING v_secret_name; 
			
			v_secret_bytes  := decrypt_secret(v_encrypted_bytes, v_enc_key_bytes, v_encryption_alg);
			
			v_verification_eval := compute_hash(v_secret_bytes, v_enc_key_bytes, v_verification_hash_alg);
			 
			 IF (v_verification_eval = v_verification_hash) THEN
			 
			  
			  l_sql_txt := 'select substr(:1,(select length(salt)+1 from '||g_sec_inventory_tbl||' where secret_name=:2)) from dual';
			  execute immediate l_sql_txt  into SECRET_BYTES using v_secret_bytes, v_secret_name;
			  
			  
			  
			  dbms_output.put_line(' ENCRYPTION KEY MATCHES, RETURNING SECRET BYTES');
  			  RETURN_CODE :=0;

			 ELSE
			  RETURN_CODE := 3;
			  raise_application_error(-20999, ' VERIFICATION HASH MISMATCH - EITHER SECRET IS TAMPERED OR WRONG KEY IS PASSED !!! ');
			 
			 END IF ;
			 
			END IF ;
			
			
						
			  
			END get_secret;
			
			
FUNCTION encrypt_secret
	 (
	 p_inp in raw,
	 p_key in raw,
	 p_enc_val in varchar2
	 )
	 return raw is
	 l_enc_val raw (2000);
	 encryption_type    PLS_INTEGER ;
	 
	 begin
	 if ( p_enc_val = 'ENCRYPT_AES256' ) THEN
	 encryption_type    := DBMS_CRYPTO.ENCRYPT_AES256 + DBMS_CRYPTO.CHAIN_CBC + DBMS_CRYPTO.PAD_PKCS5;
	 ELSIF ( p_enc_val = 'ENCRYPT_AES192' ) THEN
	 encryption_type     := DBMS_CRYPTO.ENCRYPT_AES192 + DBMS_CRYPTO.CHAIN_CBC + DBMS_CRYPTO.PAD_PKCS5;
	 ELSIF ( p_enc_val = 'ENCRYPT_AES128' ) THEN
	 encryption_type     := DBMS_CRYPTO.ENCRYPT_AES128 + DBMS_CRYPTO.CHAIN_CBC + DBMS_CRYPTO.PAD_PKCS5;
	 ELSIF ( p_enc_val = 'ENCRYPT_3DES_2KEY' ) THEN
	 encryption_type     := DBMS_CRYPTO.ENCRYPT_3DES_2KEY + DBMS_CRYPTO.CHAIN_CBC + DBMS_CRYPTO.PAD_PKCS5;
 	 ELSIF ( p_enc_val = 'ENCRYPT_3DES' ) THEN
	 encryption_type     := DBMS_CRYPTO.ENCRYPT_3DES	+ DBMS_CRYPTO.CHAIN_CBC + DBMS_CRYPTO.PAD_PKCS5;
     ELSIF ( p_enc_val = 'ENCRYPT_RC4' ) THEN
	 encryption_type     := DBMS_CRYPTO.ENCRYPT_RC4 + DBMS_CRYPTO.CHAIN_CBC + DBMS_CRYPTO.PAD_PKCS5;
	 ELSIF ( p_enc_val = 'ENCRYPT_DES' ) THEN
	 encryption_type     := DBMS_CRYPTO.ENCRYPT_DES + DBMS_CRYPTO.CHAIN_CBC + DBMS_CRYPTO.PAD_PKCS5;
	 ELSE
	 	 raise_application_error(-20997, 'ENCRYPTION TYPE - ' || P_enc_val ||' IS NOT SUPPORTED. ONLY ENCRYPTION ALGORITHMS - "ENCRYPT_AES128", "ENCRYPT_AES192", "ENCRYPT_AES256", "ENCRYPT_DES", "ENCRYPT_3DES", "ENCRYPT_3DES_2KEY" and "ENCRYPT_RC4" ARE SUPPORTED' );
		 
	 END IF;
	 
	 l_enc_val := dbms_crypto.encrypt
	 (
	 p_inp,
	 encryption_type,
	 p_key
	 );
	 return  RAWTOHEX(l_enc_val);
	 
	END encrypt_secret;

	
    FUNCTION decrypt_secret
		(
		 p_inp in raw,
		 p_key in raw,
		 p_enc_val in varchar2
		 )
		 return raw
		 is
		 l_dec_val raw (2000);
         encryption_type    PLS_INTEGER;
	   
	   begin
	   
     if ( p_enc_val = 'ENCRYPT_AES256' ) THEN
	 encryption_type    := DBMS_CRYPTO.ENCRYPT_AES256 + DBMS_CRYPTO.CHAIN_CBC + DBMS_CRYPTO.PAD_PKCS5;
	 ELSIF ( p_enc_val = 'ENCRYPT_AES192' ) THEN
	 encryption_type     := DBMS_CRYPTO.ENCRYPT_AES192 + DBMS_CRYPTO.CHAIN_CBC + DBMS_CRYPTO.PAD_PKCS5;
	 ELSIF ( p_enc_val = 'ENCRYPT_AES128' ) THEN
	 encryption_type     := DBMS_CRYPTO.ENCRYPT_AES128 + DBMS_CRYPTO.CHAIN_CBC + DBMS_CRYPTO.PAD_PKCS5;
	 ELSIF ( p_enc_val = 'ENCRYPT_3DES_2KEY' ) THEN
	 encryption_type     := DBMS_CRYPTO.ENCRYPT_3DES_2KEY + DBMS_CRYPTO.CHAIN_CBC + DBMS_CRYPTO.PAD_PKCS5;
 	 ELSIF ( p_enc_val = 'ENCRYPT_3DES' ) THEN
	 encryption_type     := DBMS_CRYPTO.ENCRYPT_3DES	+ DBMS_CRYPTO.CHAIN_CBC + DBMS_CRYPTO.PAD_PKCS5;
     ELSIF ( p_enc_val = 'ENCRYPT_RC4' ) THEN
	 encryption_type     := DBMS_CRYPTO.ENCRYPT_RC4 + DBMS_CRYPTO.CHAIN_CBC + DBMS_CRYPTO.PAD_PKCS5;
	 ELSIF ( p_enc_val = 'ENCRYPT_DES' ) THEN
	 encryption_type     := DBMS_CRYPTO.ENCRYPT_DES + DBMS_CRYPTO.CHAIN_CBC + DBMS_CRYPTO.PAD_PKCS5;
	 END IF;
	    
		l_dec_val := dbms_crypto.decrypt
		(
		 HEXTORAW(p_inp),
		 encryption_type,
		 p_key
		);
	   return l_dec_val;
	END decrypt_secret;
	
	FUNCTION generate_salt return raw is 
    num_key_bytes   NUMBER := 256/8;  
    rndm_bytes      RAW (32); 
    
    begin
     rndm_bytes      := DBMS_CRYPTO.RANDOMBYTES (num_key_bytes);
	  
    return rndm_bytes;

    END generate_salt;
	

	FUNCTION compute_hash (p_inp in raw, p_key in raw, p_verification_hash_alg in varchar2)	return raw
	is
	l_hash_val raw (2000);
	verification_hash_alg PLS_INTEGER;
	
	begin
	IF ( p_verification_hash_alg = 'HMAC_SH256' ) THEN
	 verification_hash_alg    := DBMS_CRYPTO.HMAC_SH256;
	 ELSIF ( p_verification_hash_alg = 'HMAC_SH384' ) THEN
	   verification_hash_alg    := DBMS_CRYPTO.HMAC_SH384;
	 ELSIF ( p_verification_hash_alg = 'HMAC_SH512' ) THEN
	   verification_hash_alg    := DBMS_CRYPTO.HMAC_SH512;
	 ELSIF ( p_verification_hash_alg = 'HMAC_MD5' ) THEN
	   verification_hash_alg     := DBMS_CRYPTO.HMAC_MD5;
 	 ELSIF ( p_verification_hash_alg = 'HMAC_SH1' ) THEN
	  verification_hash_alg     := DBMS_CRYPTO.HMAC_SH1;
	 END IF;
	 
		l_hash_val := dbms_crypto.mac(
			  p_inp,
			  verification_hash_alg,
			  P_key );
		return l_hash_val;
	END compute_hash;

	
END ouaf_security;
/