හරි. ඔයලා Advance Cryptography article series එකේ කලින් articles ටික read කරලා තියෙනවා නම්, මේ වෙදිදී ඔයාට substitution cipher, Affine cipher, Hill cipher, One time pad ගැන හොද idea එකක් තියෙනවා ඇති.
එතකොට මොකක්ද Practical cipher එකක් කියන්නේ? අපි කතා කරපු substitution cipher, Affine cipher, Hill cipher, One time pad සේරම Practical ciphers ද? හරි Practical cipher එකක් කියන්නේ hacker කෙනෙක්ට ලේසියෙන් brake කරන්න බැරි cipher එකක්. Example එකක් විදීයට ගත්තොත් substitution cipher වලදී hacker කෙනෙක්ට keys 26 ක් try කරලා අදාල key එක මොකක්ද කියලා detect කර ගන්න පුලුවන් වෙනවා. මේ වගේම Affine cipher, Hill cipher වගේ ඒවා hack කරන එක hacker කෙනෙක්ට ලොකු වැඩක් නෙවෙයි.
One time pad එක ගැන බැලිවොත් ඒක නම් Practical cipher එකක් කියන්න පුලුවන්. ඒත් මේක practically use කරන්න බැරි problem එකක් තියෙනවා. මොකද මේක හැම අලුත් message එකකටම එකේ length එකට සමාන random key එකක් generate වෙනවා. ඒක practically කරන්න අමාරු වැඩක් මොකද Message එකේ length එක වැඩි උනොත් දිග key එකක් generate කරන්න වෙනවානේ.
ඊලග අව්ල තමයි ඔයාලා දන්නවනේ symmetric key encryption වලදී sender and receiver දෙන්නම use කරන්නේ same key එක කියලා. එතකොට Key distribution වල වගේම protection වලදී One time pad වල ගටලු ඇති වෙනවා. ඉතිං මේකට solution එකක් විදියට One time pad එක තව develop කරලා stream cipher විදියට ලෝකෙට ආවා. දැන් අපි බලමු stream cipher කියන්නේ මොනවද කියලා.
Stream cipher
Stream cipher ගැන කතා කරන්න කලින් ඔයාලට XOR gate එක ගැන idea එකක් තියෙන්න ඕනි. One time pad එකේ වගේම Stream cipher එකෙත් XOR gate එක මත තමයි develop වෙලා තියෙන්නේ. XOR gate එකේදී වෙන්නේ මෙන්න මේ වගේ දෙයක්.
A | B | A XOR B |
1 | 1 | 0 |
1 | 0 | 1 |
0 | 1 | 1 |
0 | 0 | 0 |
ඔයාලට පේනවනේ A,B output අනුව A XOR B result එක ආපු විදිය. මෙන්න මේ විදියට තමයි One time pad එක සහ Stream cipher එක develop වෙලා තියෙන්නේ. Stream cipher එකේදී Chipertext and plaintext design වෙන්නේ මේ විදියට.
Ci = Pi XOR Ki
Pi = Pi XOR Ki
හරි අපි example එකක් විදියට MOON කියන word එක Stream cipher වලින් encrypt කරලා බලමු.
Plaintext – MOON (Plaintext එක binary විදියට convert කරන්න ඕනි)
Key – IL27 (Key එක binary විදියට convert කරන්න ඕනි)
Plaintext in Binary | 0 | 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 1 | 1 | 1 | 0 | 1 | 0 | 0 | 1 | 1 | 1 | 1 | 0 | 1 | 0 | 0 | 1 | 1 | 1 | 0 |
Key in Binary | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 1 | 1 | 1 |
XOR | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 0 | 1 | 1 | 1 | 1 | 0 | 0 | 1 |
දැන් ඔයාලට තියෙන්නේ binary එක text එකකට convert කරන්න.
Cipher text – $c}y
මේ විදියට Cipher text generate වෙන නිසා one time pad එක pseudo random number generation එකක් කියලා හදුන්වනවා.
Pseudo random number generation වෙන විධි mainly parts 3 ක් තියෙනවා.
- Linear Congruential (Operation)
- Linear Shift Feedback (Operation)
- Shrinking Generator (Operation)
මේ methods වලින් Linear Congruential & Linear Shift Feedback වල security එක තරමක් දුරට අඩුයි. ඒ කියන්නේ hacker කෙනෙක්ට try කරොත් මේ ciphers brake කරන්න බැරි වෙන්නේ නෑ. ඒ නිසා ගොඩක් වෙලාවට pseudo random number generation විදියට Shrinking Generator තමයි use වෙන්නේ.
හරි එතකොට Stream cipher අපි use කරන්නේ මොන වගේ වෙලාවල් වලටද? ගොඩක් වෙලාවට low memory recourse තියෙනකොට, GMS වලදී, SSL & TSL වල fast encryption & decryption කරන්න වගේ Stream cipher use කරනවා. හැබයි Stream cipher වල practical usage එකේදී confidentiality and integrity related questions එනවා. ඒ නිසා Block cipher ගැන මිනුස්සු අවදානය දුන්නා. ඊලගට අපි Block cipher ගැන බලමු.
Block cipher
Fixed length group එකක data encrypt කරන්න use කරන method එකක් තමයි block cipher කියලා කියන්නේ. මේකෙදී ගොඩක් වෙලාවට 64bits or 128bits තමයි use කරන්නේ. Block cipher වලදී encrypt කරන එක character එකක් character දෙකක් මත depend වෙනවා. ඒ නිසා මේක brake කරන්න නම් key elements ගොඩක් දැන ගන්න ඕනි.

Block cipher වල mainly modes 5 ක් තියෙනවා.
- Electronic code block (ECB) mode encryption

- Cipher block chaining ( CBC ) mode encryption

- Cipher feedback mode (CFB) mode encryption

- Output feedback (OFB) mode encryption

- Counter (CTR) mode encryption

Block cipher වලදී multiple encryptions වලට same key use කරන්න ඕනි. ඒක නිසා මේකේ security එක වැඩි වෙනවා. මොකද බැරි වෙලාවත් hacker කෙනෙක් මේක brake කරන්න try කරොත් එයාට අනිවාර්යෙන්ම plaintext and ciphertext pairs සේරම වෙන වෙනම try කරලා බලන්න වෙනවා. ඒක ටිකක් අමාරු වැඩක්.
හරි දැන් එහෙනම් ඔයාලට Stream cipher &Block cipher ගැන හොද idea එකක් එන්න ඇති. ඊලග article එකෙන් අපි DES / 2DES / 3DES / AES ගැන කතා කරමු.