mirror of
https://github.com/whyvl/wireproxy.git
synced 2025-04-29 19:01:42 +02:00
constant time string comparison for socks5 credential validation
This commit is contained in:
parent
898c557b8c
commit
2defb13396
1 changed files with 4 additions and 1 deletions
|
@ -2,6 +2,7 @@ package wireproxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"crypto/subtle"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
@ -110,7 +111,9 @@ func (config *Socks5Config) SpawnRoutine(vt *VirtualTun) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c CredentialValidator) Valid(username, password string) bool {
|
func (c CredentialValidator) Valid(username, password string) bool {
|
||||||
return c.username == username && c.password == password
|
u := subtle.ConstantTimeCompare([]byte(c.username), []byte(username))
|
||||||
|
p := subtle.ConstantTimeCompare([]byte(c.password), []byte(password))
|
||||||
|
return u&p == 1
|
||||||
}
|
}
|
||||||
|
|
||||||
func connForward(bufSize int, from io.ReadWriteCloser, to io.ReadWriteCloser) {
|
func connForward(bufSize int, from io.ReadWriteCloser, to io.ReadWriteCloser) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue