1 parent
cc7466823b
commit
e8c5b414d9
44 files changed
+7649
-344
No files matched your search
@@ -17,13 +17,14 @@ import (
|
||||
//
|
||||
// Two details matter for security here:
|
||||
//
|
||||
// - Every comparison is constant-time, including the API key scan. A
|
||||
// byte-at-a-time comparison leaks a valid key prefix to anyone who can
|
||||
// measure response latency, which is a real attack on a network-exposed
|
||||
// admin API.
|
||||
// - Keys are compared by hash, not by string, so the stored form is not a
|
||||
// raw key and a timing difference between a long and short key cannot
|
||||
// reveal length.
|
||||
// - Credentials are never compared in plaintext. An API key is hashed with
|
||||
// SHA-256 and looked up in a map keyed on that hash, so the long-lived
|
||||
// structure holds no key that could be read back out of a core dump, and a
|
||||
// lookup is a hash-map hit whose cost does not depend on how much of the
|
||||
// key the caller guessed. There is no byte-at-a-time scan: the comment that
|
||||
// used to describe one described a function with no callers.
|
||||
// - The two fields that are compared directly — the basic username and the
|
||||
// hashed password — go through subtle.ConstantTimeCompare.
|
||||
type authenticator struct {
|
||||
mode string
|
||||
// readOnly maps key hash -> key label.
|
||||
|
||||
Reference in new issue
Block a user