From 6c4749a903744a16deb2fa6c426c4193afe76b4c Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Wed, 24 Feb 2021 19:58:23 -0500 Subject: lib: remove OracleAESRandomEncrypt Move function into C11 where it is used. --- lib/oracle.go | 32 -------------------------------- lib/rand.go | 2 +- 2 files changed, 1 insertion(+), 33 deletions(-) (limited to 'lib') diff --git a/lib/oracle.go b/lib/oracle.go index 29338ff..8a449a1 100644 --- a/lib/oracle.go +++ b/lib/oracle.go @@ -25,38 +25,6 @@ func init() { } } -// Given an input `in`, this function AES encrypts `in` using a -// randomly generate 16-byte key using ECB or CBC mode and returns the -// cipher. -func OracleAESRandomEncrypt(in []byte) []byte { - // Generate random key. - key, err := RandomBytes(16) - if err != nil { - panic(err) - } - // Generate random initialization vector; needed for AES CBC. - iv, err := RandomBytes(16) - if err != nil { - panic(err) - } - - // Add 5-10 bytes at the beginning and end of `in` - in = append(randomBytesWithLengthBetween(5, 10), in...) - in = append(in, randomBytesWithLengthBetween(5, 10)...) - - // Randomly encrypt `in` with AES in ECB or CBC mode. - m := RandomInt(0, 1) - var out []byte - if m == 0 { - // Encrypt with AES in ECB mode. - out = AESEncryptECB(in, key) - } else { - // Encrypt with AES in CBC mode. - out = AESEncryptCBC(in, key, iv) - } - return out -} - func OracleAESEncryptECB(in []byte) []byte { return AESEncryptECB(append(in, Base64ToBytes(oracleUnknown)...), oracleKey) } diff --git a/lib/rand.go b/lib/rand.go index 1ba1679..be95366 100644 --- a/lib/rand.go +++ b/lib/rand.go @@ -37,7 +37,7 @@ func RandomBytes(size int) ([]byte, error) { } // Randomly generates `min` to `max` bytes. -func randomBytesWithLengthBetween(min, max int64) []byte { +func RandomBytesWithLengthBetween(min, max int64) []byte { bs := make([]byte, RandomInt(min, max)) _, err := rand.Read(bs) if err != nil { -- cgit v1.2.3