summaryrefslogtreecommitdiff
path: root/src/solvers
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2014-11-27 02:06:03 -0800
committeriximeow <me@iximeow.net>2014-11-27 02:06:03 -0800
commit0af5a2e4ade0b032e1ec6d25c51de2ff95dd2799 (patch)
treea4771f91a22821ffae20224dcc04269a31f73bff /src/solvers
parent9877ccf7fe7df38f8ecc65d01e9b46a98528502f (diff)
Rough cut of challenge 10
Diffstat (limited to 'src/solvers')
-rw-r--r--src/solvers/Challenge10.scala51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/solvers/Challenge10.scala b/src/solvers/Challenge10.scala
new file mode 100644
index 0000000..a130106
--- /dev/null
+++ b/src/solvers/Challenge10.scala
@@ -0,0 +1,51 @@
+package ixee.cryptopals.solvers
+
+import scala.io.Source
+import ixee.cryptopals.utils.ByteUtils._
+import ixee.cryptopals.utils.StreamUtils._
+import ixee.cryptopals.utils.ConversionUtils._
+import ixee.cryptopals.utils.FunctionUtils._
+import ixee.cryptopals.utils._
+import io.github.marklister.base64.Base64._
+import javax.crypto.Cipher
+import javax.crypto.spec.SecretKeySpec
+
+object Challenge10 {
+ val path = "./data/10.txt"
+
+ lazy val ciphertext =
+ Source
+ .fromFile(path)
+ .getLines()
+ .toSeq
+ .mkString
+ .toByteArray
+
+ def run = {
+ val encInstance = CryptoUtils.cbcEncryptInstance(
+ "AES",
+ "YELLOW SUBMARINE".asBytes.toArray,
+ Stream.continually(0.toByte).take(16)
+ )
+
+ val decInstance = CryptoUtils.cbcDecryptInstance(
+ "AES",
+ "YELLOW SUBMARINE".asBytes.toArray,
+ Stream.continually(0.toByte).take(16)
+ )
+
+ val s = "foo bar frobnicator the quick brown fox jumps over the lazy dog".asBytes
+
+ val enc = encInstance.enc(s) ++ encInstance.end()
+ val dec = decInstance.dec(enc)
+ println(dec.startsWith(enc))
+
+ val decInstance2 = CryptoUtils.cbcDecryptInstance(
+ "AES",
+ "YELLOW SUBMARINE".asBytes.toArray,
+ Stream.continually(0.toByte).take(16)
+ )
+
+ decInstance2.dec(ciphertext)
+ }
+}