mirror of
https://github.com/hanzoai/age.git
synced 2026-10-30 15:07:21 +00:00
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
"runtime/debug"
|
|
|
|
"github.com/hanzoai/age"
|
|
"github.com/hanzoai/age/plugin"
|
|
"github.com/hanzoai/age/tag"
|
|
)
|
|
|
|
const usage = `age-plugin-tag is an age plugin for P-256 tagged recipients. These are supported
|
|
natively by age v1.3.0 and later, but this plugin can be placed in $PATH to add
|
|
support to any version and implementation of age that supports plugins.
|
|
|
|
Usually, tagged recipients are the public side of private keys held in hardware,
|
|
where the identity side is handled by a different plugin.`
|
|
|
|
// Version can be set at link time to override debug.BuildInfo.Main.Version when
|
|
// building manually without git history. It should look like "v1.2.3".
|
|
var Version string
|
|
|
|
func main() {
|
|
flag.Usage = func() { fmt.Fprintf(os.Stderr, "%s\n", usage) }
|
|
|
|
p, err := plugin.New("tag")
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
p.RegisterFlags(nil)
|
|
|
|
versionFlag := flag.Bool("version", false, "print the version")
|
|
flag.Parse()
|
|
|
|
if *versionFlag {
|
|
if buildInfo, ok := debug.ReadBuildInfo(); ok && Version == "" {
|
|
Version = buildInfo.Main.Version
|
|
}
|
|
fmt.Println(Version)
|
|
return
|
|
}
|
|
|
|
p.HandleRecipient(func(b []byte) (age.Recipient, error) {
|
|
return tag.NewClassicRecipient(b)
|
|
})
|
|
|
|
os.Exit(p.Main())
|
|
}
|