X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=passwd.go;h=6fb75f57a192702bcc793495a9c44de708d163af;hb=bcfc26f87e27a5d749eeed3194681e8018df4c5b;hp=852192f8b7ea898cb54d7ea3a4e912f884e13bc9;hpb=b144ad5b2dd5d62dd14909afd6696b3137bdf0db;p=gocheese.git diff --git a/passwd.go b/passwd.go index 852192f..6fb75f5 100644 --- a/passwd.go +++ b/passwd.go @@ -19,11 +19,31 @@ along with this program. If not, see . package main import ( + "errors" "io/ioutil" "log" "strings" ) +func strToAuther(verifier string) (string, Auther, error) { + st := strings.SplitN(verifier, "$", 3) + if len(st) != 3 || st[0] != "" { + return "", nil, errors.New("invalid verifier structure") + } + algorithm := st[1] + var auther Auther + var err error + switch algorithm { + case "argon2i": + auther, err = parseArgon2i(st[2]) + case "sha256": + auther, err = parseSHA256(st[2]) + default: + err = errors.New("unknown hashing algorithm") + } + return algorithm, auther, err +} + func refreshPasswd() { passwd, err := ioutil.ReadFile(*passwdPath) if err != nil {