Upgrade to Pro — share decks privately, control downloads, hide ads and more …

20190223 密碼學基礎 Cryptography

RUI030
February 23, 2019

20190223 密碼學基礎 Cryptography

CC-BY-NC-ND

高雄市立高雄女子高級中學電腦資訊與網路科技研究社24th 專題組上課用簡報

RUI030

February 23, 2019
Tweet

More Decks by RUI030

Other Decks in Programming

Transcript

  1. MOD

  2. MOD 寫法  a mod n  a % n

     a = k (mod n) 範例  10 mod 3  30 % 20  26 = 5 (mod 7)
  3. > _ E𝐾 𝑀𝑖 = 𝑀𝑖 + 𝐾𝑖 𝑚𝑜𝑑 26

    > STEP1 _ > STEP2 K K _ 明文 M = 𝑀1 … 𝑀𝑛 密文 𝐶 = 𝐶1 … C𝑛 金鑰 K = K1 … K𝑛
  4. > _ D𝐾 C𝑖 = C𝑖 − 𝐾𝑖 𝑚𝑜𝑑 26

    > STEP1 K K _ 明文 M = 𝑀1 … 𝑀𝑛 密文 𝐶 = 𝐶1 … C𝑛 金鑰 K = K1 … K𝑛
  5. OuO 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 A 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 B 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 A C C D E F G H I J K L M N O P Q R S T U V W X Y Z A B D D E F G H I J K L M N O P Q R S T U V W X Y Z A B C E E F G H I J K L M N O P Q R S T U V W X Y Z A B C D F F G H I J K L M N O P Q R S T U V W X Y Z A B C D E G G H I J K L M N O P Q R S T U V W X Y Z A B C D E F H H I J K L M N O P Q R S T U V W X Y Z A B C D E F G I I J K L M N O P Q R S T U V W X Y Z A B C D E F G H J J K L M N O P Q R S T U V W X Y Z A B C D E F G H I K K L M N O P Q R S T U V W X Y Z A B C D E F G H I J L L M N O P Q R S T U V W X Y Z A B C D E F G H I J K M M N O P Q R S T U V W X Y Z A B C D E F G H I J K L N N O P Q R S T U V W X Y Z A B C D E F G H I J K L M O O P Q R S T U V W X Y Z A B C D E F G H I J K L M N P P Q R S T U V W X Y Z A B C D E F G H I J K L M N O Q Q R S T U V W X Y Z A B C D E F G H I J K L M N O P R R S T U V W X Y Z A B C D E F G H I J K L M N O P Q S S T U V W X Y Z A B C D E F G H I J K L M N O P Q R T T U V W X Y Z A B C D E F G H I J K L M N O P Q R S U U V W X Y Z A B C D E F G H I J K L M N O P Q R S T V V W X Y Z A B C D E F G H I J K L M N O P Q R S T U W W X Y Z A B C D E F G H I J K L M N O P Q R S T U V X X Y Z A B C D E F G H I J K L M N O P Q R S T U V W Y Y Z A B C D E F G H I J K L M N O P Q R S T U V W X Z Z 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
  6. 𝒇 𝒙 = 𝒚 𝑔 𝑓 𝑥 = 𝑥 𝑔

    𝑦 = 𝑥 𝑔 𝒇 𝒇−𝟏 Example   𝑓 𝑥 = 2𝑥 𝑓(𝑥)−1 = 1 2 𝑥  sin(30 ) = 1 2 sin−1 1 2 = 30
  7. ASCII(0~63) Dec Hex Binary Char Description Dec Hex Binary Char

    Description Dec Hex Binary Char Description Dec Hex Binary Char Description 000 00 00000000 NUL null 016 10 00010000 DLE data link escape 032 20 00100000 Space space 048 30 00110000 0 zero 001 01 00000001 SOH start of header 017 11 00010001 DC1 device control 1 033 21 00100001 ! exclamation mark 049 31 00110001 1 one 002 02 00000010 STX start of text 018 12 00010010 DC2 device control 2 034 22 00100010 " double quote 050 32 00110010 2 two 003 03 00000011 ETX end of text 019 13 00010011 DC3 device control 3 035 23 00100011 # number 051 33 00110011 3 three 004 04 00000100 EOT end of transmission 020 14 00010100 DC4 device control 4 036 24 00100100 $ dollar 052 34 00110100 4 four 005 05 00000101 ENQ enquiry 021 15 00010101 NAK negative acknowledge 037 25 00100101 % percent 053 35 00110101 5 five 006 06 00000110 ACK acknowledge 022 16 00010110 SYN synchronize 038 26 00100110 & ampersand 054 36 00110110 6 six 007 07 00000111 BEL bell 023 17 00010111 ETB end of trans. block 039 27 00100111 ' single quote 055 37 00110111 7 seven 008 08 00001000 BS backspace 024 18 00011000 CAN cancel 040 28 00101000 ( left parenthesis 056 38 00111000 8 eight 009 09 00001001 HT horizontal tab 025 19 00011001 EM end of medium 041 29 00101001 ) right parenthesis 057 39 00111001 9 nine 010 0A 00001010 LF line feed 026 1A 00011010 SUB substitute 042 2A 00101010 * asterisk 058 3A 00111010 : colon 011 0B 00001011 VT vertical tab 027 1B 00011011 ESC escape 043 2B 00101011 + plus 059 3B 00111011 ; semicolon 012 0C 00001100 FF form feed 028 1C 00011100 FS file separator 044 2C 00101100 , comma 060 3C 00111100 < less than 013 0D 00001101 CR enter 029 1D 00011101 GS group separator 045 2D 00101101 - minus 061 3D 00111101 = equality sign 014 0E 00001110 SO shift out 030 1E 00011110 RS record separator 046 2E 00101110 . period 062 3E 00111110 > greater than 015 0F 00001111 SI shift in 031 1F 00011111 US unit separator 047 2F 00101111 / slash 063 3F 00111111 ? question mark
  8. ASCII(64~127) Dec Hex Binary Char Description Dec Hex Binary Char

    Description Dec Hex Binary Char Description Dec Hex Binary Char Description 064 40 01000000 @ at sign 080 50 01010000 P 096 60 01100000 ` grave / accent 112 70 01110000 p 065 41 01000001 A 081 51 01010001 Q 097 61 01100001 a 113 71 01110001 q 066 42 01000010 B 082 52 01010010 R 098 62 01100010 b 114 72 01110010 r 067 43 01000011 C 083 53 01010011 S 099 63 01100011 c 115 73 01110011 s 068 44 01000100 D 084 54 01010100 T 100 64 01100100 d 116 74 01110100 t 069 45 01000101 E 085 55 01010101 U 101 65 01100101 e 117 75 01110101 u 070 46 01000110 F 086 56 01010110 V 102 66 01100110 f 118 76 01110110 v 071 47 01000111 G 087 57 01010111 W 103 67 01100111 g 119 77 01110111 w 072 48 01001000 H 088 58 01011000 X 104 68 01101000 h 120 78 01111000 x 073 49 01001001 I 089 59 01011001 Y 105 69 01101001 i 121 79 01111001 y 074 4A 01001010 J 090 5A 01011010 Z 106 6A 01101010 j 122 7A 01111010 z 075 4B 01001011 K 091 5B 01011011 [ left square bracket 107 6B 01101011 k 123 7B 01111011 { left curly bracket 076 4C 01001100 L 092 5C 01011100 \ backslash 108 6C 01101100 l 124 7C 01111100 | vertical bar 077 4D 01001101 M 093 5D 01011101 ] right square bracket 109 6D 01101101 m 125 7D 01111101 } right curly bracket 078 4E 01001110 N 094 5E 01011110 ^ caret / circumflex 110 6E 01101110 n 126 7E 01111110 ~ tilde 079 4F 01001111 O 095 5F 01011111 _ underscore 111 6F 01101111 o 127 7F 01111111 DEL delete
  9. > _ H E L L O W O R

    L D HELLOWORLD ↓ HWEOLRLLOD 明文 密 文
  10. > _ EBIITLOIA E F G H I J K

    L M N O P Q R S T U V W X Y Z A B C D 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 A I J K L M N O P Q R S T U V W X Y Z 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 A B C D E F G H L M N O P Q R S T U V W X Y Z A B C D E F G H I J K T U V W X Y Z A B C D E F G H I J K L M N O P Q R S L M N O P Q R S T U V W X Y Z A B C D E F G H I J K O P Q R S T U V W X Y Z A B C D E F G H I J K L M N I J K L M N O P Q R S T U V W X Y Z A B C D E F G H 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
  11. > _ Orggov Ivw Irwrmt Sllw orevw rm z dllw

    drgs svi nlgsvi. Lmv wzb Orggov Ivw Irwrmt Sllw dvmg gl erhrg svi tizmmb. Hsv szw z mrxv xzpv rm svi yzhpvg. Lm svi dzb Orggov Ivw Irwrmt Sllw nvg z dlou. ‘Svool!’ hzrw gsv dlou. ‘Dsviv ziv blf tlrmt?’ ‘R’n tlrmt gl hvv nb tizmwnlgsvi. Hsv orevh rm z slfhv yvsrmw gslhv givvh.’ Gsv dlou izm gl Tizmmb’h slfhv zmw zgv Tizmmb fk. Sv tlg rmgl Tizmmb’h yvw. Z orggov ozgvi, Orggov Ivw Irwrmt Sllw ivzxsvw gsv slfhv. Hsv ollpvw zg gsv dlou. ‘Tizmmb, dszg yrt vbvh blf szev!’ ‘Zoo gsv yvggvi gl hvv blf drgs!’ hzrw gsv dlou. ‘Tizmmb, dszg yrt vzih blf szev!’ ‘Zoo gsv yvggvi gl svzi blf drgs!’ hzrw gsv dlou. ‘Tizmmb, dszg z yrt mlhv blf szev!’ ‘Zoo gsv yvggvi gl hnvoo blf drgs!’ hzrw gsv dlou. ‘Tizmmb, dszg yrt gvvgs blf szev!’ ‘Zoo gsv yvggvi gl vzg blf drgs!’ hslfgvw gsv dlou. Z dllwxfggvi dzh rm gsv dllw. Sv svziw z olfw hxivzn zmw izm gl gsv slfhv. Gsv dllwxfggvi srg gsv dlou levi gsv svzw. Gsv dlou lkvmvw srh nlfgs drwv zmw hslfgvw zmw Tizmmb qfnkvw lfg. Gsv dlou izm zdzb zmw Orggov Ivw Irwrmt Sllw mvevi hzd gsv dlou ztzrm.
  12. > _ Little Red Riding Hood lived in a wood

    with her mother. One day Little Red Riding Hood went to visit her granny. She had a nice cake in her basket. On her way Little Red Riding Hood met a wolf. ‘Hello!’ said the wolf. ‘Where are you going?’ ‘I’m going to see my grandmother. She lives in a house behind those trees.’ The wolf ran to Granny’s house and ate Granny up. He got into Granny’s bed. A little later, Little Red Riding Hood reached the house. She looked at the wolf. ‘Granny, what big eyes you have!’ ‘All the better to see you with!’ said the wolf. ‘Granny, what big ears you have!’ ‘All the better to hear you with!’ said the wolf. ‘Granny, what a big nose you have!’ ‘All the better to smell you with!’ said the wolf. ‘Granny, what big teeth you have!’ ‘All the better to eat you with!’ shouted the wolf. A woodcutter was in the wood. He heard a loud scream and ran to the house. The woodcutter hit the wolf over the head. The wolf opened his mouth wide and shouted and Granny jumped out. The wolf ran away and Little Red Riding Hood never saw the wolf again.
  13. > _ A B C D E F G H

    I J K L M Z Y X W V U T S R Q P O N N O P Q R S T U V W X Y Z M L K J I H G F E D C B A
  14. RSA

  15. >RSA_ > STEP1 𝑝 , 𝑞 (𝑝 ≠ 𝑞) _

    > STEP2 N = 𝑝 × 𝑞_ > STEP3 𝑟 = (𝑝 − 1) × (𝑞 − 1)_ →𝜑(𝑁) = 𝜑(𝑝) × 𝜑(𝑞)_ (歐拉函數) > STEP4 𝑟 𝑒 , 𝑒 𝑟 _ > STEP5 𝑑 , 𝑒𝑑 ≡ 1 (𝑚𝑜𝑑 𝑟)_(d為e關於r的模反元素) > STEP6 𝑝, 𝑞 _ 公鑰 ( 𝑁 , 𝑒 ) 私鑰 ( 𝑁 , 𝑑 )
  16. >Base64_ 1 Dec Bin Char 0 000000 A 1 000001

    B 2 000010 C 3 000011 D 4 000100 E 5 000101 F 6 000110 G 7 000111 H Dec Bin Char 8 001000 I 9 001001 J 10 001010 K 11 001011 L 12 001100 M 13 001101 N 14 001110 O 15 001111 P Dec Bin Char 16 010000 Q 17 010001 R 18 010010 S 19 010011 T 20 010100 U 21 010101 V 22 010110 W 23 010111 X Dec Bin Char 24 011000 Y 25 011001 Z 26 011010 a 27 011011 b 28 011100 c 29 011101 d 30 011110 e 31 011111 f
  17. >Base64_ 2 Dec Bin Char 32 100000 g 33 100001

    h 34 100010 i 35 100011 j 36 100100 k 37 100101 l 38 100110 m 39 100111 n Dec Bin Char 40 101000 o 41 101001 p 42 101010 q 43 101011 r 44 101100 s 45 101101 t 46 101110 u 47 101111 v Dec Bin Char 48 110000 w 49 110001 x 50 110010 y 51 110011 z 52 110100 0 53 110101 1 54 110110 2 55 110111 3 Dec Bin Char 56 111000 4 57 111001 5 58 111010 6 59 111011 7 60 111100 8 61 111101 9 62 111110 + 63 111111 /
  18. >Base64_ O X 0 1 0 0 1 1 1

    1 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 T 1 g = OX → T1g=