improve (crypto): derivate secret_key for each usage to reduce attack surface in the worst case scenario

This commit is contained in:
Mickael KERJEAN
2019-01-18 13:48:04 +11:00
parent 7af12753ca
commit ec6eb0e8fa
10 changed files with 53 additions and 26 deletions

View File

@ -261,7 +261,7 @@ func ShareProofGetAlreadyVerified(req *http.Request) []Proof {
if len(cookieValue) > 500 {
return p
}
j, err := DecryptString(SECRET_KEY, cookieValue)
j, err := DecryptString(SECRET_KEY_DERIVATE_FOR_PROOF, cookieValue)
if err != nil {
return p
}
@ -306,7 +306,7 @@ func shareProofAreEquivalent(ref Proof, p Proof) bool {
}
for _, chunk := range strings.Split(ref.Value, ",") {
chunk = strings.Trim(chunk, " ")
if p.Id == Hash(ref.Key + "::" + chunk) {
if p.Id == Hash(ref.Key + "::" + chunk, 20) {
return true
}
}