internal/age: refactor to use the new golang.org/x/crypto/curve25519 API

This commit is contained in:
Filippo Valsorda
2019-11-27 22:49:40 -04:00
parent 9821fcefc9
commit 03f7237541
6 changed files with 84 additions and 197 deletions
+1 -13
View File
@@ -7,10 +7,8 @@
package main
import (
"bytes"
"crypto/ed25519"
"crypto/rsa"
"crypto/sha256"
"fmt"
"os"
@@ -86,18 +84,8 @@ func (i *EncryptedSSHIdentity) Matches(block *format.Recipient) error {
if len(block.Args) != 1 {
return fmt.Errorf("invalid %v recipient block", i.Type())
}
hash, err := format.DecodeString(block.Args[0])
if err != nil {
return fmt.Errorf("failed to parse %v recipient: %v", i.Type(), err)
}
if len(hash) != 4 {
return fmt.Errorf("invalid %v recipient block", i.Type())
}
sH := sha256.New()
sH.Write(i.pubKey.Marshal())
hh := sH.Sum(nil)
if !bytes.Equal(hh[:4], hash) {
if block.Args[0] != age.SSHFingerprint(i.pubKey) {
return age.ErrIncorrectIdentity
}
return nil