@@ -59,18 +59,21 @@ const (
59
59
// For example, you can get a derived key for e.g. AES-256 (which needs a
60
60
// 32-byte key) by doing:
61
61
//
62
- // key := argon2.Key([]byte("some password"), salt, 3, 32*1024, 4 , 32)
62
+ // key := argon2.Key([]byte("some password"), salt, 3, 32*1024, 1 , 32)
63
63
//
64
64
// The draft RFC recommends[2] time=3, and memory=32*1024 is a sensible number.
65
65
// If using that amount of memory (32 MB) is not possible in some contexts then
66
66
// the time parameter can be increased to compensate.
67
67
//
68
68
// The time parameter specifies the number of passes over the memory and the
69
69
// memory parameter specifies the size of the memory in KiB. For example
70
- // memory=32*1024 sets the memory cost to ~32 MB. The number of threads can be
71
- // adjusted to the number of available CPUs. The cost parameters should be
72
- // increased as memory latency and CPU parallelism increases. Remember to get a
73
- // good random salt.
70
+ // memory=32*1024 sets the memory cost to ~32 MB. The threads parameter defines
71
+ // the parallelism degree used while deriving the key. It is commonly left at 1.
72
+ //
73
+ // The cost parameters should be increased as memory latency and CPU parallelism
74
+ // increases. Remember to get a good random salt. All cost parameters affect the
75
+ // result, so it is important to use static values for portability in
76
+ // distributed systems.
74
77
func Key (password , salt []byte , time , memory uint32 , threads uint8 , keyLen uint32 ) []byte {
75
78
return deriveKey (argon2i , password , salt , nil , nil , time , memory , threads , keyLen )
76
79
}
@@ -83,18 +86,21 @@ func Key(password, salt []byte, time, memory uint32, threads uint8, keyLen uint3
83
86
// For example, you can get a derived key for e.g. AES-256 (which needs a
84
87
// 32-byte key) by doing:
85
88
//
86
- // key := argon2.IDKey([]byte("some password"), salt, 1, 64*1024, 4 , 32)
89
+ // key := argon2.IDKey([]byte("some password"), salt, 1, 64*1024, 1 , 32)
87
90
//
88
91
// The draft RFC recommends[2] time=1, and memory=64*1024 is a sensible number.
89
92
// If using that amount of memory (64 MB) is not possible in some contexts then
90
93
// the time parameter can be increased to compensate.
91
94
//
92
95
// The time parameter specifies the number of passes over the memory and the
93
96
// memory parameter specifies the size of the memory in KiB. For example
94
- // memory=64*1024 sets the memory cost to ~64 MB. The number of threads can be
95
- // adjusted to the numbers of available CPUs. The cost parameters should be
96
- // increased as memory latency and CPU parallelism increases. Remember to get a
97
- // good random salt.
97
+ // memory=32*1024 sets the memory cost to ~32 MB. The threads parameter defines
98
+ // the parallelism degree used while deriving the key. It is commonly left at 1.
99
+ //
100
+ // The cost parameters should be increased as memory latency and CPU parallelism
101
+ // increases. Remember to get a good random salt. All cost parameters affect the
102
+ // result, so it is important to use static values for portability in
103
+ // distributed systems.
98
104
func IDKey (password , salt []byte , time , memory uint32 , threads uint8 , keyLen uint32 ) []byte {
99
105
return deriveKey (argon2id , password , salt , nil , nil , time , memory , threads , keyLen )
100
106
}
0 commit comments