summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md231
1 files changed, 231 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..622264a
--- /dev/null
+++ b/README.md
@@ -0,0 +1,231 @@
1Implemented features and fixes not present in the official Sylpheed release
2===========================================================================
3
4- (fix)
5 PGP signature not verified properly when the message has no newline
6 at the end. https://sylpheed.sraoss.jp/redmine/issues/288
7
8- (feature)
9 Make it possible to select "Show signature check result in a popup window"
10 only for bad signatures.
11
12- (feature)
13 Support for encrypting and storing encrypted passwords using a master password.
14 See README for more details.
15
16
17Master password
18===============
19
20The master password feature is developed by Simeon Simeonov (sgs)
21and is currently in an experimental state.
22
23
24Motivation
25----------
26
27Currently Sylpheed is storing passwords in palin-text. One can always refrain
28from storing passwords and let Sylpheed prompt for them, but the more accounts
29one has, the more annoying this becomes.
30
31The goal is to have the passwords stored in a secure way and let Sylpheed only
32prompt for the master password.
33
34
35Security goals
36--------------
37
38- attacker (A) should not be able to derive the password from the digest
39
40- A should not be able to derive the master password even if she has
41 read and write access to the storage
42
43- A should not be able to determine the length of the encrypted password
44 even if she has read and write access to the storage
45
46- A should not be able to craft an edited password without obtaining the
47 master password
48
49- a warning / prompt should be given if a user accidently types in a "wrong"
50 master password before decryption is initiated
51
52
53Usage in Sylpheed
54-----------------
55
56- backup your Sylpheed profile (often $HOME/.sylpheed-2.0)!
57
58- start Sylpheed and open Configuration -> Common preferences...!
59
60- select the "Master password" tab, enable "Use master password" and
61 apply the changes!
62
63- restart Sylpheed (exit and then start Sylpheed again)!
64
65- you will be asked to type and verify a new master password.
66
67Note:
68Sylpheed will automatically convert existing stored passwords, but it will not
69touch your backups. You will have to remove all remnants of plain-text
70passwords manually.
71
72
73Choice of cryptographic primitives
74----------------------------------
75
76The primary concern when selecting cryptographic primitives was portability.
77The desire was to go for primitives that are both strong and available in all
78supported production distributions of OpenSSL and LibreSSL.
79
80
81Cipher
82......
83
84When it comes to implementation, there are several advantages in using stream
85cipher or a block cipher that behaves like a stream cipher when used in a
86certain mode of operation. One is avoiding to deal with padding.
87
88AES-256 operating in CFB was selected for these reasons.
89ChaCha20 should be considered as a replacement in the future.
90
91
92Hash-function
93.............
94
95Hash-functions are used for:
96- key derivation
97- plain-text digest
98
99Those operations do not have to use the same hash-function.
100(See the "Encryption & decryption scheme" section for more details!)
101
102Key-derivation:
103Since AES-256 uses a 256 bits key, we need a hash-function with at least
104the same digest size or bigger.
105Since the digest (which is the key itself) is considered confidential and is
106stored only in memory for only a limited amount of time, SHA-256 is considered
107sufficiently strong for that purpose.
108
109Size + plain-text + padding digest:
110Since the digest is created of both the plain-text and the plain-text size,
111as well as being encrypted, SHA-256 is considered sufficiently strong.
112SHA-512 may increase security at the price of adding additional 32 bytes
113to the encrypted password digest.
114
115Stronger hash-functions like SHA-3 or BLAKE2b can be considered as a
116replacement in the future.
117
118
119Master password digest
120......................
121
122In order to be able to decide whether the user typed a "wrong" master password,
123before attempting to decrypt, Sylpheed stores a digest of the master password
124in 'master_password_hash' in sylpheedrc.
125100000 iterations of PBKDF2_HMAC with SHA-512 and 16 bytes salt is used.
126Note that this digest is useless as a key and even if a plain-text that
127produces the same digest is found, it will most probably be useless as a
128master-password.
129
130
131Encryption & decryption scheme
132------------------------------
133
134
135Encryption
136..........
137
138
139Input:
140
141- palin-text password to be encrypted (P)
142
143- plain-text master-password used for key derivation (M)
144
145- integer minimum password length (0 < L < 100)
146
147
148Output:
149
150- an encrypted password digest (base64) (B)
151
152
153Operation:
154
155- generate 16 bytes of random data to be used as a salt (S)
156
157- derive the key (K): K = SHA_256(S + M)
158
159- produce a 2 byte string (N) indicating the length of P
160
161- if the length of P < L, produce L - P bytes of random data (R), N = "%02d"
162 if the length of P >= L, N = "-1"
163
164- produce a hash digest (H): H = SHA_256(N + P + R (if the length of P < L))
165
166- encrypt (E): E = AES_256_CFB_ENCRYPT(H + N + P + R (if the length of P < L), K)
167
168- B = mpes1:BASE64_ENCODE(S + E)
169 example:
170 mpes1:vo7lsIpD7i6byBA6+vlUoF4OVDfEe+aYRRk4FRtfJ2gMY8M43Kj6WfdfgbViIOl83bI4XEc96okhPW5Mla813aAR1gbPjDg0xmCyIbWOiUv/dg==
171
172
173Decryption
174..........
175
176
177Input:
178
179- encrypted password digest (base64) (B)
180
181- plain-text master-password used for key derivation (M)
182
183
184Output:
185
186- palin-text password (P)
187
188
189Operation:
190
191- remove the prefix (mpes1:) and base64-decode the rest of the digest: B = BASE64_DECODE(B)
192
193- fetch the first 16 bytes for the salt: S = B[0 : 15]
194
195- derive the key (K): K = SHA_256(S + M)
196
197- decrypt the rest of B (D): D = AES_256_CFB_DECRYPT(B[16 :], K)
198
199- extract the first 16 bytes for the hash digest (H): H = D[0 : 15]
200
201- in order to detect data-inconsistency, assert H == SHA_256(D[16 :])
202
203- extract the next 2 bytes for the length of P (N): N = D[16 : 17]
204
205- if N == "-1" the password is the remaining bytes of D: P = D[18 :]
206 if N != "-1", extract the next N-bytes from D: P = D[18 : (18 + N)]
207
208
209Limitations
210-----------
211
212- when Sylpheed starts, the master-password is loaded into memory and remains
213 there as long as Sylpheed is running. Currently no strong mechanisms,
214 preventing someone with access to the memory from snatching it,
215 are implemented.
216 "Unloading" the master-password immediately after
217 account-processing (decryption) should be considered in the future.
218
219- currently only the 'password' and 'smtp_password' keys in accountrc
220 are encrypted.
221 A machanism that allows for any key and even folders to be encrypted
222 should be considered in the future.
223
224- currently it is not possible to select alternative ciphers, hash-functions
225 and modes of operation (without editing the source code).
226
227- currently it is not possible to change your master password without having to
228 set your passwords manually.
229
230--
231Simeon Simeonov <sgs [ATTT] pichove (DOTTT) org>