add crypto-notes.md; closes #911
vitzli committed
Mar 10, 2015 at 21:54 UTC
098bcc5a61ee774d0c7a65f1f4840b329ec882a8
1 file changed
+40
dev/crypto-notes.md
new
+40
@@ -0,0 +1,40 @@
1
+## Important notes
2
+
3
+### Key-pair generation
4
+
5
+When compared to gpg without hardware-based (P)RNG, IPFS generates key-pair
6
+alarmingly fast: it takes ipfs about 1 minute to generate 4096-bit
7
+key-pair, but for gpg it takes about 10 minutes. In the same time
8
+entropy_avail show severe drop in available entropy for gpg, but for
9
+ipfs entropy drops about 100 bits.
10
+
11
+[This issue (#911)](https://github.com/jbenet/go-ipfs/issues/911) seems to be caused
12
+by `crypto/rand` implementation in the Go programming language:
13
+
14
+1. [in UNIX-like](http://golang.org/src/crypto/rand/rand_unix.go) operating
15
+system it uses /dev/urandom device:
16
+```
17
+// Easy implementation: read from /dev/urandom.
18
+// This is sufficient on Linux, OS X, and FreeBSD.
19
+```
20
+
21
+For OS X that would use 160-bit Yarrow PRNG based on SHA-1 key,
22
+for FreeBSD - 256-bit Yarrow algorithm. For both operating systems /dev/random and
23
+/dev/urandom are equal.
24
+
25
+2. [in Linux](http://golang.org/src/crypto/rand/rand_linux.go#L22) it falls back
26
+to urandom in several cases:
27
+```
28
+// Test whether we should use the system call or /dev/urandom.
29
+// We'll fall back to urandom if:
30
+// - the kernel is too old (before 3.17)
31
+// - the machine has no entropy available (early boot + no hardware
32
+// entropy source?) and we want to avoid blocking later.
33
+```
34
+
35
+The first clause would be used for several production-class operationg systems.
36
+
37
+3. [in Windows]() it uses Windows CryptGenRandom API.
38
+
39
+According to [wikipedia](https://en.wikipedia.org/?title=/dev/random) using
40
+/dev/urandom instead of /dev/random seems to be safe.