aboutsummaryrefslogtreecommitdiff
path: root/invite.go
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-02-15 10:29:46 +0100
committerAlex Auvolat <alex@adnab.me>2020-02-15 10:29:46 +0100
commite1b5980f27ef60f0e655930d810138b6e2cd2752 (patch)
treee81073efda736e070a2e39df1bb5c0db79def8aa /invite.go
parent193e28cf0086a4b4a1f6d562c42b7c22b6e34561 (diff)
downloadguichet-e1b5980f27ef60f0e655930d810138b6e2cd2752.tar.gz
guichet-e1b5980f27ef60f0e655930d810138b6e2cd2752.zip
Use Argon2 hash function
Diffstat (limited to 'invite.go')
-rw-r--r--invite.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/invite.go b/invite.go
index 83e35a3..2ec6243 100644
--- a/invite.go
+++ b/invite.go
@@ -3,7 +3,6 @@ package main
import (
"bytes"
"crypto/rand"
- "crypto/sha256"
"encoding/binary"
"encoding/hex"
"fmt"
@@ -17,6 +16,7 @@ import (
"github.com/emersion/go-smtp"
"github.com/go-ldap/ldap/v3"
"github.com/gorilla/mux"
+ "golang.org/x/crypto/argon2"
)
var EMAIL_REGEXP = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
@@ -332,8 +332,8 @@ func readCode(code string) (code_id string, code_pw string) {
}
}
- id_hash := sha256.Sum256([]byte("Guichet ID " + code_digits))
- pw_hash := sha256.Sum256([]byte("Guichet PW " + code_digits))
+ id_hash := argon2.IDKey([]byte(code_digits), []byte("Guichet ID"), 2, 64*1024, 4, 32)
+ pw_hash := argon2.IDKey([]byte(code_digits), []byte("Guichet PW"), 2, 64*1024, 4, 32)
code_id = hex.EncodeToString(id_hash[:8])
code_pw = hex.EncodeToString(pw_hash[:16])