utils

package
v0.0.0-...-f3f2e40 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2023 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AESCTRdecrypt

func AESCTRdecrypt(key []byte, ciphertext []byte) []byte

AEC-CTR decrypt data, setting initial counter to 0

func AESCTRencrypt

func AESCTRencrypt(key []byte, plaintext []byte) []byte

AEC-CTR encrypt data, setting initial counter to 0

func AESECBencrypt

func AESECBencrypt(key []byte, plaintext []byte) []byte

AEC-ECB encrypt data

func AESGCMdecrypt

func AESGCMdecrypt(key []byte, ctWithNonce []byte) []byte

decrypt and reuse the ciphertext slice to put plaintext into it

func AESGCMencrypt

func AESGCMencrypt(key []byte, plaintext []byte) []byte

func Assert

func Assert(condition bool)

func BitsToBytes

func BitsToBytes(b []int) []byte

convert an array of 0/1 with least bit at index 0 into bytes

func BytesToBits

func BytesToBits(b []byte) []int

convert bytes into a 0/1 array with least bit at index 0

func Concat

func Concat(slices ...[]byte) []byte

concatenate slices of bytes into a new slice with a new underlying array

func ConcatP

func ConcatP(pointers ...*[]byte) []byte

concatenate slices of bytes pointed to by pointers into a new slice with a new underlying array

func Contains

func Contains(n int, h []int) bool

check if int is in array

func Decrypt

func Decrypt(a, b []byte, t uint32, m []byte) []byte

func Decrypt_generic

func Decrypt_generic(plaintext []byte, key []byte, nonce int) []byte

func ECDSAPubkeyToPEM

func ECDSAPubkeyToPEM(key *ecdsa.PublicKey) []byte

func ECDSASign

func ECDSASign(key *ecdsa.PrivateKey, items ...[]byte) []byte

func Encrypt

func Encrypt(a, b []byte, t uint32, m []byte) []byte

Based on the the A4 method from Fig.1 and the D4 method in Fig6 of the BHKR13 paper (https://eprint.iacr.org/2013/426.pdf) Note that the paper doesn't prescribe a specific method to break the symmerty between A and B, so we choose a circular byte shift instead of a circular bitshift as in Fig6.

func Encrypt_generic

func Encrypt_generic(plaintext []byte, key []byte, nonce int) []byte

func ExpandRange

func ExpandRange(min int, max int) []int

expand the range [min:max] into array of ints 1,2,3,4... up to but not including max

func FinishHash

func FinishHash(outerState []byte, data []byte) []byte

finishes sha256 hash from a previous mid-state

func Flatten

func Flatten(sos [][]byte) []byte

flatten a slice of slices into a slice

func Generichash

func Generichash(length int, msg []byte) []byte

port of sodium.crypto_generichash

func GetRandom

func GetRandom(size int) []byte

GetRandom returns a random slice of specified size

func Max

func Max(a, b int) int

func RandInt

func RandInt(min, max int) int

func RandString

func RandString() string

func Reverse

func Reverse(s []int) []int

reverses elements order in slice of int, returns a new slice of int

func Sha256

func Sha256(data []byte) []byte

func SplitIntoChunks

func SplitIntoChunks(data []byte, chunkSize int) [][]byte

split a slice into smaller slices of size "chunkSize" each

func To16Bytes

func To16Bytes(x *big.Int) []byte

convert big.Int into a slice of 16 bytes

func To32Bytes

func To32Bytes(x *big.Int) []byte

convert big.Int into a slice of 32 bytes

func XorBytes

func XorBytes(a, b []byte) []byte

Types

This section is empty.

Jump to

Keyboard shortcuts

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