diff options
author | Andreas Müller <andreas.mueller@ost.ch> | 2021-06-14 07:26:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-14 07:26:10 +0200 |
commit | 114633b43a0f1ebedbc5dfd85f75ede9841f26fd (patch) | |
tree | 18e61c7d69883a1c9b69098b7d36856abaed5c1e /buch/chapters/90-crypto/images/sbox.m | |
parent | Delete buch.pdf (diff) | |
parent | Fix references.bib (diff) | |
download | SeminarMatrizen-114633b43a0f1ebedbc5dfd85f75ede9841f26fd.tar.gz SeminarMatrizen-114633b43a0f1ebedbc5dfd85f75ede9841f26fd.zip |
Merge branch 'master' into master
Diffstat (limited to '')
-rw-r--r-- | buch/chapters/90-crypto/images/sbox.m | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/buch/chapters/90-crypto/images/sbox.m b/buch/chapters/90-crypto/images/sbox.m new file mode 100644 index 0000000..973ffc9 --- /dev/null +++ b/buch/chapters/90-crypto/images/sbox.m @@ -0,0 +1,52 @@ +# +# sbox.m +# +# (c) 2021 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule +# +A=[ +1,0,0,0,1,1,1,1; +1,1,0,0,0,1,1,1; +1,1,1,0,0,0,1,1; +1,1,1,1,0,0,0,1; +1,1,1,1,1,0,0,0; +0,1,1,1,1,1,0,0; +0,0,1,1,1,1,1,0; +0,0,0,1,1,1,1,1; +] + +R = zeros(8,16); +R(:,1:8) = A; +R(:,9:16) = eye(8); + +for k = (1:5) + for i=(k+1:8) + pivot = R(i,k); + R(i,:) = R(i,:) + pivot * R(k,:); + end + R = mod(R, 2) +end + +P = [ +1,0,0,0,0,0,0,0; +0,1,0,0,0,0,0,0; +0,0,1,0,0,0,0,0; +0,0,0,1,0,0,0,0; +0,0,0,0,1,0,0,0; +0,0,0,0,0,0,0,1; +0,0,0,0,0,1,0,0; +0,0,0,0,0,0,1,0; +] + +R = P * R + +for k = (8:-1:2) + for i = (1:k-1) + pivot = R(i,k); + R(i,:) = R(i,:) + pivot * R(k,:); + end + R = mod(R, 2) +end + +B = R(:,9:16) + +A * B |