pkg/metadata: Implement Load interface for files
Store msg+sig in the same file so that it's easier to do atomic read/writes.
Skeleton to start with:
package metadata
import (
"context"
"crypto"
"fmt"
)
// FileSource implements the Loader interface for signed metadata objects that
// are locatable via files. The following signature schemes are supported:
//
// - Ed25519 (RFC 8032, §5.1)
// - RSASSA-PKCS1-V1_5 with SHA256 (RFC 3447, §8.2)
//
// Use NewFileSource() to configure a new file source with FileSourceOptions.
type FileSource struct {
opts FileSourceOptions
}
// FileSourceOptions are options to configure a file source
type FileSourceOptions struct {
PublicKey crypto.PublicKey
FilePath string
}
// NewFileSource configures a new file source based on the provided options
func NewFileSource(opts FileSourceOptions) FileSource {
return FileSource{opts: opts}
}
// Load implements the Loader interface
func (s *FileSource) Load(ctx context.Context) ([]byte, []byte, Metadata, error) {
return nil, nil, Metadata{}, fmt.Errorf("TODO: implement file sources")
}
Edited by Rasmus Dahlberg