2018-02-25 01:42:37 -08:00
|
|
|
package keyring
|
|
|
|
|
2018-02-25 01:45:56 -08:00
|
|
|
import (
|
|
|
|
"log"
|
2018-02-25 01:52:57 -08:00
|
|
|
"os"
|
|
|
|
"path/filepath"
|
2018-02-25 01:45:56 -08:00
|
|
|
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"golang.org/x/crypto/openpgp"
|
2018-02-25 01:52:57 -08:00
|
|
|
|
|
|
|
"mcquay.me/fs"
|
2018-02-25 01:45:56 -08:00
|
|
|
)
|
2018-02-25 01:42:37 -08:00
|
|
|
|
|
|
|
func NewKeyPair(root, name, email string) error {
|
2018-02-25 01:52:57 -08:00
|
|
|
pgpDir := filepath.Join(root, "var", "lib", "pm", "pgp")
|
|
|
|
if !fs.Exists(pgpDir) {
|
|
|
|
if err := os.MkdirAll(pgpDir, 0755); err != nil {
|
|
|
|
return errors.Wrap(err, "mk pgp dir")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-25 01:45:56 -08:00
|
|
|
e, err := openpgp.NewEntity(name, "pm", email, nil)
|
|
|
|
if err != nil {
|
|
|
|
errors.Wrap(err, "new entity")
|
|
|
|
}
|
|
|
|
log.Printf("%+v", e)
|
|
|
|
return errors.New("NYI")
|
2018-02-25 01:42:37 -08:00
|
|
|
}
|