Us “do it all yourself” developers tend to look at cryptography as yet another opportunity to just be clever and be done with it. At least, that’s how I felt a few years ago. Tony Arcieri wrote a pretty solid rant about why we should keep our hands out of the Pandora’s box that is cryptography if we don’t know enough:
The most important question is: are you using an authenticated encryption mode? If you don’t know what authenticated encryption is, then you’ve probably already made a mistake. Here’s a hint: authenticated encryption has nothing to do with authenticating users into a webapp. It has everything to do with ensuring the integrity of your data hasn’t been compromised, i.e. no one has tampered with the message.
If you’ve actually read the OAuth 1.0 specification, you should have stumbled on the concept. Like me, you may not have given too much thought to why HMAC signing was chosen though, which only serves to prove Tony’s point:
tl;dr: use authenticated encryption. use authenticated encryption. use authenticated encryption. use authenticated encryption. use authenticated encryption. use authenticated encryption. use authenticated encryption. use authenticated encryption. use authenticated encryption. use authenticated encryption.