Documentation ¶
Overview ¶
Package sign implements Ed25519 signing, verification on files. It builds upon golang.org/x/crypto/ed25519 by adding methods for serializing and deserializing Ed25519 private & public keys. In addition, it works with large files - by precalculating their SHA512 checksum in mmap'd mode and sending the 64 byte signature for Ed25519 signing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Keypair ¶
type Keypair struct { Sec PrivateKey Pub PublicKey }
Ed25519 key pair
type PrivateKey ¶
type PrivateKey struct { Sk []byte // contains filtered or unexported fields }
Private Ed25519 key
func MakePrivateKey ¶
func MakePrivateKey(yml []byte, pw string) (*PrivateKey, error)
Make a private key from bytes 'yml' and password 'pw'. The bytes are assumed to be serialized version of the private key.
func ReadPrivateKey ¶
func ReadPrivateKey(fn string, pw string) (*PrivateKey, error)
Read the private key in 'fn', optionally decrypting it using password 'pw' and create new instance of PrivateKey
func (*PrivateKey) SignFile ¶
func (sk *PrivateKey) SignFile(fn string) (*Signature, error)
Read and sign a file
We calculate the signature differently here: We first calculate the SHA-512 checksum of the file and its size. We sign the checksum.
func (*PrivateKey) SignMessage ¶
func (sk *PrivateKey) SignMessage(ck []byte, comment string) (*Signature, error)
Sign a prehashed Message; return the signature as opaque bytes Signature is an YAML file:
Comment: source file path Signature: Ed25519 signature
type PublicKey ¶
type PublicKey struct {
Pk []byte
}
Public Ed25519 key
func MakePublicKey ¶
Parse a serialized public in 'yml' and return the resulting public key instance
func ReadPublicKey ¶
Read the public key from 'fn' and create new instance of PublicKey
func (*PublicKey) VerifyFile ¶
Verify a signature 'sig' for file 'fn' against public key 'pk' Return True if signature matches, False otherwise
type Signature ¶
type Signature struct { Sig []byte // 32 byte digital signature // contains filtered or unexported fields }
An Ed25519 Signature
func MakeSignature ¶
Parse serialized signature from bytes 'b' and construct a Signature object
func ReadSignature ¶
Read serialized signature from file 'fn' and construct a Signature object
func (*Signature) IsPKMatch ¶
IsPKMatch returns true if public key 'pk' can potentially validate the signature. It does this by comparing the hash of 'pk' against 'Pkhash' of 'sig'.
func (*Signature) SerializeFile ¶
SerializeFile serializes the signature to an output file 'f'