From 08c36af51e68d71b6c45eefd15cfdfd1bb02f7ab Mon Sep 17 00:00:00 2001 From: Pierre Carrier Date: Thu, 3 Dec 2015 18:21:57 +0000 Subject: [PATCH] fix encryption - moving to crypto/ssh/terminal, which should also work on Windows and be better maintained (code.google.com is going away) - fix support for padding Closes #2. --- gauth.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gauth.go b/gauth.go index 2c64d57..cc4c490 100644 --- a/gauth.go +++ b/gauth.go @@ -2,7 +2,6 @@ package main import ( "bytes" - "code.google.com/p/gopass" "crypto/aes" "crypto/cipher" "crypto/hmac" @@ -11,12 +10,14 @@ import ( "encoding/base32" "encoding/csv" "fmt" + "golang.org/x/crypto/ssh/terminal" "io/ioutil" "log" "math/big" "os/user" "path" "strings" + "syscall" "time" ) @@ -82,7 +83,8 @@ func main() { // Support for 'openssl enc -aes-128-cbc -md sha256 -pass pass:' if bytes.Compare(cfgContent[:8], []byte{0x53, 0x61, 0x6c, 0x74, 0x65, 0x64, 0x5f, 0x5f}) == 0 { - passwd, e := gopass.GetPass("Encryption password: ") + fmt.Printf("Encryption password: ") + passwd, e := terminal.ReadPassword(syscall.Stdin) if e != nil { log.Fatal(e) } @@ -102,7 +104,7 @@ func main() { mode := cipher.NewCBCDecrypter(block, iv) mode.CryptBlocks(rest, rest) // Remove padding - i := len(rest) + i := len(rest) - 1 for rest[i] < 16 { i-- }