summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2020-12-13 10:35:29 -0500
committerrsiddharth <s@ricketyspace.net>2020-12-13 10:35:29 -0500
commit0757abde108a039b8ed867132300a87c8cd4d58d (patch)
tree685ce68a19e1b09b46ade099a98d598c71071a3e
parentf7dacb6eb820b553e1d565e177f77ab176f18897 (diff)
lib/aes: add OracleAESEncryptECB
-rw-r--r--lib/oracle.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/oracle.go b/lib/oracle.go
index a77793a..47d850c 100644
--- a/lib/oracle.go
+++ b/lib/oracle.go
@@ -8,6 +8,20 @@ import (
"math/big"
)
+var oracleUnknown string = `Um9sbGluJyBpbiBteSA1LjAKV2l0aCBteSByYWctdG9wIGRvd24gc28gbXkg
+aGFpciBjYW4gYmxvdwpUaGUgZ2lybGllcyBvbiBzdGFuZGJ5IHdhdmluZyBq
+dXN0IHRvIHNheSBoaQpEaWQgeW91IHN0b3A/IE5vLCBJIGp1c3QgZHJvdmUg
+YnkK`
+
+var oracleKey []byte = make([]byte, 16)
+
+func init() {
+ _, err := rand.Read(oracleKey)
+ if err != nil {
+ panic(err)
+ }
+}
+
// 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.
@@ -45,6 +59,10 @@ func OracleAESRandomEncrypt(in []byte) []byte {
return out
}
+func OracleAESEncryptECB(in []byte) []byte {
+ return AESEncryptECB(append(in, Base64ToBytes(oracleUnknown)...), oracleKey)
+}
+
// Randomly generates `min` to `max` bytes.
func randomBytes(min, max int64) []byte {
var rn *big.Int