bitpay/copay — pull request #224 by matiu (2014-04-30 00:00:42+00:00)
Title: Feature/authenticated encryption using aes/ccm mode

This implements CCM/AES mode for authenticated encryption.

SJSC support two modes CCM and OBC. OBC is faster, but have some
patents restrictions in certain countries, so I choose CCM. Default mode
can be changed in `config.js`.

CCM will encrypt and mac each package using the RECIPIENT sha256 of copayerID as a seed
for a Password-Based Key-Derivation Function (PBKDF2-HMAC-SHA256). This is the method specified by RSA's PKCS #5 standard. Iterations number is configurable in `config.js`, defaults to `1000`. This should
ensure a good key even if there is any uneven distribution of ECDSA pubkeys in the 33 bytes space.
`salt` for PBKDF can be configured on `config.js`. Alternatively we could send a true random number for that key.

Since all peers know each other peer's pubkeys ONCE the wallet is complete, there is no need to keep
encrypting differently each message for each peer, that could be enhanced on the future.

More info on CCM/AES:
http://spark-university.s3.amazonaws.com/stanford-crypto/slides/07.4-authenc-annotated.pdf

On PBKDF2:
http://en.wikipedia.org/wiki/PBKDF2ll