cryptography ip-cores in vhdl / verilog
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
2.8 KiB

  1. -- ======================================================================
  2. -- DES encryption/decryption
  3. -- algorithm according to FIPS 46-3 specification
  4. -- Copyright (C) 2011 Torsten Meissner
  5. -------------------------------------------------------------------------
  6. -- This program is free software; you can redistribute it and/or modify
  7. -- it under the terms of the GNU General Public License as published by
  8. -- the Free Software Foundation; either version 2 of the License, or
  9. -- (at your option) any later version.
  10. -- This program is distributed in the hope that it will be useful,
  11. -- but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. -- GNU General Public License for more details.
  14. -- You should have received a copy of the GNU General Public License
  15. -- along with this program; if not, write to the Free Software
  16. -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. -- ======================================================================
  18. -- Revision 1.0 2011/09/17
  19. -- Initial release
  20. library ieee;
  21. use ieee.std_logic_1164.all;
  22. use ieee.numeric_std.ALL;
  23. entity tb_des is
  24. end entity tb_des;
  25. architecture rtl of tb_des is
  26. signal s_clk : std_logic : := '0';
  27. signal s_des1_key : std_logic_vector(0 to 63);
  28. signal s_des1_datain : std_logic_vector(0 to 63);
  29. signal s_des1_validin : std_logic;
  30. signal s_des1_dataout : std_logic_vector(0 to 63);
  31. signal s_des1_validout : std_logic;
  32. signal s_des2_key : std_logic_vector(0 to 63);
  33. signal s_des2_dataout : std_logic_vector(0 to 63);
  34. signal s_des2_validout : std_logic;
  35. component des is
  36. port (
  37. clk_i : IN std_logic;
  38. mode_i : IN std_logic; -- des-modus: 0 = encrypt, 1 = decrypt
  39. key_i : IN std_logic_vector(0 TO 63);
  40. data_i : IN std_logic_vector(0 TO 63);
  41. valid_i : IN std_logic;
  42. data_o : OUT std_logic_vector(0 TO 63);
  43. valid_o : OUT std_logic
  44. );
  45. end component des;
  46. begin
  47. s_clk <= not(s_clk) after 10 ns;
  48. testinputP : process is
  49. begin
  50. for index in 0 to 31 loop
  51. wait until s_clk = '1';
  52. s_valid <= '1';
  53. s_mode
  54. end process testinputP;
  55. testoutputP : process is
  56. begin
  57. wait until s_clk = '1';
  58. end process testoutputP;
  59. i1_des : des
  60. port map (
  61. clk_i => s_clk,
  62. mode_i => '0',
  63. key_i => s_des1_key,
  64. data_i => s_des1_datain,
  65. valid_i => s_des1_validin,
  66. data_o => s_des1_dataout,
  67. valid_o => s_des1_validout
  68. );
  69. i2_des : des
  70. port map (
  71. clk_i => s_clk,
  72. mode_i => '1',
  73. key_i => s_des2_key,
  74. data_i => s_des1_dataout,
  75. valid_i => s_des1_validout,
  76. data_o => s_des2_dataout,
  77. valid_o => s_des2_validout
  78. );
  79. end architecture rtl;