add config to key generation

This commit is contained in:
zhj4478 2018-06-06 14:05:57 -07:00
parent edf3da1573
commit 60d877f35d
2 changed files with 9 additions and 2 deletions

View file

@ -22,7 +22,7 @@ func ArmorKey(input []byte) (string, error) {
// ArmorWithType make bytes input to armor format // ArmorWithType make bytes input to armor format
func ArmorWithType(input []byte, armorType string) (string, error) { func ArmorWithType(input []byte, armorType string) (string, error) {
var b bytes.Buffer var b bytes.Buffer
w, err := armor.Encode(&b, armorType, nil) w, err := armor.Encode(&b, armorType, armorHeader)
if err != nil { if err != nil {
return "", err return "", err
} }

9
key.go
View file

@ -2,6 +2,7 @@ package pm
import ( import (
"bytes" "bytes"
"crypto"
"encoding/hex" "encoding/hex"
"errors" "errors"
"fmt" "fmt"
@ -162,7 +163,13 @@ func (o *OpenPGP) GenerateKey(userName string, domain string, passphrase string,
return o.getNow() return o.getNow()
} }
cfg := &packet.Config{RSABits: bits, Time: timeNow} cfg := &packet.Config{
RSABits: bits,
Time: timeNow,
DefaultHash: crypto.SHA256,
DefaultCipher: packet.CipherAES256,
}
newEntity, err := openpgp.NewEntity(email, comments, email, cfg) newEntity, err := openpgp.NewEntity(email, comments, email, cfg)
if err != nil { if err != nil {
return "", err return "", err