Documentation ¶
Index ¶
- func ChecksumFileSHA256(path string) ([]byte, error)
- func ExportPrivateKeyAsPem(privateKey *rsa.PrivateKey) []byte
- func ExportPublicKeyAsPem(publicKey *rsa.PublicKey) ([]byte, error)
- func GeneratePrivateKey() (*rsa.PrivateKey, error)
- func GetFileSignature(priv *rsa.PrivateKey, path string) ([]byte, error)
- func ParsePemPrivateKey(privPEM []byte) (*rsa.PrivateKey, error)
- func ParsePemPublicKey(pubPEM []byte) (*rsa.PublicKey, error)
- func VerifyFileSignature(pub *rsa.PublicKey, signature []byte, path string) error
- func WriteSignaturesToJSON(dest string, signatures *Signatures) error
- type Signatures
- func (s *Signatures) Add(relPath string, signature []byte)
- func (s *Signatures) Get(relPath string) ([]byte, error)
- func (s *Signatures) Remove(relPath string)
- func (s *Signatures) Verify(pub *rsa.PublicKey, relPath string, fullpath string) error
- func (s *Signatures) VerifyFolder(pub *rsa.PublicKey, root string) ([]string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChecksumFileSHA256 ¶
ChecksumFileSHA256 calculate the sha256 checksum of a file
func ExportPrivateKeyAsPem ¶
func ExportPrivateKeyAsPem(privateKey *rsa.PrivateKey) []byte
ExportPrivateKeyAsPem exports the private key to Pem
func ExportPublicKeyAsPem ¶
ExportPublicKeyAsPem exports the public key as Pem
func GeneratePrivateKey ¶
func GeneratePrivateKey() (*rsa.PrivateKey, error)
GeneratePrivateKey generate a random private key.
func GetFileSignature ¶
func GetFileSignature(priv *rsa.PrivateKey, path string) ([]byte, error)
GetFileSignature signs a file using the given private key returns the signature in a hex string
func ParsePemPrivateKey ¶
func ParsePemPrivateKey(privPEM []byte) (*rsa.PrivateKey, error)
ParsePemPrivateKey parses the pem private key
func ParsePemPublicKey ¶
ParsePemPublicKey parse the pem public key
func VerifyFileSignature ¶
VerifyFileSignature verifies the signature of a file
func WriteSignaturesToJSON ¶ added in v1.5.1
func WriteSignaturesToJSON(dest string, signatures *Signatures) error
WriteSignaturesToJSON writes signatures to dest as a JSON file
Types ¶
type Signatures ¶
Signatures stores all the signatures of the files within a folder
func GetFolderSignatures ¶
func GetFolderSignatures(priv *rsa.PrivateKey, root string) (*Signatures, error)
GetFolderSignatures computes the signatures for a folder using the given private key
func LoadSignaturesFromJSON ¶
func LoadSignaturesFromJSON(path string) (signatures *Signatures, err error)
LoadSignaturesFromJSON loads signatures from a JSON file
func (*Signatures) Add ¶
func (s *Signatures) Add(relPath string, signature []byte)
Add adds a signature of a file relPath must be a relative path from the root of the folder
func (*Signatures) Get ¶
func (s *Signatures) Get(relPath string) ([]byte, error)
Get gets a signature of a file given a relative path
func (*Signatures) Remove ¶
func (s *Signatures) Remove(relPath string)
Remove removes a signature of a file given a relative path
func (*Signatures) Verify ¶
Verify verifies the signature of a file full path must be the full path to the file relPath must be relative to the root
func (*Signatures) VerifyFolder ¶
VerifyFolder verifies all the files signatures of a folder returns list of unverified files