66// Argon2 was selected as the winner of the Password Hashing Competition and can
77// be used to derive cryptographic keys from passwords.
88//
9- // For a detailed specification of Argon2 see [1 ].
9+ // For a detailed specification of Argon2 see [argon2-specs.pdf ].
1010//
1111// If you aren't sure which function you need, use Argon2id (IDKey) and
1212// the parameter recommendations for your scenario.
1717// It uses data-independent memory access, which is preferred for password
1818// hashing and password-based key derivation. Argon2i requires more passes over
1919// memory than Argon2id to protect from trade-off attacks. The recommended
20- // parameters (taken from [2 ]) for non-interactive operations are time=3 and to
20+ // parameters (taken from [RFC 9106 Section 7.3 ]) for non-interactive operations are time=3 and to
2121// use the maximum available memory.
2222//
2323// # Argon2id
2727// half of the first iteration over the memory and data-dependent memory access
2828// for the rest. Argon2id is side-channel resistant and provides better brute-
2929// force cost savings due to time-memory tradeoffs than Argon2i. The recommended
30- // parameters for non-interactive operations (taken from [2 ]) are time=1 and to
30+ // parameters for non-interactive operations (taken from [RFC 9106 Section 7.3 ]) are time=1 and to
3131// use the maximum available memory.
3232//
33- // [1] https://github.com/P-H-C/phc-winner-argon2/blob/master/argon2-specs.pdf
34- // [2] https://tools.ietf .org/html/draft-irtf-cfrg-argon2-03 #section-9 .3
33+ // [argon2-specs.pdf]: https://github.com/P-H-C/phc-winner-argon2/blob/master/argon2-specs.pdf
34+ // [RFC 9106 Section 7.3]: https://www.rfc-editor .org/rfc/rfc9106.html #section-7 .3
3535package argon2
3636
3737import (
@@ -59,7 +59,7 @@ const (
5959//
6060// key := argon2.Key([]byte("some password"), salt, 3, 32*1024, 4, 32)
6161//
62- // The draft RFC recommends[2] time=3, and memory=32*1024 is a sensible number.
62+ // [RFC 9106 Section 7.3] recommends time=3, and memory=32*1024 as a sensible number.
6363// If using that amount of memory (32 MB) is not possible in some contexts then
6464// the time parameter can be increased to compensate.
6565//
@@ -69,6 +69,8 @@ const (
6969// adjusted to the number of available CPUs. The cost parameters should be
7070// increased as memory latency and CPU parallelism increases. Remember to get a
7171// good random salt.
72+ //
73+ // [RFC 9106 Section 7.3]: https://www.rfc-editor.org/rfc/rfc9106.html#section-7.3
7274func Key (password , salt []byte , time , memory uint32 , threads uint8 , keyLen uint32 ) []byte {
7375 return deriveKey (argon2i , password , salt , nil , nil , time , memory , threads , keyLen )
7476}
@@ -83,7 +85,7 @@ func Key(password, salt []byte, time, memory uint32, threads uint8, keyLen uint3
8385//
8486// key := argon2.IDKey([]byte("some password"), salt, 1, 64*1024, 4, 32)
8587//
86- // The draft RFC recommends[2] time=1, and memory=64*1024 is a sensible number.
88+ // [RFC 9106 Section 7.3] recommends time=1, and memory=64*1024 as a sensible number.
8789// If using that amount of memory (64 MB) is not possible in some contexts then
8890// the time parameter can be increased to compensate.
8991//
@@ -93,6 +95,8 @@ func Key(password, salt []byte, time, memory uint32, threads uint8, keyLen uint3
9395// adjusted to the numbers of available CPUs. The cost parameters should be
9496// increased as memory latency and CPU parallelism increases. Remember to get a
9597// good random salt.
98+ //
99+ // [RFC 9106 Section 7.3]: https://www.rfc-editor.org/rfc/rfc9106.html#section-7.3
96100func IDKey (password , salt []byte , time , memory uint32 , threads uint8 , keyLen uint32 ) []byte {
97101 return deriveKey (argon2id , password , salt , nil , nil , time , memory , threads , keyLen )
98102}
0 commit comments