crypto

package
v1.5.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2023 License: LGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChecksumFileSHA256

func ChecksumFileSHA256(path string) ([]byte, error)

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

func ExportPublicKeyAsPem(publicKey *rsa.PublicKey) ([]byte, error)

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

func ParsePemPublicKey(pubPEM []byte) (*rsa.PublicKey, error)

ParsePemPublicKey parse the pem public key

func VerifyFileSignature

func VerifyFileSignature(pub *rsa.PublicKey, signature []byte, path string) error

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

type Signatures struct {
	Version       string
	SignaturesMap map[string][]byte
}

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

func (s *Signatures) Verify(pub *rsa.PublicKey, relPath string, fullpath string) error

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

func (s *Signatures) VerifyFolder(pub *rsa.PublicKey, root string) ([]string, error)

VerifyFolder verifies all the files signatures of a folder returns list of unverified files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL