Challenge 50 goes by the wayside.

The opposite of the last challenge, this time prepending (forged javascript) with the aim to make the same cbc mac.

As for the last challenge xor'ing the mac of the first part (our forged javascript) with the first block of the 2nd part (the javascript we wish to 'replace') results in the same cbc mac for the whole javascript snippet, which still runs in a browser.

There are probably other ways but this was easy to implement.

#rust #cryptopalsChallenge #cryptography #alwaysLearning

Challenge 42, Bleichenbacher's e=3 RSA Attack, is done. Padding is important in cryptography.

Wasn't sure if they wanted md5, sha1 or sha256. Did them all.

Rust match arms are so neat and concise at this.

Before: ugly, if else if else .. else

enum Hash { Md5, Sha1, Sha256 }

let hash: Vec<u8>;
if self.hashfn == Hash::Md5 {
hash = openssl....;
} else if self.hashfn == Hash::Sha1 {
hash = sha1(...);
} else {
hash = sha256(...);
}

After: match

//same enum definition
let hash = match self.hashfn {
Hash::Md5 => openssl... ,
Hash::Sha1 => sha1(...),
Hash::Sha256 => sha256(....)
};

Clean.

#rust #cryptopalsChallenge #learning #neverTooOldToLearn