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

Crypto-101 @hackerspace 26/07/2013

duongkai
July 26, 2013
94

Crypto-101 @hackerspace 26/07/2013

Bài trình bày tại hackerspace 26/07/2013

duongkai

July 26, 2013
Tweet

Transcript

  1. First terms + Message (plaintext) [m] + Ciphertext [c] +

    Encryption [E] + Decryption [D] + Key [k] 7/26/13 5
  2. Formula Encryption: c = E (m, k) Decryption: m =

    D (c, k) = D (E (m, k), k) 7/26/13 6
  3. Kerckhoffs’s Principle …” the security of a cryptosystem should depend

    solely on the secrecy of the key and the private randomizer”…[2] Auguste Kerckhoffs (1835 – 1903), La Cryptographie Militaire 7/26/13 8
  4. Is it md5 hash? >>> a = '317a513579704578526533366754566b’ >>> a.decode

    ('hex') '1zQ5ypExRe36gTVk’ >>> b = '900150983cd24fb0d6963f7d28e17f72’ >>> b.decode ('hex') '\x90\x01P\x98<\xd2O\xb0\xd6\x96?}(\xe1\x7fr’ >>> md5 ('abc').hexdigest() '900150983cd24fb0d6963f7d28e17f72' 7/26/13 14
  5. So, You work on bytes or string. You display in

    base64 or hexadecimal 7/26/13 15
  6. Base64 >>> from base64 import b64decode, b64encode >>> b64encode ('hello

    world') 'aGVsbG8gd29ybGQ=' >>> b64decode ('aGVsbG8gd29ybGQ=') 'hello world' 7/26/13 17
  7. But, random is a problem. >>> randint (10, 1000) 59

    >>> from Crypto.Random.random import StrongRandom >>> a = StrongRandom() >>> ''.join (a.sample (list ('abcdef'), 3)) 'cad' >>> a.randint (10, 10000) 3978L 7/26/13 20