diff options
-rw-r--r-- | challenge/c17.go | 4 | ||||
-rw-r--r-- | lib/oracle.go | 8 | ||||
-rw-r--r-- | lib/rand.go | 2 |
3 files changed, 7 insertions, 7 deletions
diff --git a/challenge/c17.go b/challenge/c17.go index 78c949c..2ebc583 100644 --- a/challenge/c17.go +++ b/challenge/c17.go @@ -11,7 +11,7 @@ import ( // Cryptopals #17 - CBC padding oracle attack func C17() { - key, err := lib.RandomKey(16) + key, err := lib.RandomBytes(16) if err != nil { fmt.Printf("key generation: error: %v\n", err) } @@ -31,7 +31,7 @@ func C17() { r := lib.RandomInt(0, int64(len(cookies)-1)) p := lib.Base64ToBytes(cookies[r]) k := key - iv, err := lib.RandomKey(16) + iv, err := lib.RandomBytes(16) if err != nil { fmt.Printf("iv generation: error: %v\n", err) } diff --git a/lib/oracle.go b/lib/oracle.go index e2ee5fe..4def7e2 100644 --- a/lib/oracle.go +++ b/lib/oracle.go @@ -14,12 +14,12 @@ var oracleRandom []byte func init() { var err error - oracleKey, err = RandomKey(16) + oracleKey, err = RandomBytes(16) if err != nil { panic(err) } - oracleRandom, err = RandomKey(int(RandomInt(1, 4096))) + oracleRandom, err = RandomBytes(int(RandomInt(1, 4096))) if err != nil { panic(err) } @@ -30,12 +30,12 @@ func init() { // cipher. func OracleAESRandomEncrypt(in []byte) []byte { // Generate random key. - key, err := RandomKey(16) + key, err := RandomBytes(16) if err != nil { panic(err) } // Generate random initialization vector; needed for AES CBC. - iv, err := RandomKey(16) + iv, err := RandomBytes(16) if err != nil { panic(err) } diff --git a/lib/rand.go b/lib/rand.go index 03fd651..8546948 100644 --- a/lib/rand.go +++ b/lib/rand.go @@ -27,7 +27,7 @@ func RandomInt(min, max int64) int64 { } } -func RandomKey(size int) ([]byte, error) { +func RandomBytes(size int) ([]byte, error) { k := make([]byte, size) _, err := rand.Read(k) if err != nil { |