mirror of
https://github.com/psforever/PSF-LoginServer.git
synced 2026-07-16 08:55:18 +00:00
Merge e724a04d1a into 6f4ceaee29
This commit is contained in:
commit
7109397eb0
2 changed files with 13 additions and 15 deletions
|
|
@ -3,9 +3,7 @@
|
|||
lazy val psforeverSettings = Seq(
|
||||
organization := "net.psforever",
|
||||
version := "1.0.2-SNAPSHOT",
|
||||
// TODO 2.13.5+ breaks Md5Mac test
|
||||
// possibly due to ListBuffer changes? https://github.com/scala/scala/pull/9257
|
||||
scalaVersion := "2.13.4",
|
||||
scalaVersion := "2.13.10",
|
||||
Global / cancelable := false,
|
||||
semanticdbEnabled := true,
|
||||
semanticdbVersion := scalafixSemanticdb.revision,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package net.psforever.util
|
||||
|
||||
import scodec.bits.ByteVector
|
||||
import scala.collection.mutable.ListBuffer
|
||||
import scala.collection.mutable.ArrayBuffer
|
||||
|
||||
object Md5Mac {
|
||||
val BLOCKSIZE = 64
|
||||
|
|
@ -39,14 +39,14 @@ object Md5Mac {
|
|||
class Md5Mac(val key: ByteVector) {
|
||||
import Md5Mac._
|
||||
|
||||
private val buffer: ListBuffer[Byte] = ListBuffer.fill(BLOCKSIZE)(0)
|
||||
private val digest: ListBuffer[Byte] = ListBuffer.fill(DIGESTSIZE)(0)
|
||||
private val m: ListBuffer[Byte] = ListBuffer.fill(32)(0)
|
||||
private val k1: ListBuffer[Byte] = ListBuffer.fill(16)(0)
|
||||
private val k2: ListBuffer[Byte] = ListBuffer.fill(16)(0)
|
||||
private val k3: ListBuffer[Byte] = ListBuffer.fill(BLOCKSIZE)(0)
|
||||
private var count: Long = 0
|
||||
private var position: Int = 0
|
||||
private val buffer: ArrayBuffer[Byte] = ArrayBuffer.fill(BLOCKSIZE)(0)
|
||||
private val digest: ArrayBuffer[Byte] = ArrayBuffer.fill(DIGESTSIZE)(0)
|
||||
private val m: ArrayBuffer[Byte] = ArrayBuffer.fill(32)(0)
|
||||
private val k1: ArrayBuffer[Byte] = ArrayBuffer.fill(16)(0)
|
||||
private val k2: ArrayBuffer[Byte] = ArrayBuffer.fill(16)(0)
|
||||
private val k3: ArrayBuffer[Byte] = ArrayBuffer.fill(BLOCKSIZE)(0)
|
||||
private var count: Long = 0
|
||||
private var position: Int = 0
|
||||
|
||||
private val t: Seq[Seq[Byte]] = Seq(
|
||||
Seq(0x97, 0xef, 0x45, 0xac, 0x29, 0x0f, 0x43, 0xcd, 0x45, 0x7e, 0x1b, 0x55, 0x1c, 0x80, 0x11, 0x34),
|
||||
|
|
@ -58,8 +58,8 @@ class Md5Mac(val key: ByteVector) {
|
|||
doKey()
|
||||
|
||||
private def doKey(): Unit = {
|
||||
val ek: ListBuffer[Byte] = ListBuffer.fill(48)(0)
|
||||
val data: ListBuffer[Byte] = ListBuffer.fill(128)(0)
|
||||
val ek: ArrayBuffer[Byte] = ArrayBuffer.fill(48)(0)
|
||||
val data: ArrayBuffer[Byte] = ArrayBuffer.fill(128)(0)
|
||||
(0 until 16).foreach(j => {
|
||||
data(j) = key(j % key.length)
|
||||
data(j + 112) = key(j % key.length)
|
||||
|
|
@ -226,7 +226,7 @@ class Md5Mac(val key: ByteVector) {
|
|||
* @return the hash
|
||||
*/
|
||||
def doFinal(length: Int = MACLENGTH): ByteVector = {
|
||||
val output: ListBuffer[Byte] = ListBuffer.fill(MACLENGTH)(0)
|
||||
val output: ArrayBuffer[Byte] = ArrayBuffer.fill(MACLENGTH)(0)
|
||||
buffer(position) = 0x80.toByte
|
||||
(position + 1 until BLOCKSIZE).foreach(i => buffer(i) = 0)
|
||||
if (position >= BLOCKSIZE - 8) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue