Refactor code to use subtle.ConstantTimeCompare for secure comparison (#466)
* Refactor code to use subtle.ConstantTimeCompare for secure comparison * Refactor code to use subtle.ConstantTimeCompare for secure comparison
This commit is contained in:
parent
3087aa4eb6
commit
a3f69952c0
4 changed files with 8 additions and 6 deletions
|
|
@ -4,6 +4,7 @@ package main
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/subtle"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"os"
|
||||
|
|
@ -329,7 +330,7 @@ func (p *plugin) findAndCreateUpstream(conn libplugin.ConnMetadata, password str
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if bytes.Equal(authedPubkey.Marshal(), publicKey) {
|
||||
if subtle.ConstantTimeCompare(authedPubkey.Marshal(), publicKey) == 1 {
|
||||
return p.createUpstream(conn, pipe.To, "")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue