supportfunctions

package
v0.0.0-...-053aa00 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPadding

func AddPadding(bytes []byte, keysize int) []byte

AddPadding Abc

func AppendRandomBytesInFrontAndBack

func AppendRandomBytesInFrontAndBack(input []byte) (output []byte)

AppendRandomBytesInFrontAndBack abc

func CheckIfMinDistanceIsEqual3Times

func CheckIfMinDistanceIsEqual3Times(decodedBytesFromFile []byte, keysize int) bool

CheckIfMinDistanceIsEqual3Times UNTESTED, DO NOT USE

func ComputeHammingDistance

func ComputeHammingDistance(by1 []byte, by2 []byte) (result int)

ComputeHammingDistance abc

func CreateTableOfAllRepeatingKeyXORsWithInput

func CreateTableOfAllRepeatingKeyXORsWithInput(input string) []string

CreateTableOfAllRepeatingKeyXORsWithInput Creates a table with 128 ASCII chars repeated len(input) times, then XORs it with the input.

func DiscoverBlockSize

func DiscoverBlockSize(sillyOracle Oracle) (estimatedKeyLength int, addedPseudoPadding int, doubleBytePosition int)

DiscoverBlockSize abc

func EnglishCount

func EnglishCount(input string) (count int)

EnglishCount Counts all the instances of letters in "etaoin shrdlu"

func FindMostEnglishString

func FindMostEnglishString(decodedString []string) (letter int, bestString string)

FindMostEnglishString To find highest probability of an English text, applies a counter on letters in "etaoin shrdlu" on a set of strings, returning the one that has the most.

func FindThreeEqualDistances

func FindThreeEqualDistances(slice [][]byte) (ThreeEqual bool)

FindThreeEqualDistances UNTESTED, DO NOT USE

func GetByteListFromClonedString

func GetByteListFromClonedString(size int, letter string) []byte

GetByteListFromClonedString abc

func GetCypherMap

func GetCypherMap(sillyOracle Oracle, keysize int, oneByteShortByteList []byte) map[string]string

GetCypherMap abc

func GetMinDistanceInKeysizeMultiComparison

func GetMinDistanceInKeysizeMultiComparison(decodedBytesFromFile []byte, keysize int, nSlices int) (minDistanceFound int, positionofDoubleByte int)

GetMinDistanceInKeysizeMultiComparison Function to find the minimal Hamming distance for multiple ciphered blocks and if the distance is equal to 0, the position of the first doubled element

func GetRandomBytes

func GetRandomBytes(numberOfBytes int) (randomBytes []byte)

GetRandomBytes abc

func GetRandomInt

func GetRandomInt(maxValue int) (int, error)

GetRandomInt abc

func HexStringToBase64

func HexStringToBase64(msg string) (output string, err error)

HexStringToBase64 abc

func HexStringToBytes

func HexStringToBytes(msg string) (output []byte, err error)

HexStringToBytes abc

func MinOfDistances

func MinOfDistances(slice [][]byte, currentMin int, tempSliceNumber int, outsideValueForDoubleBytesPosition *int) (sum int)

MinOfDistances Recursive function to go through a 2D slice of bytes to calculate a minimal distance and if

func PaddingOracleAttack

func PaddingOracleAttack(attackedOracle Oracle) string

PaddingOracleAttack abc

func RemovePaddingAndFlatten2DArray

func RemovePaddingAndFlatten2DArray(bytesToFlatten [][]byte) (flatBytes []byte)

RemovePaddingAndFlatten2DArray Flattens and removes padding from a 2D array that it is provided

func XOROnBytes

func XOROnBytes(by1 []byte, by2 []byte) []byte

XOROnBytes abc

Types

type Oracle

type Oracle interface {
	PrepareInputString(input string) (output string)
	Encrypt([]byte) []byte
	Decrypt([]byte) []byte
}

Oracle interface type for all encryption functions

func NewPrefixInputPostfixCBCOracle

func NewPrefixInputPostfixCBCOracle(stringToPrefix string, stringToPostfix string, secretKey string) Oracle

NewPrefixInputPostfixCBCOracle abc

func NewPrefixInputPostfixECBOracle

func NewPrefixInputPostfixECBOracle(stringToPrefix string, stringToPostfix string, secretKey string) Oracle

NewPrefixInputPostfixECBOracle abc

type PrefixInputPostfixCBCOracle

type PrefixInputPostfixCBCOracle struct {
	// contains filtered or unexported fields
}

PrefixInputPostfixCBCOracle aaa

func (*PrefixInputPostfixCBCOracle) Decrypt

func (myOracle *PrefixInputPostfixCBCOracle) Decrypt(bytesToDecrypt []byte) []byte

Decrypt abc

func (*PrefixInputPostfixCBCOracle) Encrypt

func (myOracle *PrefixInputPostfixCBCOracle) Encrypt(unpaddedBytesToEncrypt []byte, iv []byte) []byte

Encrypt abc

func (*PrefixInputPostfixCBCOracle) PrepareInputString

func (myOracle *PrefixInputPostfixCBCOracle) PrepareInputString(input string) (output string)

PrepareInputString abc

type PrefixInputPostfixECBOracle

type PrefixInputPostfixECBOracle struct {
	// contains filtered or unexported fields
}

PrefixInputPostfixECBOracle aaa

func (*PrefixInputPostfixECBOracle) Decrypt

func (myOracle *PrefixInputPostfixECBOracle) Decrypt(bytesToDecrypt []byte) []byte

Decrypt abc

func (*PrefixInputPostfixECBOracle) Encrypt

func (myOracle *PrefixInputPostfixECBOracle) Encrypt(unpaddedBytesToEncrypt []byte) []byte

Encrypt abc

func (*PrefixInputPostfixECBOracle) PrepareInputString

func (myOracle *PrefixInputPostfixECBOracle) PrepareInputString(input string) (output string)

PrepareInputString abc

type RandomPrefixInputPostfixECBOOrCBCOracle

type RandomPrefixInputPostfixECBOOrCBCOracle struct {
	CBCOracle Oracle
	EBCOracle Oracle
	// contains filtered or unexported fields
}

RandomPrefixInputPostfixECBOOrCBCOracle abc

Jump to

Keyboard shortcuts

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