Skip to content

dbalan/cryptopals

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cryptopals solutions

builds.sr.ht status

Solutions to cryptopals challenges in Go.

Running

Solutions are implemented as a testcases.

cd cryptopals
go test -v ./...

Solutions

Set 1

  1. Convert hex to base64: https://github.com/dbalan/cryptopals/blob/master/set1/ch1_test.go#L16
  2. Fixed XOR: https://github.com/dbalan/cryptopals/blob/master/set1/ch2.go
  3. Single-byte XOR cipher: https://github.com/dbalan/cryptopals/blob/master/set1/ch3.go#L62
  4. Detect single-character XOR: https://github.com/dbalan/cryptopals/blob/master/set1/ch4_test.go#L9
  5. Implement repeating-key XOR: https://github.com/dbalan/cryptopals/blob/master/set1/ch5_test.go#L19
  6. Break repeating-key XOR: https://github.com/dbalan/cryptopals/blob/master/set1/ch6_test.go#L41
  7. AES in ECB mode: https://github.com/dbalan/cryptopals/blob/master/set1/ch7_test.go#L11
  8. Detect AES in ECB mode: https://github.com/dbalan/cryptopals/blob/master/set1/ch8_test.go#L11

Set 2

  1. Implement PKCS#7 padding: https://github.com/dbalan/cryptopals/blob/master/set2/pkcs.go
  2. Implement CBC mode: https://github.com/dbalan/cryptopals/blob/master/set2/aescbc.go
  3. An ECB/CBC detection oracle: https://github.com/dbalan/cryptopals/blob/master/set2/aes_detect_mode.go#L7
  4. Byte-at-a-time ECB decryption (Simple): https://github.com/dbalan/cryptopals/blob/master/set2/aes_ecb_attack1.go
  5. ECB cut-and-paste: https://github.com/dbalan/cryptopals/blob/master/set2/ecbcutpaste_test.go
  6. Byte-at-a-time ECB decryption (Harder): https://github.com/dbalan/cryptopals/blob/master/set2/aes_ecb_attack2.go
  7. PKCS#7 padding validation: https://github.com/dbalan/cryptopals/blob/master/set2/pkcs.go
  8. CBC bitflipping attacks: https://github.com/dbalan/cryptopals/blob/master/set2/cbc_bitflipping_test.go

Set 3

  1. The CBC padding oracle: https://github.com/dbalan/cryptopals/blob/master/set3/padding_oracle.go
  2. Implement CTR, the stream cipher mode: https://github.com/dbalan/cryptopals/blob/master/set3/aesctr.go
  3. Break fixed-nonce CTR mode using substitutions: TODO
  4. Break fixed-nonce CTR statistically: https://github.com/dbalan/cryptopals/blob/master/set3/aesctr_stat.go
  5. Implement the MT19937 Mersenne Twister RNG: https://github.com/dbalan/cryptopals/blob/master/set3/mt19937.go
  6. Crack an MT19937 seed: https://github.com/dbalan/cryptopals/blob/master/set3/mt_stream_cipher.go
  7. Clone an MT19937 RNG from its output: https://github.com/dbalan/cryptopals/blob/master/set3/mt_clone.go
  8. Create the MT19937 stream cipher and break it: https://github.com/dbalan/cryptopals/blob/master/set3/mt_stream_cipher_test.go

Set 4

  1. Break "random access read/write" AES CTR: https://github.com/dbalan/cryptopals/blob/master/set4/aesctr_attack.go
  2. CTR bitflipping: https://github.com/dbalan/cryptopals/blob/master/set4/ctrbitflipping.go
  3. Recover the key from CBC with IV=Key: https://github.com/dbalan/cryptopals/blob/master/set4/ivattack.go
  4. Implement a SHA-1 keyed MAC: https://github.com/dbalan/cryptopals/blob/master/sha/sha.go
  5. Break a SHA-1 keyed MAC using length extension: https://github.com/dbalan/cryptopals/blob/master/set4/sha_len_ext.go
  6. Break an MD4 keyed MAC using length extension: TODO (MD construction similar to sha1)
  7. Implement and break HMAC-SHA1 with an artificial timing leak: TODO
  8. Break HMAC-SHA1 with a slightly less artificial timing leak: TODO

Set 5

  1. Implement Diffie-Hellman: https://github.com/dbalan/cryptopals/blob/master/set5/dh.go
  2. Implement a MITM key-fixing attack on Diffie-Hellman with parameter injection: https://github.com/dbalan/cryptopals/blob/master/set5/dh_mitm_test.go
  3. Implement DH with negotiated groups, and break with malicious "g" parameters: https://github.com/dbalan/cryptopals/blob/master/set5/dh_mitm_primes.go
  4. Implement Secure Remote Password (SRP) : https://github.com/dbalan/cryptopals/blob/master/set5/simple_srp.go
  5. Break SRP with a zero key: https://github.com/dbalan/cryptopals/blob/master/set5/srp_test.go
  6. Offline dictionary attack on simplified SRP: https://github.com/dbalan/cryptopals/blob/master/set5/evil_ssrp.go
  7. Implement RSA: https://github.com/dbalan/cryptopals/blob/master/rsa/rsa.go
  8. Implement an E=3 RSA Broadcast attack: https://github.com/dbalan/cryptopals/blob/master/set5/broadcast_rsa_attack_test.go

Set 6

  1. Implement unpadded message recovery oracle: https://github.com/dbalan/cryptopals/blob/master/set6/rsa_recovery_test.go
  2. Bleichenbacher's e=3 RSA Attack : https://github.com/dbalan/cryptopals/blob/master/set6/rsa_sign_test.go
  3. DSA key recovery from nonce: https://github.com/dbalan/cryptopals/blob/master/set6/dsa_key_recovery.go
  4. DSA nonce recovery from repeated nonce: https://github.com/dbalan/cryptopals/blob/master/set6/dsa_repeated_nonce.go
  5. DSA parameter tampering: https://github.com/dbalan/cryptopals/blob/master/set6/dsa_parameter_tampering.go
  6. RSA parity oracle: https://github.com/dbalan/cryptopals/blob/master/set6/rsa_parity_oracle.go
  7. Bleichenbacher's PKCS 1.5 Padding Oracle (Simple Case): https://github.com/dbalan/cryptopals/blob/master/set6/pkcs_padding_oracle.go
  8. Bleichenbacher's PKCS 1.5 Padding Oracle (Complete Case: https://github.com/dbalan/cryptopals/blob/master/set6/pkcs_padding_oracle.go

Releases

No releases published

Packages

No packages published

Languages