diff --git a/internal/signature/ident.go b/internal/signature/ident.go index 84edd54..c31f37a 100644 --- a/internal/signature/ident.go +++ b/internal/signature/ident.go @@ -7,10 +7,11 @@ import ( "crypto/rand" "crypto/rsa" "crypto/sha256" - "crypto/x509" - "encoding/pem" - "fmt" - "os" +_ "crypto/x509" +_ "encoding/pem" +_ "fmt" +_ "os" + "errors" ) var ErrInvalidSignature error = errors.New("Invalid signature") @@ -31,7 +32,7 @@ func NewIdent() *Ident { func (i *Ident) Generate() error { var err error i.privateKey, err = rsa.GenerateKey(rand.Reader, 2048) - i.publicKey = &privateKey.PublicKey + i.publicKey = &i.privateKey.PublicKey return err } @@ -39,7 +40,7 @@ func (i *Ident) Sign(data []byte) ([]byte, error) { checksum := sha256.Sum256(data) sig, e := rsa.SignPKCS1v15(rand.Reader, i.privateKey, crypto.SHA256, checksum[:]) if e != nil { - return e + return nil, e } return sig, e }