Skip to content
This repository has been archived by the owner on Mar 14, 2020. It is now read-only.

Commit

Permalink
Update various dependencies
Browse files Browse the repository at this point in the history
* Library dependencies
* SBT plugins
* SBT version
* Scala version
  • Loading branch information
Richard-W committed Mar 7, 2019
1 parent 4f2e66c commit ec2faf6
Show file tree
Hide file tree
Showing 20 changed files with 90 additions and 187 deletions.
5 changes: 2 additions & 3 deletions build.sbt
Expand Up @@ -13,11 +13,11 @@ lazy val scalacrypt = project.in(file("."))
version := "0.5-SNAPSHOT",
licenses := Seq("Apache" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
homepage := Some(url("https://github.com/richard-w/scalacrypt")),
scalaVersion := "2.12.2",
scalaVersion := "2.12.8",
scalacOptions ++= Seq("-feature", "-unchecked", "-deprecation", "-opt:_"),
libraryDependencies ++= {
Seq(
"org.scalatest" %% "scalatest" % "3.0.1"
"org.scalatest" %% "scalatest" % "3.0.5"
)
},
publishMavenStyle := true,
Expand Down Expand Up @@ -45,4 +45,3 @@ lazy val scalacrypt = project.in(file("."))
</scm>
)
)
.settings(scalariformSettings: _*)
2 changes: 1 addition & 1 deletion project/build.properties
@@ -1 +1 @@
sbt.version=0.13.9
sbt.version=1.2.8
8 changes: 4 additions & 4 deletions project/plugins.sbt
@@ -1,7 +1,7 @@
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.2")

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.0")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1")

addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.1.0")
addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.7")

addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.3.0")
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.2")
3 changes: 1 addition & 2 deletions src/main/scala/blockciphers/SymmetricJavaBlockCipher.scala
Expand Up @@ -41,8 +41,7 @@ sealed trait SymmetricJavaBlockCipher[KeyType <: Key] extends BlockCipher[KeyTyp
}
} else {
Failure(
new IllegalBlockSizeException("Expected block of length " + blockSize + ", got " + block.length + " bytes.")
)
new IllegalBlockSizeException("Expected block of length " + blockSize + ", got " + block.length + " bytes."))
}
}

Expand Down
9 changes: 3 additions & 6 deletions src/main/scala/blockciphers/Threefish.scala
Expand Up @@ -189,8 +189,7 @@ trait Threefish256 extends Threefish[SymmetricKey256] {
Seq(25, 33),
Seq(46, 12),
Seq(58, 22),
Seq(32, 32)
)
Seq(32, 32))

val permutation: Seq[Int] = Seq(0, 3, 2, 1)

Expand All @@ -211,8 +210,7 @@ trait Threefish512 extends Threefish[SymmetricKey512] {
Seq(39, 30, 34, 24),
Seq(13, 50, 10, 17),
Seq(25, 29, 39, 43),
Seq(8, 35, 56, 22)
)
Seq(8, 35, 56, 22))

val permutation: Seq[Int] = Seq(2, 1, 4, 7, 6, 5, 0, 3)

Expand All @@ -233,8 +231,7 @@ trait Threefish1024 extends Threefish[SymmetricKey1024] {
Seq(41, 9, 37, 31, 12, 47, 44, 30),
Seq(16, 34, 56, 51, 4, 53, 42, 41),
Seq(31, 44, 47, 46, 19, 42, 44, 25),
Seq(9, 48, 35, 52, 23, 31, 37, 20)
)
Seq(9, 48, 35, 52, 23, 31, 37, 20))
val permutation: Seq[Int] = Seq(0, 9, 2, 13, 6, 11, 4, 15, 10, 7, 12, 3, 14, 5, 8, 1)

val reversePermutation: Seq[Int] = Seq(0, 15, 2, 11, 6, 13, 4, 9, 14, 1, 8, 5, 10, 3, 12, 7)
Expand Down
6 changes: 2 additions & 4 deletions src/main/scala/hash/MD5.scala
Expand Up @@ -44,8 +44,7 @@ object MD5 extends MDConstruction[(Int, Int, Int, Int)] {
7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21
)
6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21)

private val k = Seq(
0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
Expand All @@ -63,8 +62,7 @@ object MD5 extends MDConstruction[(Int, Int, Int, Int)] {
0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391
)
0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391)

private def g(t: Int): Int = {
if (t < 16) t
Expand Down
3 changes: 1 addition & 2 deletions src/main/scala/hash/SHA256.scala
Expand Up @@ -41,8 +41,7 @@ object SHA256 extends MDConstruction[(Int, Int, Int, Int, Int, Int, Int, Int)] {
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
)
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2)

def compressionFunction(state: (Int, Int, Int, Int, Int, Int, Int, Int), block: Seq[Byte]): (Int, Int, Int, Int, Int, Int, Int, Int) = {
val w = ((block.grouped(4).toSeq map { bytes2word(_) }) ++ Seq.fill[Int](64) { 0 }).toArray
Expand Down
3 changes: 1 addition & 2 deletions src/main/scala/khash/Hmac.scala
Expand Up @@ -35,8 +35,7 @@ class Hmac(hash: Hash) extends KeyedHash[Key] {
Success(
hash.apply.fold(Element(iKeyPad)) map { innerHash
hash(oKeyPad ++ innerHash)
}
)
})
}

def verify(key: Key, hash: Seq[Byte]): Try[Iteratee[Seq[Byte], Boolean]] = apply(key) map { _ map { _ == hash } }
Expand Down
9 changes: 3 additions & 6 deletions src/main/scala/suites/AES_CBC_NoPadding.scala
Expand Up @@ -28,8 +28,7 @@ object AES128_CBC_NoPadding {
'iv -> (iv match {
case Some(s) s
case _ Random.nextBytes(16)
})
)
}))

BlockCipher[AES128](params) flatMap { cipher
BlockCipherMode[CBC](params) flatMap { mode
Expand All @@ -49,8 +48,7 @@ object AES192_CBC_NoPadding {
'iv -> (iv match {
case Some(s) s
case _ Random.nextBytes(16)
})
)
}))

BlockCipher[AES192](params) flatMap { cipher
BlockCipherMode[CBC](params) flatMap { mode
Expand All @@ -70,8 +68,7 @@ object AES256_CBC_NoPadding {
'iv -> (iv match {
case Some(s) s
case _ Random.nextBytes(16)
})
)
}))

BlockCipher[AES256](params) flatMap { cipher
BlockCipherMode[CBC](params) flatMap { mode
Expand Down
9 changes: 3 additions & 6 deletions src/main/scala/suites/AES_CBC_PKCS7Padding.scala
Expand Up @@ -28,8 +28,7 @@ object AES128_CBC_PKCS7Padding {
'iv -> (iv match {
case Some(s) s
case _ Random.nextBytes(16)
})
)
}))

BlockCipher[AES128](params) flatMap { cipher
BlockCipherMode[CBC](params) flatMap { mode
Expand All @@ -49,8 +48,7 @@ object AES192_CBC_PKCS7Padding {
'iv -> (iv match {
case Some(s) s
case _ Random.nextBytes(16)
})
)
}))

BlockCipher[AES192](params) flatMap { cipher
BlockCipherMode[CBC](params) flatMap { mode
Expand All @@ -70,8 +68,7 @@ object AES256_CBC_PKCS7Padding {
'iv -> (iv match {
case Some(s) s
case _ Random.nextBytes(16)
})
)
}))

BlockCipher[AES256](params) flatMap { cipher
BlockCipherMode[CBC](params) flatMap { mode
Expand Down
3 changes: 1 addition & 2 deletions src/main/scala/suites/RSAES_OAEP.scala
Expand Up @@ -28,8 +28,7 @@ object RSAES_OAEP {
'rsaKey -> k,
'label -> label,
'hash -> hash,
'generator -> genSeed
)
'generator -> genSeed)

BlockCipher[RSA](params) flatMap { cipher
BlockCipherMode[ECB](params) flatMap { mode
Expand Down
9 changes: 3 additions & 6 deletions src/main/scala/suites/Threefish_CBC_PKCS7Padding.scala
Expand Up @@ -32,8 +32,7 @@ object Threefish256_CBC_PKCS7Padding {
'tweak -> (tweak match {
case Some(s) s
case _ Random.nextBytes(16)
})
)
}))

BlockCipher[Threefish256](params) flatMap { cipher
BlockCipherMode[CBC](params) flatMap { mode
Expand All @@ -57,8 +56,7 @@ object Threefish512_CBC_PKCS7Padding {
'tweak -> (tweak match {
case Some(s) s
case _ Random.nextBytes(16)
})
)
}))

BlockCipher[Threefish512](params) flatMap { cipher
BlockCipherMode[CBC](params) flatMap { mode
Expand All @@ -82,8 +80,7 @@ object Threefish1024_CBC_PKCS7Padding {
'tweak -> (tweak match {
case Some(s) s
case _ Random.nextBytes(16)
})
)
}))

BlockCipher[Threefish1024](params) flatMap { cipher
BlockCipherMode[CBC](params) flatMap { mode
Expand Down
3 changes: 1 addition & 2 deletions src/main/scala/util/PBKDF2Easy.scala
Expand Up @@ -24,8 +24,7 @@ import scala.util.{ Try, Success, Failure }
*/
object PBKDF2Easy {
lazy val algoMap = Map[Byte, KeyedHash[Key]](
1.toByte -> khash.HmacSHA256
)
1.toByte -> khash.HmacSHA256)

lazy val defaultAlgorithm = 1.toByte
val defaultSaltLength = 32
Expand Down
40 changes: 13 additions & 27 deletions src/test/scala/BlockCipherSpec.scala
Expand Up @@ -106,37 +106,30 @@ class AES128Spec extends BlockCipherSpec[SymmetricKey128, AES128] {

val parameterTestVectors = Seq(
(Parameters('symmetricKey256 -> Key.generate[SymmetricKey256]), false),
(Parameters('symmetricKey128 -> Key.generate[SymmetricKey192]), false)
)
(Parameters('symmetricKey128 -> Key.generate[SymmetricKey192]), false))

val defaultKey = (Seq(
0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c
) map { _.toByte }).toKey[SymmetricKey128].get
0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c) map { _.toByte }).toKey[SymmetricKey128].get

val testVectors = Seq(
(
Seq(0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a) map { _.toByte },
defaultKey,
Seq(0x3a, 0xd7, 0x7b, 0xb4, 0x0d, 0x7a, 0x36, 0x60, 0xa8, 0x9e, 0xca, 0xf3, 0x24, 0x66, 0xef, 0x97) map { _.toByte },
None
), (
None), (
Seq(0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51) map { _.toByte },
defaultKey,
Seq(0xf5, 0xd3, 0xd5, 0x85, 0x03, 0xb9, 0x69, 0x9d, 0xe7, 0x85, 0x89, 0x5a, 0x96, 0xfd, 0xba, 0xaf) map { _.toByte },
None
), (
None), (
Seq(0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef) map { _.toByte },
defaultKey,
Seq(0x43, 0xb1, 0xcd, 0x7f, 0x59, 0x8e, 0xce, 0x23, 0x88, 0x1b, 0x00, 0xe3, 0xed, 0x03, 0x06, 0x88) map { _.toByte },
None
), (
None), (
Seq(0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10) map { _.toByte },
defaultKey,
Seq(0x7b, 0x0c, 0x78, 0x5e, 0x27, 0xe8, 0xad, 0x3f, 0x82, 0x23, 0x20, 0x71, 0x04, 0x72, 0x5d, 0xd4) map { _.toByte },
None
)
)
None))
}

class AES192Spec extends BlockCipherSpec[SymmetricKey192, AES192] {
Expand All @@ -146,8 +139,7 @@ class AES192Spec extends BlockCipherSpec[SymmetricKey192, AES192] {

val parameterTestVectors = Seq(
(Parameters('symmetricKey256 -> Key.generate[SymmetricKey256]), false),
(Parameters('symmetricKey192 -> Key.generate[SymmetricKey1024]), false)
)
(Parameters('symmetricKey192 -> Key.generate[SymmetricKey1024]), false))

val testVectors = Seq()
}
Expand All @@ -159,8 +151,7 @@ class AES256Spec extends BlockCipherSpec[SymmetricKey256, AES256] {

val parameterTestVectors = Seq(
(Parameters('symmetricKey128 -> Key.generate[SymmetricKey128]), false),
(Parameters('symmetricKey256 -> Key.generate[SymmetricKey128]), false)
)
(Parameters('symmetricKey256 -> Key.generate[SymmetricKey128]), false))

val testVectors = Seq()
}
Expand All @@ -174,8 +165,7 @@ class Threefish256Spec extends BlockCipherSpec[SymmetricKey256, Threefish256] {
val parameterTestVectors = Seq(
(Parameters('symmetricKey128 -> Key.generate[SymmetricKey128], 'tweak -> tweak), false),
(Parameters('symmetricKey256 -> Key.generate[SymmetricKey1024], 'tweak -> tweak), false),
(Parameters('symmetricKey256 -> Key.generate[SymmetricKey256], 'tweak -> (0 until 15 map { _.toByte })), false)
)
(Parameters('symmetricKey256 -> Key.generate[SymmetricKey256], 'tweak -> (0 until 15 map { _.toByte })), false))

val testVectors = Seq()
}
Expand All @@ -189,8 +179,7 @@ class Threefish512Spec extends BlockCipherSpec[SymmetricKey512, Threefish512] {
val parameterTestVectors = Seq(
(Parameters('symmetricKey256 -> Key.generate[SymmetricKey256], 'tweak -> tweak), false),
(Parameters('symmetricKey512 -> Key.generate[SymmetricKey1024], 'tweak -> tweak), false),
(Parameters('symmetricKey512 -> Key.generate[SymmetricKey512], 'tweak -> (0 until 15 map { _.toByte })), false)
)
(Parameters('symmetricKey512 -> Key.generate[SymmetricKey512], 'tweak -> (0 until 15 map { _.toByte })), false))

val testVectors = Seq()
}
Expand All @@ -204,8 +193,7 @@ class Threefish1024Spec extends BlockCipherSpec[SymmetricKey1024, Threefish1024]
val parameterTestVectors = Seq(
(Parameters('symmetricKey256 -> Key.generate[SymmetricKey256], 'tweak -> tweak), false),
(Parameters('symmetricKey1024 -> Key.generate[SymmetricKey256], 'tweak -> tweak), false),
(Parameters('symmetricKey512 -> Key.generate[SymmetricKey512], 'tweak -> (0 until 15 map { _.toByte })), false)
)
(Parameters('symmetricKey512 -> Key.generate[SymmetricKey512], 'tweak -> (0 until 15 map { _.toByte })), false))

val testVectors = Seq()
}
Expand Down Expand Up @@ -263,8 +251,7 @@ class RSACrtSpec extends BlockCipherSpec[RSAKey, RSA] {

val parameterTestVectors = Seq(
(Parameters('symmetricKey256 -> Key.generate[SymmetricKey256]), false),
(Parameters('rsaKey -> Key.generate[SymmetricKey1024]), false)
)
(Parameters('rsaKey -> Key.generate[SymmetricKey1024]), false))

val testVectors = Seq()
}
Expand Down Expand Up @@ -324,8 +311,7 @@ class RSAExpSpec extends BlockCipherSpec[RSAKey, RSA] {

val parameterTestVectors = Seq(
(Parameters('symmetricKey256 -> Key.generate[SymmetricKey256]), false),
(Parameters('rsaKey -> Key.generate[SymmetricKey1024]), false)
)
(Parameters('rsaKey -> Key.generate[SymmetricKey1024]), false))

val testVectors = Seq()
}

0 comments on commit ec2faf6

Please sign in to comment.