8000 update: use pbkdf2 for better security by HolgerHuo · Pull Request #65 · gobackup/gobackup · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

update: use pbkdf2 for better security #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions encryptor/openssl.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,29 @@ import (
// - base64: false
// - salt: true
// - password:
// - pbkdf2: true
// - iter: 10000
type OpenSSL struct {
Base
salt bool
base64 bool
iter int
pbkdf2 bool
password string
}

func (enc *OpenSSL) perform() (encryptPath string, err error) {
sslViper := enc.viper
sslViper.SetDefault("salt", true)
sslViper.SetDefault("base64", false)
sslViper.SetDefault("iter", 10000)
sslViper.SetDefault("pbkdf2", true)

enc.salt = sslViper.GetBool("salt")
enc.base64 = sslViper.GetBool("base64")
enc.password = sslViper.GetString("password")
enc.pbkdf2 = sslViper.GetBool("pbkdf2")
enc.password = sslViper.GetString("password")

if len(enc.password) == 0 {
err = fmt.Errorf("password option is required")
Expand All @@ -48,6 +56,12 @@ func (enc *OpenSSL) options() (opts []string) {
if enc.salt {
opts = append(opts, "-salt")
}
if enc.iter > 0 {
opts = append(opts, "-iter", fmt.Sprintf("%d", enc.iter))
}
if enc.pbkdf2 {
opts = append(opts, "-pbkdf2")
}
opts = append(opts, `-k`, enc.password)
return opts
}
0