Debian Codegraph @

extra/age-plugin-tagpq/plugin-tagpq.go

raw symbols SCIP
1 package main
2
3 import (
4 "flag"
5 "fmt"
6 "log"
7 "os"
8 "runtime/debug"
9
10 "filippo.io/age"
11 "filippo.io/age/plugin"
12 "filippo.io/age/tag"
13 )
14
15 const usage = `age-plugin-tagpq is an age plugin for ML-KEM-768 + P-256 post-quantum hybrid
16 tagged recipients. These are supported natively by age v1.3.0 and later, but
17 this plugin can be placed in $PATH to add support to any version and
18 implementation of age that supports plugins.
19
20 Usually, tagged recipients are the public side of private keys held in hardware,
21 where the identity side is handled by a different plugin.`
22
23 // Version can be set at link time to override debug.BuildInfo.Main.Version when
24 // building manually without git history. It should look like "v1.2.3".
25 var Version string
26
27 func main() {
28 flag.Usage = func() { fmt.Fprintf(os.Stderr, "%s\n", usage) }
29
30 p, err := plugin.New("tagpq")
31 if err != nil {
32 log.Fatal(err)
33 }
34 p.RegisterFlags(nil)
35
36 versionFlag := flag.Bool("version", false, "print the version")
37 flag.Parse()
38
39 if *versionFlag {
40 if buildInfo, ok := debug.ReadBuildInfo(); ok && Version == "" {
41 Version = buildInfo.Main.Version
42 }
43 fmt.Println(Version)
44 return
45 }
46
47 p.HandleRecipient(func(b []byte) (age.Recipient, error) {
48 return tag.NewHybridRecipient(b)
49 })
50
51 os.Exit(p.Main())
52 }