SlideShare une entreprise Scribd logo
1  sur  12
Télécharger pour lire hors ligne
Eskişehir Osmangazi Üniversitesi




Enigma Otomata Projesi ve
Yazılım Gerçeklemesi

Prepared for: Yrd.Doç.Dr.Ahmet Yazıcı
Prepared by: Serkan Danışan, Mahmut Bulut, Tuğrul Boztepe

May 28, 2012




Eskişehir Osmangazi Üniversitesi Bilgisayar Mühendisliği Bölümü
Eskişehir Osmangazi Üniversitesi




Proje İçeriği

Enigma Önbilgisi
                                                                                      i
  Enigmanın Tarihçesi, Kullanım Yerleri ve Bilgisayar Bilimine Etkisi
                                 i
  Mekanik Enigma Makinesinin Çalışma Prensibi
                                                         i
DFA Yapısına İndirgeme
                                                                              ii
  ROT-N şifrelemesinin ve Enigma Makinesinin indirgenmesi
                                           ii
     Kodlama Tipi
                                                                                   ii
     Genel DFA
                                                                                      ii
Kodlar
                                                                                             iii
  Proje Adı
                                                                                        iii
  ROT-N Mantığının Kodlanması
                                                                      iii
  Enigma Mantığının Kodlanması
                                                                     vi




Enigma Otomata Projesi ve Yazılım Gerçeklemesi
                                                        i
Eskişehir Osmangazi Üniversitesi




Enigma Önbilgisi

Enigmanın Tarihçesi, Kullanım Yerleri ve Bilgisayar Bilimine Etkisi
 II. Dünya Savaşında Almanya tarafından gizli mesajların şifrelenmesi ve tekrar çözülmesi amacı ile kullanılan bir şifre makinesi
olan ve Rotor makineleri sayesinde çalışan Elektro-Mekanik aygıttı.Bu makineyı ünlü bilim adamı Alan Turning
keşfetmiştir.Enigma makinasının birçok türü vardı ve birçok ordu için 1920 li yıllardan başlayarak üretildi.Ancak en çok tarihte
bahsedilen modeli Alman ordusunda kullanılan Wehrmacht Enigma modeliydi.Bu makina almanlar için yararlı gibi görünse de
zamanla zararlı yönü ortaya çıktı. ll.Dünya savaşı ülkelerinden Polonya ve İngiltere tarafından mesajlar çözümlendi.Bu müttefik
ülkelerin savaşı kazanmasında bu çözümlümenin oldukça büyük bir payı vardı.Enigmanın dünya bilimindeki diğer önemli rolü
de şifre çözücü bu makinenin bilgisayar biliminin temelini atmış olmasıdır.


Mekanik Enigma Makinesinin Çalışma Prensibi
Enigma makinesinin işleyişi, düz yazı harflerini şifreli yazı harflerine çeviren 3 ROTORlu bir sistem üzerine kurulmuştur.Rotorlar
diğer rotorlar ile kendi eksenleri etrafında dönerler, böylece yer değiştirme işlemini tamamlarlar. Makinenin klavyesinde bir
harfe basıldığı zaman, önce ilk rotora gönderilir ve makinenin o andaki ayarına göre o harf değiştirilir(başka bir harf ile). Yeni
harf, o andaki ayarına göre dönüştürülecek harf ile yer değiştireceği ikinci rotora geçer. Bu yeni harf üçüncü rotora dönüşerek
geçecek, yine uygun olanla yer değiştirecektir. Sonra, bu yeni harf bir yansıtıcıdan yansıyacak ve 3 rotordan da ters sırayla
geçecektir. Enigmayı zamanında bu kadar güçlü yapan rotorlarının kendi eksenleri etrafında dönmeleriydi. Düz metin harfi ilk
rotordan geçtiğinde ilk rotor bir kere dönecekti. Diğer, ikinci rotor ilk rotor 26 kez(alman alfabesi için) dönene kadar sabit ve
hareketsiz(fonksiyonsuz) kalacaktı. Sonra ikinci rotor harekete başlıyacaktı. İkinci rotor 26 kere döndüğünde(26×26 harf, ilk
rotor 26 kez dönmüştü sonra ilk rotor ikinci 26′yı tamamladığında ikinci rotorda bir kez 26yı tamamlamış oldu ), üçüncü
rotorda 1 yönde hareket edecekti. Döngü bütün mesajın uzunluğu kadar bunun gibi devam edecekti.Sonuç değiştirilen
dönüşüm olarak karşımıza çıkacaktı. Diğer bir deyişle, bir “s” ilk bölümde “b” olarak kodlanabilir oluyor, ama mesajın ilerleyen
bölümlerinde “m” olarak da karşımıza çıkabiliyordu. Rotorların dönmesi prensibi 26x26x26 = 17576 mümkün pozisyona izin
veriyordu.




Enigma Otomata Projesi ve Yazılım Gerçeklemesi
                                                                                          i
Eskişehir Osmangazi Üniversitesi




DFA Yapısına İndirgeme

ROT-N şifrelemesinin ve Enigma Makinesinin indirgenmesi

Kodlama Tipi
Programımız’da ise ROT13 şifreleme yöntemi(Sezar yöntemi) ve Wehrmacht Enigma’nın yazılım olarak modellenmiş şekli
Java programlama dilinde kodlandı ve arayüz ile sunuldu.

Genel DFA
ROT13 sistemi ve enigma makinesinin DFA’i aşağıda gösterilmiştir.





                    
     Harflere Ayrıştırma                         Rotor(Öteleme)




Enigma Otomata Projesi ve Yazılım Gerçeklemesi
                                                                             ii
Eskişehir Osmangazi Üniversitesi




Enigma’nın çalışma sistemi kısaca şöyledir;

Şifrelenecek kod başta starting state olarak alınır.Daha sonra alınan string harflerine ayrıştırılır.Ayrıştırılan harfler rötor sistemi ile
alfabede diğer harflere atanır.Enigmanın içinde bu rötor sistemlerinden çokça vardır.Alınan stringin harfleri tüm bu rötor işlem-
lerinden geçtikten sonra tekrar başka bir string(kodlanmış string) olarak alıcıya gönderilir.



Kodlar

Proje Adı
Projemizin adını “trenigma” olarak belirledik. “Kodlar” başlığında belirtilen kodların tamamı bu projenin paketlerinin içinde
halihazırda bulunmaktadır.


ROT-N Mantığının Kodlanması
Rot-N kodlaması(genellikle 13 harf öteleme kullanılır) enigma makinesinin temeli olup tarafımızca kodlaması şöyledir:

Rotter.java kaynak dosyasında Rotter sınıfı constructor’ında argüman olarak öteleme sayısını alacak şekilde(ROT-N’deki N)
yazımı:

public class Rotter {

      public Rotter(String str) {

            s = str;

      }

      public String rotter(int rotadd) {

            StringBuilder strbld = new StringBuilder("");

            for (int i = 0; i < s.length(); i++) {

                  char c = s.charAt(i);

                  if (c >= 'a' && c <= 'm') {

                        c += rotadd;

                  } else if (c >= 'n' && c <= 'z') {

                        c -= rotadd;

                  } else if (c >= 'A' && c <= 'M') {
Enigma Otomata Projesi ve Yazılım Gerçeklemesi
                                                                                            iii
Eskişehir Osmangazi Üniversitesi




                      c += rotadd;

                  } else if (c >= 'A' && c <= 'Z') {

                      c -= rotadd;

                  }

                  strbld.append(c);

           }

           return strbld.toString();

     }

     public String getString(){

           return this.s;

     }

     public void rotterlayered(int rotad, int layer) {

           do {

                  rotter(rotad);

                  layer--;

           } while (layer != 0);

     }

     private String s;

}

GUI’deki seçimi yaparak encode işlemini gerçekleştiren kod:

           if (Rot.getText() != "") {

                  Rotter rot = new Rotter(Rot.getText());

                  if (jComboBox1.getSelectedIndex() == 0) {

                      RotOut.setText(rot.rotter(1));

                  } else if (jComboBox1.getSelectedIndex() == 1) {

                      RotOut.setText(rot.rotter(2));

Enigma Otomata Projesi ve Yazılım Gerçeklemesi
                                                iv
Eskişehir Osmangazi Üniversitesi




               } else if (jComboBox1.getSelectedIndex() == 2) {

                     RotOut.setText(rot.rotter(3));

               } else if (jComboBox1.getSelectedIndex() == 3) {

                     RotOut.setText(rot.rotter(4));

               } else if (jComboBox1.getSelectedIndex() == 4) {

                     RotOut.setText(rot.rotter(5));

               } else if (jComboBox1.getSelectedIndex() == 5) {

                     RotOut.setText(rot.rotter(6));

               } else if (jComboBox1.getSelectedIndex() == 6) {

                     RotOut.setText(rot.rotter(7));

               } else if (jComboBox1.getSelectedIndex() == 7) {

                     RotOut.setText(rot.rotter(8));

               } else if (jComboBox1.getSelectedIndex() == 8) {

                     RotOut.setText(rot.rotter(9));

               } else if (jComboBox1.getSelectedIndex() == 9) {

                     RotOut.setText(rot.rotter(10));

               } else if (jComboBox1.getSelectedIndex() == 10) {

                     RotOut.setText(rot.rotter(11));

               } else if (jComboBox1.getSelectedIndex() == 11) {

                     RotOut.setText(rot.rotter(12));

               } else if (jComboBox1.getSelectedIndex() == 12) {

                     RotOut.setText(rot.rotter(13));

               }

               str = Rot.getText();

               Rot.setText("");

          }

Enigma Otomata Projesi ve Yazılım Gerçeklemesi
                                               v
Eskişehir Osmangazi Üniversitesi




Enigma Mantığının Kodlanması
Enigma Mantığı ise Enigma.java içerisindeki “Enigma” sınıfında eski 3 rotorlu mekanik makinedeki rotorların İngiliz
alfabesindeki karşılığı baz alınarak, ayrıca “reflector” denen 3.rotoun şifrelemesini karşı tarafın çözmesini zorlaştımak için
ROT-1 işlemi yaparak 1 kademe çözen 4. dişliyi de içinde bulundurmaktadır ve bu karşılıklar kodun içine gömülmüştür. Ayrıca
kodumuz 6 rotorlu sistemi de içinde bulundurmakta ama kullanmamaktadır, kullanmak için yorum satırlarını kaldırıp 3’lü rotor
atamalarını silmemiz ve birkaç küçük değişiklik 1 yapmamız yeterlidir:

public class Enigma {

/*

        public static final Rotor ROTOR_I = new Rotor(new char[]{'E', 'K', 'M', 'F', 'L',
'G', 'D', 'Q', 'V', 'Z', 'N', 'T', 'O', 'W', 'Y', 'H', 'X', 'U', 'S', 'P', 'A', 'I', 'B',
'R', 'C', 'J'});

        public static final Rotor ROTOR_II = new Rotor(new char[]{'A', 'J', 'D', 'K', 'S',
'I', 'R', 'U', 'X', 'B', 'L', 'H', 'W', 'T', 'M', 'C', 'Q', 'G', 'Z', 'N', 'P', 'Y', 'F',
'V', 'O', 'E'});

        public static final Rotor ROTOR_III = new Rotor(new char[]{'B', 'D', 'F', 'H', 'J',
'L', 'C', 'P', 'R', 'T', 'X', 'V', 'Z', 'N', 'Y', 'E', 'I', 'W', 'G', 'A', 'K', 'M', 'U',
'S', 'Q', 'O'});

        public static final Rotor ROTOR_IV = new Rotor(new char[]{'E', 'S', 'O', 'V', 'P',
'Z', 'J', 'A', 'Y', 'Q', 'U', 'I', 'R', 'H', 'X', 'L', 'N', 'F', 'T', 'G', 'K', 'D', 'C',
'M', 'W', 'B'});

        public static final Rotor ROTOR_V = new Rotor(new char[]{'V', 'Z', 'B', 'R', 'G',
'I', 'T', 'Y', 'U', 'P', 'S', 'D', 'N', 'H', 'L', 'X', 'A', 'W', 'M', 'J', 'Q', 'O', 'F',
'E', 'C', 'K'});

        public static final Rotor ROTOR_VI = new Rotor(new char[]{'J', 'P', 'G', 'V', 'O',
'U', 'M', 'F', 'Y', 'Q', 'B', 'E', 'N', 'H', 'Z', 'R', 'D', 'K', 'A', 'S', 'X', 'L', 'I',
'C', 'T', 'W'});

        public static final Rotor ROTOR_VII = new Rotor(new char[]{'N', 'Z', 'J', 'H', 'G',
'R', 'C', 'X', 'M', 'Y', 'S', 'W', 'B', 'O', 'U', 'F', 'A', 'I', 'V', 'L', 'P', 'E', 'K',
'Q', 'D', 'T'});

        public static final Rotor ROTOR_VIII = new Rotor(new char[]{'F', 'K', 'Q', 'H', 'T',
'L', 'X', 'O', 'C', 'B', 'J', 'S', 'P', 'D', 'Z', 'R', 'A', 'M', 'E', 'W', 'N', 'I', 'U',
'Y', 'G', 'V'});


1   Kodun logic yapısı değişmemekle birlikte encode() fonksiyonunun içine rotorlar eklenmeli ve rotorlar public olarak deklare
edilmelidir.
Enigma Otomata Projesi ve Yazılım Gerçeklemesi
                                                                                      vi
Eskişehir Osmangazi Üniversitesi




     public static final Rotor ROTOR_BETA = new Rotor(new char[]{'L', 'E', 'Y', 'J', 'V',
'C', 'N', 'I', 'X', 'W', 'P', 'B', 'Q', 'M', 'D', 'R', 'T', 'A', 'K', 'Z', 'G', 'F', 'U',
'H', 'O', 'S'});

     public static final Rotor ROTOR_GAMMA = new Rotor(new char[]{'F', 'S', 'O', 'K', 'A',
'N', 'U', 'E', 'R', 'H', 'M', 'B', 'T', 'I', 'Y', 'C', 'W', 'L', 'Q', 'P', 'Z', 'X', 'V',
'G', 'J', 'D'});*/




     // World War I: Enigma 1st encoding rotor scheme

     private char[][] rotor1 = {{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'},

          {'G', 'T', 'U', 'B', 'Z', 'Y', 'V', 'J', 'L', 'K', 'S', 'A', 'W', 'X', 'H', 'C',
'D', 'E', 'M', 'N', 'O', 'P', 'Q', 'R', 'I', 'F'}};

     // {G,T,U,B,Z,Y,V,J,L,K,S,A,W,X,H,C,D,E,M,N,O,P,Q,R,I,F}

     private char[][] rotor2 = {{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'},

          {'L', 'C', 'D', 'G', 'Y', 'U', 'B', 'Z', 'S', 'V', 'J', 'E', 'M', 'A', 'W', 'X',
'H', 'N', 'O', 'P', 'Q', 'R', 'I', 'F', 'T', 'K'}};

     // {L,C,D,G,Y,U,B,Z,S,V,J,E,M,A,W,X,H,N,O,P,Q,R,I,F,T,K}

     private char[][] rotor3 = {{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'},

          {'S', 'V', 'J', 'E', 'M', 'W', 'X', 'L', 'N', 'A', 'B', 'H', 'C', 'O', 'P', 'Q',
'R', 'I', 'F', 'Y', 'D', 'G', 'T', 'U', 'Z', 'K'}};

     // {S,V,J,E,M,W,X,L,N,A,B,H,C,O,P,Q,R,I,F,Y,D,G,T,U,Z,K}

     private char[][] reflector = {{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'},

          {'Y', 'R', 'U', 'H', 'Q', 'S', 'L', 'D', 'P', 'X', 'N', 'G', 'O', 'K', 'M', 'I',
'E', 'B', 'F', 'Z', 'C', 'W', 'V', 'J', 'A', 'T'}};

     // {Y,R,U,H,Q,S,L,D,P,X,N,G,O,K,M,I,E,B,F,Z,C,W,V,J,A,T}




Enigma Otomata Projesi ve Yazılım Gerçeklemesi
                                                     vii
Eskişehir Osmangazi Üniversitesi




     public char encode(char uncodedLetter, char[][] getRotor) {

          for (int i = getRotor[0].length - 1; i >= 0; i--) {

               if (getRotor[0][i] == uncodedLetter) {

                     System.out.println("getRotor[0][X] object adress " +
getRotor.toString());

                     return getRotor[1][i];

               }

          }

          return '~';

     }




     public char decode(char codedLetter, char[][] getRotor) {

          for (int i = getRotor[1].length - 1; i >= 0; i--) {

               if (getRotor[1][i] == codedLetter) {

                     System.out.println("getRotor[1][X] object adress " +
getRotor.toString());

                     return getRotor[0][i];

               }

          }

          return '~';

     }




     public char rotoredAndReflected(char letter) {

          int i = 0;

          char result = encode(letter, rotor1);

          char result1 = encode(result, rotor2);



Enigma Otomata Projesi ve Yazılım Gerçeklemesi
                                                      viii
Eskişehir Osmangazi Üniversitesi




          char result2 = encode(result1, rotor3);

          char backthrough1 = decode(result2, reflector);

          char backthrough2 = decode(backthrough1, rotor3);

          char backthrough3 = decode(backthrough2, rotor2);

          {

               this.encode(letter, rotor1);

               rotor2[0][i] = result;

               this.encode(result, rotor2);

               rotor3[0][i] = result1;

               this.encode(result1, rotor3);

               reflector[0][i] = result2;

               this.encode(result2, reflector);

               rotor3[0][i] = backthrough1;

               this.decode(backthrough1, rotor3);

               rotor2[0][i] = backthrough2;

               this.decode(backthrough2, rotor2);

               rotor1[0][i] = backthrough3;

               this.decode(backthrough3, rotor1);

          }




          return decode(backthrough3, rotor1);

     }




     public String encdecString(String message) {

          StringBuilder encoded = new StringBuilder("");

          char[] rotor = message.toCharArray();

Enigma Otomata Projesi ve Yazılım Gerçeklemesi
                                         ix
Eskişehir Osmangazi Üniversitesi




           for (int i = 0; i < rotor.length; i++) {

                 encoded.append(rotoredAndReflected(rotor[i]));

           }

           return encoded.toString();

     }

}

Enigma’nın GUI’deki Encode işlemini tamamlama şekli:

           if (Enigma.getText() != "") {

                 Enigma en = new Enigma();

                 EnigmaOut.setText(en.encdecString(Enigma.getText()));

                 str2 = Enigma.getText();

                 Enigma.setText("");

           }

Encode işlemlerinin tamamı “private void encodeActionPerformed(java.awt.event.ActionEvent evt)” Action’ının ürünüdür.

Decode işlemlerinin tamamı “private void decodeActionPerformed(java.awt.event.ActionEvent evt)” Action’ının ürünüdür.

Bütün decode işlemleri ise hafızadaki encode işlemi yapılmamış verinin saf olarak geriye döndürülmesi şeklinde yapılmıştır:

           if (RotOut.getText() != "") {

                 Rot.setText(str);

                 RotOut.setText("");

           }




           if (EnigmaOut.getText() != "") {

                 Enigma.setText(str2);

                 EnigmaOut.setText("");

           }




Enigma Otomata Projesi ve Yazılım Gerçeklemesi
                                                                                   x

Contenu connexe

En vedette

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellSaba Software
 

En vedette (20)

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 

Enigma otomataprojesiveyazilimgerceklemesi

  • 1. Eskişehir Osmangazi Üniversitesi Enigma Otomata Projesi ve Yazılım Gerçeklemesi Prepared for: Yrd.Doç.Dr.Ahmet Yazıcı Prepared by: Serkan Danışan, Mahmut Bulut, Tuğrul Boztepe May 28, 2012 Eskişehir Osmangazi Üniversitesi Bilgisayar Mühendisliği Bölümü
  • 2. Eskişehir Osmangazi Üniversitesi Proje İçeriği Enigma Önbilgisi i Enigmanın Tarihçesi, Kullanım Yerleri ve Bilgisayar Bilimine Etkisi i Mekanik Enigma Makinesinin Çalışma Prensibi i DFA Yapısına İndirgeme ii ROT-N şifrelemesinin ve Enigma Makinesinin indirgenmesi ii Kodlama Tipi ii Genel DFA ii Kodlar iii Proje Adı iii ROT-N Mantığının Kodlanması iii Enigma Mantığının Kodlanması vi Enigma Otomata Projesi ve Yazılım Gerçeklemesi i
  • 3. Eskişehir Osmangazi Üniversitesi Enigma Önbilgisi Enigmanın Tarihçesi, Kullanım Yerleri ve Bilgisayar Bilimine Etkisi  II. Dünya Savaşında Almanya tarafından gizli mesajların şifrelenmesi ve tekrar çözülmesi amacı ile kullanılan bir şifre makinesi olan ve Rotor makineleri sayesinde çalışan Elektro-Mekanik aygıttı.Bu makineyı ünlü bilim adamı Alan Turning keşfetmiştir.Enigma makinasının birçok türü vardı ve birçok ordu için 1920 li yıllardan başlayarak üretildi.Ancak en çok tarihte bahsedilen modeli Alman ordusunda kullanılan Wehrmacht Enigma modeliydi.Bu makina almanlar için yararlı gibi görünse de zamanla zararlı yönü ortaya çıktı. ll.Dünya savaşı ülkelerinden Polonya ve İngiltere tarafından mesajlar çözümlendi.Bu müttefik ülkelerin savaşı kazanmasında bu çözümlümenin oldukça büyük bir payı vardı.Enigmanın dünya bilimindeki diğer önemli rolü de şifre çözücü bu makinenin bilgisayar biliminin temelini atmış olmasıdır. Mekanik Enigma Makinesinin Çalışma Prensibi Enigma makinesinin işleyişi, düz yazı harflerini şifreli yazı harflerine çeviren 3 ROTORlu bir sistem üzerine kurulmuştur.Rotorlar diğer rotorlar ile kendi eksenleri etrafında dönerler, böylece yer değiştirme işlemini tamamlarlar. Makinenin klavyesinde bir harfe basıldığı zaman, önce ilk rotora gönderilir ve makinenin o andaki ayarına göre o harf değiştirilir(başka bir harf ile). Yeni harf, o andaki ayarına göre dönüştürülecek harf ile yer değiştireceği ikinci rotora geçer. Bu yeni harf üçüncü rotora dönüşerek geçecek, yine uygun olanla yer değiştirecektir. Sonra, bu yeni harf bir yansıtıcıdan yansıyacak ve 3 rotordan da ters sırayla geçecektir. Enigmayı zamanında bu kadar güçlü yapan rotorlarının kendi eksenleri etrafında dönmeleriydi. Düz metin harfi ilk rotordan geçtiğinde ilk rotor bir kere dönecekti. Diğer, ikinci rotor ilk rotor 26 kez(alman alfabesi için) dönene kadar sabit ve hareketsiz(fonksiyonsuz) kalacaktı. Sonra ikinci rotor harekete başlıyacaktı. İkinci rotor 26 kere döndüğünde(26×26 harf, ilk rotor 26 kez dönmüştü sonra ilk rotor ikinci 26′yı tamamladığında ikinci rotorda bir kez 26yı tamamlamış oldu ), üçüncü rotorda 1 yönde hareket edecekti. Döngü bütün mesajın uzunluğu kadar bunun gibi devam edecekti.Sonuç değiştirilen dönüşüm olarak karşımıza çıkacaktı. Diğer bir deyişle, bir “s” ilk bölümde “b” olarak kodlanabilir oluyor, ama mesajın ilerleyen bölümlerinde “m” olarak da karşımıza çıkabiliyordu. Rotorların dönmesi prensibi 26x26x26 = 17576 mümkün pozisyona izin veriyordu. Enigma Otomata Projesi ve Yazılım Gerçeklemesi i
  • 4. Eskişehir Osmangazi Üniversitesi DFA Yapısına İndirgeme ROT-N şifrelemesinin ve Enigma Makinesinin indirgenmesi Kodlama Tipi Programımız’da ise ROT13 şifreleme yöntemi(Sezar yöntemi) ve Wehrmacht Enigma’nın yazılım olarak modellenmiş şekli Java programlama dilinde kodlandı ve arayüz ile sunuldu. Genel DFA ROT13 sistemi ve enigma makinesinin DFA’i aşağıda gösterilmiştir. Harflere Ayrıştırma Rotor(Öteleme) Enigma Otomata Projesi ve Yazılım Gerçeklemesi ii
  • 5. Eskişehir Osmangazi Üniversitesi Enigma’nın çalışma sistemi kısaca şöyledir; Şifrelenecek kod başta starting state olarak alınır.Daha sonra alınan string harflerine ayrıştırılır.Ayrıştırılan harfler rötor sistemi ile alfabede diğer harflere atanır.Enigmanın içinde bu rötor sistemlerinden çokça vardır.Alınan stringin harfleri tüm bu rötor işlem- lerinden geçtikten sonra tekrar başka bir string(kodlanmış string) olarak alıcıya gönderilir. Kodlar Proje Adı Projemizin adını “trenigma” olarak belirledik. “Kodlar” başlığında belirtilen kodların tamamı bu projenin paketlerinin içinde halihazırda bulunmaktadır. ROT-N Mantığının Kodlanması Rot-N kodlaması(genellikle 13 harf öteleme kullanılır) enigma makinesinin temeli olup tarafımızca kodlaması şöyledir: Rotter.java kaynak dosyasında Rotter sınıfı constructor’ında argüman olarak öteleme sayısını alacak şekilde(ROT-N’deki N) yazımı: public class Rotter { public Rotter(String str) { s = str; } public String rotter(int rotadd) { StringBuilder strbld = new StringBuilder(""); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (c >= 'a' && c <= 'm') { c += rotadd; } else if (c >= 'n' && c <= 'z') { c -= rotadd; } else if (c >= 'A' && c <= 'M') { Enigma Otomata Projesi ve Yazılım Gerçeklemesi iii
  • 6. Eskişehir Osmangazi Üniversitesi c += rotadd; } else if (c >= 'A' && c <= 'Z') { c -= rotadd; } strbld.append(c); } return strbld.toString(); } public String getString(){ return this.s; } public void rotterlayered(int rotad, int layer) { do { rotter(rotad); layer--; } while (layer != 0); } private String s; } GUI’deki seçimi yaparak encode işlemini gerçekleştiren kod: if (Rot.getText() != "") { Rotter rot = new Rotter(Rot.getText()); if (jComboBox1.getSelectedIndex() == 0) { RotOut.setText(rot.rotter(1)); } else if (jComboBox1.getSelectedIndex() == 1) { RotOut.setText(rot.rotter(2)); Enigma Otomata Projesi ve Yazılım Gerçeklemesi iv
  • 7. Eskişehir Osmangazi Üniversitesi } else if (jComboBox1.getSelectedIndex() == 2) { RotOut.setText(rot.rotter(3)); } else if (jComboBox1.getSelectedIndex() == 3) { RotOut.setText(rot.rotter(4)); } else if (jComboBox1.getSelectedIndex() == 4) { RotOut.setText(rot.rotter(5)); } else if (jComboBox1.getSelectedIndex() == 5) { RotOut.setText(rot.rotter(6)); } else if (jComboBox1.getSelectedIndex() == 6) { RotOut.setText(rot.rotter(7)); } else if (jComboBox1.getSelectedIndex() == 7) { RotOut.setText(rot.rotter(8)); } else if (jComboBox1.getSelectedIndex() == 8) { RotOut.setText(rot.rotter(9)); } else if (jComboBox1.getSelectedIndex() == 9) { RotOut.setText(rot.rotter(10)); } else if (jComboBox1.getSelectedIndex() == 10) { RotOut.setText(rot.rotter(11)); } else if (jComboBox1.getSelectedIndex() == 11) { RotOut.setText(rot.rotter(12)); } else if (jComboBox1.getSelectedIndex() == 12) { RotOut.setText(rot.rotter(13)); } str = Rot.getText(); Rot.setText(""); } Enigma Otomata Projesi ve Yazılım Gerçeklemesi v
  • 8. Eskişehir Osmangazi Üniversitesi Enigma Mantığının Kodlanması Enigma Mantığı ise Enigma.java içerisindeki “Enigma” sınıfında eski 3 rotorlu mekanik makinedeki rotorların İngiliz alfabesindeki karşılığı baz alınarak, ayrıca “reflector” denen 3.rotoun şifrelemesini karşı tarafın çözmesini zorlaştımak için ROT-1 işlemi yaparak 1 kademe çözen 4. dişliyi de içinde bulundurmaktadır ve bu karşılıklar kodun içine gömülmüştür. Ayrıca kodumuz 6 rotorlu sistemi de içinde bulundurmakta ama kullanmamaktadır, kullanmak için yorum satırlarını kaldırıp 3’lü rotor atamalarını silmemiz ve birkaç küçük değişiklik 1 yapmamız yeterlidir: public class Enigma { /* public static final Rotor ROTOR_I = new Rotor(new char[]{'E', 'K', 'M', 'F', 'L', 'G', 'D', 'Q', 'V', 'Z', 'N', 'T', 'O', 'W', 'Y', 'H', 'X', 'U', 'S', 'P', 'A', 'I', 'B', 'R', 'C', 'J'}); public static final Rotor ROTOR_II = new Rotor(new char[]{'A', 'J', 'D', 'K', 'S', 'I', 'R', 'U', 'X', 'B', 'L', 'H', 'W', 'T', 'M', 'C', 'Q', 'G', 'Z', 'N', 'P', 'Y', 'F', 'V', 'O', 'E'}); public static final Rotor ROTOR_III = new Rotor(new char[]{'B', 'D', 'F', 'H', 'J', 'L', 'C', 'P', 'R', 'T', 'X', 'V', 'Z', 'N', 'Y', 'E', 'I', 'W', 'G', 'A', 'K', 'M', 'U', 'S', 'Q', 'O'}); public static final Rotor ROTOR_IV = new Rotor(new char[]{'E', 'S', 'O', 'V', 'P', 'Z', 'J', 'A', 'Y', 'Q', 'U', 'I', 'R', 'H', 'X', 'L', 'N', 'F', 'T', 'G', 'K', 'D', 'C', 'M', 'W', 'B'}); public static final Rotor ROTOR_V = new Rotor(new char[]{'V', 'Z', 'B', 'R', 'G', 'I', 'T', 'Y', 'U', 'P', 'S', 'D', 'N', 'H', 'L', 'X', 'A', 'W', 'M', 'J', 'Q', 'O', 'F', 'E', 'C', 'K'}); public static final Rotor ROTOR_VI = new Rotor(new char[]{'J', 'P', 'G', 'V', 'O', 'U', 'M', 'F', 'Y', 'Q', 'B', 'E', 'N', 'H', 'Z', 'R', 'D', 'K', 'A', 'S', 'X', 'L', 'I', 'C', 'T', 'W'}); public static final Rotor ROTOR_VII = new Rotor(new char[]{'N', 'Z', 'J', 'H', 'G', 'R', 'C', 'X', 'M', 'Y', 'S', 'W', 'B', 'O', 'U', 'F', 'A', 'I', 'V', 'L', 'P', 'E', 'K', 'Q', 'D', 'T'}); public static final Rotor ROTOR_VIII = new Rotor(new char[]{'F', 'K', 'Q', 'H', 'T', 'L', 'X', 'O', 'C', 'B', 'J', 'S', 'P', 'D', 'Z', 'R', 'A', 'M', 'E', 'W', 'N', 'I', 'U', 'Y', 'G', 'V'}); 1 Kodun logic yapısı değişmemekle birlikte encode() fonksiyonunun içine rotorlar eklenmeli ve rotorlar public olarak deklare edilmelidir. Enigma Otomata Projesi ve Yazılım Gerçeklemesi vi
  • 9. Eskişehir Osmangazi Üniversitesi public static final Rotor ROTOR_BETA = new Rotor(new char[]{'L', 'E', 'Y', 'J', 'V', 'C', 'N', 'I', 'X', 'W', 'P', 'B', 'Q', 'M', 'D', 'R', 'T', 'A', 'K', 'Z', 'G', 'F', 'U', 'H', 'O', 'S'}); public static final Rotor ROTOR_GAMMA = new Rotor(new char[]{'F', 'S', 'O', 'K', 'A', 'N', 'U', 'E', 'R', 'H', 'M', 'B', 'T', 'I', 'Y', 'C', 'W', 'L', 'Q', 'P', 'Z', 'X', 'V', 'G', 'J', 'D'});*/ // World War I: Enigma 1st encoding rotor scheme private char[][] rotor1 = {{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'}, {'G', 'T', 'U', 'B', 'Z', 'Y', 'V', 'J', 'L', 'K', 'S', 'A', 'W', 'X', 'H', 'C', 'D', 'E', 'M', 'N', 'O', 'P', 'Q', 'R', 'I', 'F'}}; // {G,T,U,B,Z,Y,V,J,L,K,S,A,W,X,H,C,D,E,M,N,O,P,Q,R,I,F} private char[][] rotor2 = {{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'}, {'L', 'C', 'D', 'G', 'Y', 'U', 'B', 'Z', 'S', 'V', 'J', 'E', 'M', 'A', 'W', 'X', 'H', 'N', 'O', 'P', 'Q', 'R', 'I', 'F', 'T', 'K'}}; // {L,C,D,G,Y,U,B,Z,S,V,J,E,M,A,W,X,H,N,O,P,Q,R,I,F,T,K} private char[][] rotor3 = {{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'}, {'S', 'V', 'J', 'E', 'M', 'W', 'X', 'L', 'N', 'A', 'B', 'H', 'C', 'O', 'P', 'Q', 'R', 'I', 'F', 'Y', 'D', 'G', 'T', 'U', 'Z', 'K'}}; // {S,V,J,E,M,W,X,L,N,A,B,H,C,O,P,Q,R,I,F,Y,D,G,T,U,Z,K} private char[][] reflector = {{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'}, {'Y', 'R', 'U', 'H', 'Q', 'S', 'L', 'D', 'P', 'X', 'N', 'G', 'O', 'K', 'M', 'I', 'E', 'B', 'F', 'Z', 'C', 'W', 'V', 'J', 'A', 'T'}}; // {Y,R,U,H,Q,S,L,D,P,X,N,G,O,K,M,I,E,B,F,Z,C,W,V,J,A,T} Enigma Otomata Projesi ve Yazılım Gerçeklemesi vii
  • 10. Eskişehir Osmangazi Üniversitesi public char encode(char uncodedLetter, char[][] getRotor) { for (int i = getRotor[0].length - 1; i >= 0; i--) { if (getRotor[0][i] == uncodedLetter) { System.out.println("getRotor[0][X] object adress " + getRotor.toString()); return getRotor[1][i]; } } return '~'; } public char decode(char codedLetter, char[][] getRotor) { for (int i = getRotor[1].length - 1; i >= 0; i--) { if (getRotor[1][i] == codedLetter) { System.out.println("getRotor[1][X] object adress " + getRotor.toString()); return getRotor[0][i]; } } return '~'; } public char rotoredAndReflected(char letter) { int i = 0; char result = encode(letter, rotor1); char result1 = encode(result, rotor2); Enigma Otomata Projesi ve Yazılım Gerçeklemesi viii
  • 11. Eskişehir Osmangazi Üniversitesi char result2 = encode(result1, rotor3); char backthrough1 = decode(result2, reflector); char backthrough2 = decode(backthrough1, rotor3); char backthrough3 = decode(backthrough2, rotor2); { this.encode(letter, rotor1); rotor2[0][i] = result; this.encode(result, rotor2); rotor3[0][i] = result1; this.encode(result1, rotor3); reflector[0][i] = result2; this.encode(result2, reflector); rotor3[0][i] = backthrough1; this.decode(backthrough1, rotor3); rotor2[0][i] = backthrough2; this.decode(backthrough2, rotor2); rotor1[0][i] = backthrough3; this.decode(backthrough3, rotor1); } return decode(backthrough3, rotor1); } public String encdecString(String message) { StringBuilder encoded = new StringBuilder(""); char[] rotor = message.toCharArray(); Enigma Otomata Projesi ve Yazılım Gerçeklemesi ix
  • 12. Eskişehir Osmangazi Üniversitesi for (int i = 0; i < rotor.length; i++) { encoded.append(rotoredAndReflected(rotor[i])); } return encoded.toString(); } } Enigma’nın GUI’deki Encode işlemini tamamlama şekli: if (Enigma.getText() != "") { Enigma en = new Enigma(); EnigmaOut.setText(en.encdecString(Enigma.getText())); str2 = Enigma.getText(); Enigma.setText(""); } Encode işlemlerinin tamamı “private void encodeActionPerformed(java.awt.event.ActionEvent evt)” Action’ının ürünüdür. Decode işlemlerinin tamamı “private void decodeActionPerformed(java.awt.event.ActionEvent evt)” Action’ının ürünüdür. Bütün decode işlemleri ise hafızadaki encode işlemi yapılmamış verinin saf olarak geriye döndürülmesi şeklinde yapılmıştır: if (RotOut.getText() != "") { Rot.setText(str); RotOut.setText(""); } if (EnigmaOut.getText() != "") { Enigma.setText(str2); EnigmaOut.setText(""); } Enigma Otomata Projesi ve Yazılım Gerçeklemesi x