Why shouldn't we create our own security schemes?

I see a lot of questions around here about custom crypto and custom security mechanisms, especially around password hashing.

With that in mind, I'm looking for a canonical answer, with the following properties:


Easy for a newbie to understand.
Clear and explicit in why rolling your own is a bad idea.
Provides strong examples.


Obligatory xkcd.

You can roll your own, but you probably will make a major security mistake if you are not an expert in security/cryptography or have had your scheme analyzed by multiple experts.  I'm more willing to bet on an open-source publicly known encryption scheme that's out there for all to see and analyze.  More eyes means more likely that the current version doesn't have major vulnerabilities, as opposed to something developed in-house by non-experts.

From Phil Zimmermann's (PGP creator) Introduction to Cryptography (Page 54):


  When I was in college in the early 70s, I devised what I believed was a brilliant
  encryption scheme. A simple pseudorandom number stream was added to the
  plaintext stream to create ciphertext. This would seemingly thwart any
  frequency analysis of the ciphertext, and would be uncrackable even to the
  most resourceful government intelligence agencies. I felt so smug about my
  achievement.
  
  Years later, I discovered this same scheme in several introductory
  cryptography texts and tutorial papers. How nice. Other cryptographers had
  thought of the same scheme. Unfortunately, the scheme was presented as a
  simple homework assignment on how to use elementary cryptanalytic
  techniques to trivially crack it. So much for my brilliant scheme.
  
  From this humbling experience I learned how easy it is to fall into a false sense
  of security when devising an encryption algorithm. Most people don’t realize
  how fiendishly difficult it is to devise an encryption algorithm that can
  withstand a prolonged and determined attack by a resourceful opponent.


(This question has more discussion of the above quote.)

If you are not convinced of "Don't Roll Your Own [Cryptography/Security]", then you probably are not an expert and there are many mistakes you likely will make.   

Is your application robust against:


Timing Attacks.  E.g., to the nanoseconds do completely-bad keys and partially-bad keys take the same amount of time in the aggregate to fail?  Otherwise, this timing information can be exploited to find the correct key/password.    
Trivial Brute Force Attacks; e.g., that can be done in within seconds to years (when you worry about it being broken within a few years).  Maybe your idea of security may be a 1 in a billion (1 000 000 000) chance of breaking in (what if someone with a bot net tries a few billion times?).  My idea is to aim for something like 1 in ~2128 ( 34 000 000 000 000 000 000 000 000 000 000 000), which is roughly ten million billion billion times more secure and completely outside the realm of guessing your way in.  
Attacks on user accounts in parallel; e.g., you may hash passwords with the same (or worse no) 'salt' on all password hashes in the database like what happened with the  leaked LinkedIn hashes.
Attack any specific account trivially simply.  Maybe there was a unique random salt with each simply hashed (e.g., MD5/SHA1/SHA2) password, but as you can try billions of possible passwords on any hash each second, so using common password lists, dictionary attacks, etc. it may only take an attacker seconds to crack most accounts. Use strong cryptographic hashes like bcrypt or PBKDF2 to avoid or key-strengthen regular hashes by a suitable factor (typically 10(3-8)).
Attacks on guessable/weak "random" numbers.  Maybe you use microtime/MT-rand or too little information to seed the pseudo-random number like Debian OpenSSL did a few years back.  
Attacks that bypass protections.  Maybe you did hashing/input validation client side in  web application and this was bypassed by the user altering the scripts.  Or you have local application that the client tries running in a virtual machine or disassembles to reverse engineer it/alter the memory/ or otherwise cheat somehow.
Other attacks, including (but not attempting to be a complete list) CSRF, XSS, SQL injection, network eavesdropping, replay attacks, Man in the Middle attacks, buffer overflows, etc.  Best protections very quickly summarized.  


CSRF: require randomly generated CSRF tokens on POST actions; XSS: always validate/escape untrusted user-input before inputting into the database and displaying to user/browser.
SQLi: always use bound parameters and limit how many results get returned.
Eavesdropping: encrypt sensitive network traffic.
Replay: put unique one-time nonces in each transaction.
MitM: Web of Trust/Same as site last visited/Certificate issued by trusted CA.
Buffer overflows: safe programming language/libraries/executable space protection/etc).



You are only as strong as your weakest exploitable link.  Also just because you aren't rolling your own scheme, doesn't mean your scheme will be secure,  it's quite likely that the person who created what you rolled out was not an expert, or created an otherwise weak scheme.
