cryptopals

package module
v0.0.0-...-de37aec Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2017 License: MIT Imports: 6 Imported by: 0

README

cryptopals

My solutions to the cryptopals set of cryptography programming challenges http://cryptopals.com

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64Decode

func Base64Decode(src []byte) ([]byte, error)

Base64Decode decodes a byte array from base64 encoding Seems to be returning too long a slice for s1c6

func BreakRepeatingKeyXOR

func BreakRepeatingKeyXOR(b []byte) []byte

BreakRepeatingKeyXOR ...

func CBCDecrypt

func CBCDecrypt(b []byte, key []byte, iv []byte) []byte

CBCDecrypt - Cipher Block Chaining AES decryption likely less efficient than the crypto lib impl

func CBCEncrypt

func CBCEncrypt(b []byte, key []byte, iv []byte) []byte

CBCEncrypt - Cipher Block Chaining AES encryption likely less efficient than the crypto lib impl

func DecryptAESECB

func DecryptAESECB(b, key []byte) []byte

DecryptAESECB decrypts encrypted data b using given key Equivalent in openssl commandline: fmt.Sprintf(openssl enc -aes-128-ecb -a -d -K '%s' -nosalt -in 7.txt", hex.EncodeToString(key))

func DetectECB

func DetectECB(b []byte) bool

DetectECB detects if ciphertext b is encrypted via ECB

func DetermineKeysize

func DetermineKeysize(b []byte) (int, float64)

DetermineKeysize determines the likely keysize of an encryption cypher given the encrypted data b. It also returns normalised difference of the blocks of size keysize, this can be considered a sort of confidence, the lower the better

func EncryptAESECB

func EncryptAESECB(b, key []byte) []byte

EncryptAESECB encrypts data b using given key

func HammingDistance

func HammingDistance(bs ...[]byte) float64

func HexStringToBase64String

func HexStringToBase64String(h string) string

HexStringToBase64String is a utility function, not intended for heavy use due to string conversions

func HexToBase64

func HexToBase64(src []byte) []byte

HexToBase64 takes a hex encoded byte array and returns a base 64 encoded byte array, a function that only operates upon a byte repr is desirable in terms of effiency TODO: This is not hex specific, rename Base64Encode

func NewECBDecrypter

func NewECBDecrypter(b cipher.Block) cipher.BlockMode

func NewECBEncrypter

func NewECBEncrypter(b cipher.Block) cipher.BlockMode

func PKCS7Pad

func PKCS7Pad(b []byte, blockSize int) []byte

PKCS7Pad pads data b upto nearest multiple of blocksize PKCS#7 padding should work for any block size from 1 to 255 bytes

func PKCS7Unpad

func PKCS7Unpad(b []byte, blockSize int) []byte

PKCS7Unpad strips padding from unencrypted data b

func ScorePlaintext

func ScorePlaintext(s string) float64

ScorePlaintext scores a string for confidence that is plaintext, the higher the score, the higher the confidence

func Xor

func Xor(b1, b2 []byte) []byte

Xor takes two buffers and returns their XOR combination b2 can be shorter in length than b1, if so b2 will repeat

Types

type Result

type Result struct {
	Plaintext string
	Cypher    byte
	Score     float64
}

func BruteforceXOR

func BruteforceXOR(bIn1 []byte) *Result

BruteforceXOR searches for a single character XOR cypher that yields the most likely plaintext

Jump to

Keyboard shortcuts

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