diff options
| author | Shulhan <ms@kilabit.info> | 2024-01-30 02:01:41 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2024-01-30 02:01:41 +0700 |
| commit | 77ba620765a5682e05169be8b8740df925f612c8 (patch) | |
| tree | e33f5273e5d124afb020040c4466f7a93c5cb3f7 /gotp.go | |
| parent | a6f27c3faea924a509915ab679511033893b773f (diff) | |
| download | gotp-77ba620765a5682e05169be8b8740df925f612c8.tar.xz | |
all: use [lib/crypto.LoadPrivateKeyInteractive]
The lib/crypto.LoadPrivateKeyInteractive provides a simple way to read
passphrase from stdin that also support SSH_ASKPASS.
While at it, add test for Cli with passphrase.
Diffstat (limited to 'gotp.go')
| -rw-r--r-- | gotp.go | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -5,7 +5,9 @@ package gotp import ( + "io" "strings" + "time" "unicode" ) @@ -30,6 +32,15 @@ const ( // Version define the latest version of this module and gotp CLI. var Version = `0.4.0` +// termrw define terminal for reading passphrase. +// It is defined to mock parameter termrw in +// [libcrypto.LoadPrivateKeyInteractive]. +var termrw io.ReadWriter + +// timeNow return the current time in UTC. +// It is defined to mock current time for testing Generate. +var timeNow = func() time.Time { return time.Now().UTC() } + // normalizeLabel convert non alpha number, hyphen, underscore, or period // characters into `-`. func normalizeLabel(in string) (out string) { |
