rendered paste body----------------------------------------------------------------------------------
-- Autor: Martin Gaitan
-- Objetivo: generador de claves para Simple-DES
-- Descripción: recibe una clave de 10bits,
--1) proceso de permutación P10
-- --------------------
-- P10
-- 3 5 2 7 4 10 1 9 8 6
-- --------------------
--2) Tanto el nibble superior como el inferior sufren un shift izq de 1 bit
--
-- => Para obtener k1, luego se vuelven a unir. (
-- 1 2 3 4 5 | 6 7 8 9 10 )
-- i5 i2 i7 i4 i3 | i1 i9 i8 i6 i10 )
--
-- 3) La union de ambos nibbles concatenados sufren P8
--
-- ------------------
-- P8
-- 6 3 7 4 8 5 10 9
-- ------------------
-- => k1 <= i1 i7 i4 i8 i3 i10 i6
--
-- Los nibbles luego de P10 y la primer rotacion de 1bit, sufre una nueva rotacion de 2bits
--
-- 1 2 3 4 5 | 6 7 8 9 10 )
-- i7 i4 i3 i5 i2 | i8 i6 i10 i1 i9 )
--
--- Aplicando P8
-- => k2 <= i8 i3 i6 i5 i10 i2 i9 i1
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity keygen is
Port (
i: in STD_LOGIC_VECTOR (0 to 9);
k1 : out STD_LOGIC_VECTOR (0 to 7);
k2 : out STD_LOGIC_VECTOR (0 to 7));
end keygen;
architecture Behavioral of keygen is
begin
k1 <= i(1) & i(7) & i(4) & i(8) & i(3) & i(10) & i(6);
k2 <= i(8) & i(3) & i(6) & i(5) & i(10) & i(2) & i(9) & i(1);
-- k1 <= port map (i(1),i(7),i(4),i(8),i(3),i(10),i(6));
-- k2 <= port map (i(8),i(3),i(6),i(5),i(10),i(2),i(9),i(1));
end Behavioral;