func encryptOracle(src []byte) []byte { key := util.RandAes128() block, _ := aes.NewCipher(key) out := make([]byte, len(src)) copy(out, src) // random prepend and append prefixSize := util.RandByte()%10 + 5 postfixSize := util.RandByte()%10 + 5 postfix := util.RandBytes(int(postfixSize)) out = append(util.RandBytes(int(prefixSize)), out...) out = append(out, postfix...) // padding out = util.PadTo(out, 16) // fmt.Println("before enc", out) // random encryption mode mode := util.RandByte() if mode%2 == 0 { // ecb fmt.Println("ecb") util.ECBEncrypt(block, out, out) } else { // cbc fmt.Println("cbc") iv := util.RandAes128() util.CBCEncrypt(block, iv, out, out) } return out }
func encryptProfile(email string) []byte { block, _ := aes.NewCipher(key) profile := profileFor(string(email)) out := make([]byte, len(profile)) copy(out, profile) out = util.PadTo(out, 16) fmt.Println("before enc:", out) util.ECBEncrypt(block, out, out) return out }
func encryptOracle(src []byte) []byte { block, _ := aes.NewCipher(key) out := make([]byte, len(src)) copy(out, src) appendix, _ := base64.StdEncoding.DecodeString("Um9sbGluJyBpbiBteSA1LjAKV2l0aCBteSByYWctdG9wIGRvd24gc28gbXkgaGFpciBjYW4gYmxvdwpUaGUgZ2lybGllcyBvbiBzdGFuZGJ5IHdhdmluZyBqdXN0IHRvIHNheSBoaQpEaWQgeW91IHN0b3A/IE5vLCBJIGp1c3QgZHJvdmUgYnkK") out = append(out, appendix...) out = util.PadTo(out, 16) // fmt.Println("before enc", out) util.ECBEncrypt(block, out, out) return out }
func encryptOracle(src []byte) []byte { block, _ := aes.NewCipher(key) out := make([]byte, len(src)) copy(out, src) target := []byte("secret bytes. nobody is gonna read them.") out = append(prefix, out...) out = append(out, target...) out = util.PadTo(out, 16) // fmt.Println("before enc", out) util.ECBEncrypt(block, out, out) return out }