HDL Code Obfuscation

Introduction

Aldec provides the script to convert VHDL, Verilog, and SystemVerilog code into obfuscated code. HDL Code Obfuscation is beneficial for users who wish to obscure the contents of their code from other users. The obfuscated code is unreadable to the receiving user, but is still readable to compilers and simulators. This is especially useful in cases where a user has a particular source file that needs to be debugged, but does not want the recipient to see the contents of the actual file.

Script for Obfuscation

Aldec provides a script that obfuscates files depending on the specific need of the user. The obfuscator_procedure.tcl script contains the following commands:

  1. obfuscator.vhdlfile

  2. obfuscator.verilogfile

  3. obfuscator.dir

NOTE: The obfuscator_procedure.tcl script can be downloaded from our website at: http://www.aldec.com/downloads/private/409.

How to execute the Tcl script

  1. Pass the contents of the obfuscator_procedures.tcl file to the Tcl interpreter:

    source obfuscator_procedures.tcl
    
  2. Invoke the required procedure in the following format:

    obfuscator.vhdlfile <source_file> <obfuscated_file>
    obfuscator.verilogfile <source_file> <obfuscated_file>
    obfuscator.dir <source_directory> <target_directory>
    

NOTE: To use the obfuscator_procedures.tcl script in Active-HDL, the working mode of the command interpreter must be set to the Tcl mode. To do so, invoke the scripterconf command with the -tcl argument.

Obfuscator commands

These commands can also be used independently in the Console window of Active-HDL, Riviera-PRO, and ALINT.

obfuscator.vhdlfile/obfuscator.verilogfile

These commands are used to transform a single VHDL/Verilog/SystemVerilog file into obfuscated code. The user-defined identifiers are replaced with their md5 hash value, all comments are removed, and the code formatting is distorted.

To transform a file, please use the following syntax:

obfuscator.vhdlfile <source_file> <obfuscated_file>

or

obfuscator.verilogfile <source_file> <obfuscated_file>

VHDL Example

This is a portion of code before obfuscation:

component AND2
	port (
		I0 : in STD_LOGIC;
		I1 : in STD_LOGIC;
		O : out STD_LOGIC);
end component;

component INV
	port (
		I : in STD_LOGIC;
		O : out STD_LOGIC);
end component;

component BIN2BCD
	port (
		BIN : in STD_LOGIC_VECTOR (4 downto 0);
		BCD_H : out STD_LOGIC_VECTOR (1 downto 0);
		BCD_L : out STD_LOGIC_VECTOR (3 downto 0));
end component;

This is the portion of code after obfuscation:

 component IE78B0DC123245A66D28424B7441786C2  port ( IA9E26254E651465C89FF715D5733E97C : in std_logic ; I9CE88802F07591E5CE0457EF51ECE021 :
in std_logic ; ID95679752134A2D9EB61DBD7B91C4BCC : out std_logic ); end component ; component I545F7F577C93318B34476E9999931731 
port ( I865C0C0B4AB0E063E5CAA3387C1A8741 : in std_logic ; ID95679752134A2D9EB61DBD7B91C4BCC : out std_logic ); end component ;
component IE204BDD6D6610E296B5C4727A490693E  port ( IC1111BD512B29E821B120B86446026B8 : in std_logic_vector (4 downto 0);
I2E082C56D8BBC0B0C0A888AD7A5D6A4B : out std_logic_vector (1 downto 0); I0695DFE458CCCA4B0E57C8660F3873DF : out std_logic_vector (3
downto 0)); end component ;

Verilog Example

This is a portion of code before obfuscation:

module BIN2BCD (BIN, BCD_H, BCD_L);
input  [4:0]BIN;
output [1:0]BCD_H;
output [3:0]BCD_L;

assign BCD_L = (BIN == 5'b00001 || BIN == 5'b01011 || BIN == 5'b10101 || BIN == 5'b11111) ? 4'b0001 :
			   (BIN == 5'b00010 || BIN == 5'b01100 || BIN == 5'b10110) ? 4'b0010 :
			   (BIN == 5'b00011 || BIN == 5'b01101 || BIN == 5'b10111) ? 4'b0011 :
			   (BIN == 5'b00100 || BIN == 5'b01110 || BIN == 5'b11000) ? 4'b0100 :
			   (BIN == 5'b00101 || BIN == 5'b01111 || BIN == 5'b11001) ? 4'b0101 :
			   (BIN == 5'b00110 || BIN == 5'b10000 || BIN == 5'b11010) ? 4'b0110 :
			   (BIN == 5'b00111 || BIN == 5'b10001 || BIN == 5'b11011) ? 4'b0111 :
			   (BIN == 5'b01000 || BIN == 5'b10010 || BIN == 5'b11100) ? 4'b1000 :
			   (BIN == 5'b01001 || BIN == 5'b10011 || BIN == 5'b11101) ? 4'b1001 :
			   4'b0000 ;

assign BCD_H = (BIN < 5'd10) ? 2'b00 :
			   (BIN < 5'd20) ? 2'b01 :
			   (BIN < 5'd30) ? 2'b10 :
			   2'b11 ;

endmodule

This is the portion of code after obfuscation:

module I36DFB826C984926D0D99D7A8CAFBF71F (I35D3245A21B0942070419EF6602D239E , IF755C48F393913F48C1C13D3F07E3D62 ,
I3F74699ECAB4A004DA8DEDDEB9AB9B49 ); input [4:0]I35D3245A21B0942070419EF6602D239E ; output [1:0]IF755C48F393913F48C1C13D3F07E3D62 ;
output [3:0]I3F74699ECAB4A004DA8DEDDEB9AB9B49 ; assign I3F74699ECAB4A004DA8DEDDEB9AB9B49 = (I35D3245A21B0942070419EF6602D239E
== 5'b00001 || I35D3245A21B0942070419EF6602D239E == 5'b01011 || I35D3245A21B0942070419EF6602D239E == 5'b10101 ||
I35D3245A21B0942070419EF6602D239E == 5'b11111) ? 4'b0001 : (I35D3245A21B0942070419EF6602D239E == 5'b00010 || I35D3245A21B0942070419EF6602D239E
== 5'b01100 || I35D3245A21B0942070419EF6602D239E == 5'b10110) ? 4'b0010 : (I35D3245A21B0942070419EF6602D239E ==
5'b00011 || I35D3245A21B0942070419EF6602D239E == 5'b01101 || I35D3245A21B0942070419EF6602D239E == 5'b10111) ? 4'b0011
: (I35D3245A21B0942070419EF6602D239E == 5'b00100 || I35D3245A21B0942070419EF6602D239E == 5'b01110 || I35D3245A21B0942070419EF6602D239E
== 5'b11000) ? 4'b0100 : (I35D3245A21B0942070419EF6602D239E == 5'b00101 || I35D3245A21B0942070419EF6602D239E ==
5'b01111 || I35D3245A21B0942070419EF6602D239E == 5'b11001) ? 4'b0101 : (I35D3245A21B0942070419EF6602D239E == 5'b00110
|| I35D3245A21B0942070419EF6602D239E == 5'b10000 || I35D3245A21B0942070419EF6602D239E == 5'b11010) ? 4'b0110 : (I35D3245A21B0942070419EF6602D239E
== 5'b00111 || I35D3245A21B0942070419EF6602D239E == 5'b10001 || I35D3245A21B0942070419EF6602D239E == 5'b11011) ?
4'b0111 : (I35D3245A21B0942070419EF6602D239E == 5'b01000 || I35D3245A21B0942070419EF6602D239E == 5'b10010 || I35D3245A21B0942070419EF6602D239E
== 5'b11100) ? 4'b1000 : (I35D3245A21B0942070419EF6602D239E == 5'b01001 || I35D3245A21B0942070419EF6602D239E ==
5'b10011 || I35D3245A21B0942070419EF6602D239E == 5'b11101) ? 4'b1001 : 4'b0000 ; assign IF755C48F393913F48C1C13D3F07E3D62
= (I35D3245A21B0942070419EF6602D239E < 5'd10) ? 2'b00 : (I35D3245A21B0942070419EF6602D239E < 5'd20) ? 2'b01 : (I35D3245A21B0942070419EF6602D239E
< 5'd30) ? 2'b10 : 2'b11 ; endmodule

obfuscator.dir

This command searches for HDL files located in the specified source directory, and replaces all identifiers in the code with their md5 hash value.

NOTE: The contents of the source directory are not modified

To obfuscate a specific source directory, please use the following syntax:

obfuscator.dir <source_dir> <target_dir>
Ask Us a Question
x
Ask Us a Question
x
Captcha ImageReload Captcha
Incorrect data entered.
Thank you! Your question has been submitted. Please allow 1-3 business days for someone to respond to your question.
Internal error occurred. Your question was not submitted. Please contact us using Feedback form.
We use cookies to ensure we give you the best user experience and to provide you with content we believe will be of relevance to you. If you continue to use our site, you consent to our use of cookies. A detailed overview on the use of cookies and other website information is located in our Privacy Policy.