ZeroK-RTS/Zero-K-Infrastructure — pull request #29 by xponen (2014-07-17 16:24:48+00:00)
Title: Implemented Optional Encrypted PM

-=Documentation=-
AES: for encrypting text.
*128-bit
*using CBC cipher-mode for each String
*IV reset to original for each new line, but XOR-ed to a counter (increment by 1, for each player).
*using ISO10126 padding to randomize empty ending

RSA: for encrypting AES key (did not encrypt IV)
*1024-bit
*using OAEP padding

Key Exchange:
All is send in plaintext.
A:"Encryption:RequestKeyExchange<(extra special request)>"
B:"Encryption:Parameter:<(extra special request)>"
A:"Encryption:PublicKey:"
B:"Encryption:SymKey:" " SymIV:" ,
A:"Encryption:Active"

If A sent "RequestKeyExchange" then don't respond to similar message from B (and vice-versa) to avoid collision.
Don't respond to skipped sequence and automatically timeout in 10-second if no respond, and say "Encryption:End".

A&B can say "Encryption:End" to terminate encryption session at any time. This will reset any encryption's internal state.
A&B can say "Encryption:RequestKeyExchange" at any time too, this can re-exchange new key.
Adding "(no history)" to <(extra special request)> should skip saving chat history to local disk.

Text Encryption:
Text-about-to-send is encrypted and appended with "\x2D0" or U+2D0 (triangle semicolon) to the beginning of encrypted string (for ZKL formatting) and is sent.