crust

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package crust will contain cryptographic functions needed for communication between the xx messenger and Crust.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashFile

func HashFile(file []byte) ([]byte, error)

HashFile hashes the file using the go-multihash library.

func HashUsername

func HashUsername(username string) []byte

HashUsername hashes the passed in username using the sha256 hashing algorithm.

func JointVerify

func JointVerify(UDPubkey, userPublicKey *rsa.PublicKey, usernameHash,
	fileHash, verificationSignature, uploadSignature []byte, uploadTs,
	now time.Time) error

JointVerify verifies both the upload and the verification signature at once Both will be sent as part of the auth headers to Crust's upload and pinning service, this will make proper usage more clear Returns nil for the error if the verification is successful

func SignUpload

func SignUpload(rand io.Reader, userPrivKey *rsa.PrivateKey,
	file []byte, timestamp time.Time) ([]byte, error)

SignUpload returns a signature that proves that the user wants to upload a new file. The timestamp indicates the time the user wanted to upload the file. Use serializeTimestamp to serialize the timestamp.

func SignVerification

func SignVerification(rand io.Reader, udPrivKey *rsa.PrivateKey,
	username string, receptionPubKey *rsa.PublicKey) ([]byte, error)

SignVerification signs the user's username and reception public key, hashed together.

func VerifyUpload

func VerifyUpload(userPublicKey *rsa.PublicKey,
	now, timestamp time.Time,
	fileHash, signature []byte) error

VerifyUpload verifies the user's upload signature. The signature should be from SignUpload. The timestamp provided must be +-1 minute from the current time passed in as "now".

func VerifyVerificationSignature

func VerifyVerificationSignature(pubKey *rsa.PublicKey,
	usernameHash []byte, receptionPubKey *rsa.PublicKey, signature []byte) error

VerifyVerificationSignature verifies the signature provided from SignVerification.

Types

This section is empty.

Jump to

Keyboard shortcuts

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