Sign then Encrypt

Just as a heads up this is wacky as shit because of some weird merging and rebasing…I'm still looking at it but if you see anything odd please let me know.
I think it should be the other way round: first encrypt, then authenticate (sign). Have a look [here](http://crypto.stackexchange.com/questions/202/should-we-mac-then-encrypt-or-encrypt-then-mac).