Solution de W1tch3d pour Sbox

intro hardware

10 mars 2024

Description

Cette épreuve nous propose de nous familiariser avec les circuits logiques. Ici le schéma nous propose 2 fonctions logiques NOR (Fonction NON-OU) et XOR (Fonction OU exclusif).

Table de vérité OU-NON - NOR 
Entrées----------->Sortie
0 NOR 0----------->1
0 NOR 1----------->0
1 NOR 0----------->0
1 NOR 1----------->0
Table de vérité de OU EXCLUSIF - XOR
Entrées------>Sortie
0 xor 0------>0
0 xor 1------>1
1 xor 0------>1
1 xor 1------>0

Petit script en powershell

#les entrées
$x3=1
$x2=0
$x1=1
$x0=0

#la fonction XOR
function xor
{
    Param($ch1,$ch2)
    if ($ch1 -ne $ch2 ){return "1"}
    else {return "0"}
}

#la fonction NOR
function nor
{
    Param($ch1,$ch2)
    if ($ch1 -eq 0 -and $ch2 -eq 0 ){return "1"}
    if ($ch1 -eq 0 -and $ch2 -eq 1 ){return "0"}
    if ($ch1 -eq 1 -and $ch2 -eq 0 ){return "0"} 
    if ($ch1 -eq 1 -and $ch2 -eq 1 ){return "0"}
}

#la traduction du schéma
$y3=xor($x0,(nor($x3,$x2)))
$y2=xor($x3,(nor($x2,$x1)))
$y1=xor($x2,(nor($x1,$y3)))
$y0=xor($x1,(nor($y3,$y2)))

write-host les entrées sont x3=$x3 x2=$x2 x1=$x1 x0=$x0
write-host "la solution est FCSC`{$y3,$y2,$y1,$y0`}"

Le script nous affiche comme sortie:

les entrées sont x3=1 x2=0 x1=1 x0=0
la solution est FCSC{0,1,0,1}