Documentation
¶
Index ¶
- func ChecksumFileSHA256(path string) ([]byte, error)
- func ExportPrivateKeyAsPem(privkey *rsa.PrivateKey) []byte
- func ExportPublicKeyAsPem(pubkey *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
- 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(privkey *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
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