mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2025-10-28 04:05:21 +08:00
improve (crypto): derivate secret_key for each usage to reduce attack surface in the worst case scenario
This commit is contained in:
@ -16,4 +16,22 @@ const (
|
||||
URL_SETUP = "/admin/setup"
|
||||
)
|
||||
|
||||
var BUILD_NUMBER string
|
||||
var (
|
||||
BUILD_NUMBER string
|
||||
SECRET_KEY string
|
||||
SECRET_KEY_DERIVATE_FOR_PROOF string
|
||||
SECRET_KEY_DERIVATE_FOR_ADMIN string
|
||||
SECRET_KEY_DERIVATE_FOR_USER string
|
||||
)
|
||||
|
||||
|
||||
/*
|
||||
* Improve security by calculating derivative of the secret key to restrict the attack surface
|
||||
* in the worst case scenario with one compromise secret key
|
||||
*/
|
||||
func InitSecretDerivate(secret string) {
|
||||
SECRET_KEY = secret
|
||||
SECRET_KEY_DERIVATE_FOR_PROOF = Hash("PROOF_" + SECRET_KEY, len(SECRET_KEY))
|
||||
SECRET_KEY_DERIVATE_FOR_ADMIN = Hash("ADMIN_" + SECRET_KEY, len(SECRET_KEY))
|
||||
SECRET_KEY_DERIVATE_FOR_USER = Hash("USER_" + SECRET_KEY, len(SECRET_KEY))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user