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.
This commit is contained in:
8
gauth.go
8
gauth.go
@ -2,7 +2,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"code.google.com/p/gopass"
|
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
"crypto/cipher"
|
"crypto/cipher"
|
||||||
"crypto/hmac"
|
"crypto/hmac"
|
||||||
@ -11,12 +10,14 @@ import (
|
|||||||
"encoding/base32"
|
"encoding/base32"
|
||||||
"encoding/csv"
|
"encoding/csv"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"golang.org/x/crypto/ssh/terminal"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"math/big"
|
"math/big"
|
||||||
"os/user"
|
"os/user"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -82,7 +83,8 @@ func main() {
|
|||||||
|
|
||||||
// Support for 'openssl enc -aes-128-cbc -md sha256 -pass pass:'
|
// 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 {
|
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 {
|
if e != nil {
|
||||||
log.Fatal(e)
|
log.Fatal(e)
|
||||||
}
|
}
|
||||||
@ -102,7 +104,7 @@ func main() {
|
|||||||
mode := cipher.NewCBCDecrypter(block, iv)
|
mode := cipher.NewCBCDecrypter(block, iv)
|
||||||
mode.CryptBlocks(rest, rest)
|
mode.CryptBlocks(rest, rest)
|
||||||
// Remove padding
|
// Remove padding
|
||||||
i := len(rest)
|
i := len(rest) - 1
|
||||||
for rest[i] < 16 {
|
for rest[i] < 16 {
|
||||||
i--
|
i--
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user