Minor improvements and version bumps

This commit is contained in:
2017-07-02 08:37:43 +02:00
parent a245288359
commit a8addf946b
15 changed files with 25 additions and 31 deletions

View File

@ -28,6 +28,6 @@ dependencies {
compile 'ch.dissem.msgpack:msgpack:1.0.0'
testCompile 'junit:junit:4.12'
testCompile 'org.hamcrest:hamcrest-library:1.3'
testCompile 'com.nhaarman:mockito-kotlin:1.4.0'
testCompile 'com.nhaarman:mockito-kotlin:1.5.0'
testCompile project(':cryptography-bc')
}

View File

@ -40,7 +40,6 @@ data class NetworkMessage(
return byteArrayOf(d[0], d[1], d[2], d[3])
}
@Throws(IOException::class)
override fun write(out: OutputStream) {
// magic
Encode.int32(MAGIC, out)

View File

@ -36,14 +36,14 @@ import java.util.*
import java.util.Collections
import kotlin.collections.HashSet
internal fun message(encoding: Plaintext.Encoding, subject: String, body: String): ByteArray = when (encoding) {
private fun message(encoding: Plaintext.Encoding, subject: String, body: String): ByteArray = when (encoding) {
SIMPLE -> "Subject:$subject\nBody:$body".toByteArray()
EXTENDED -> Message.Builder().subject(subject).body(body).build().zip()
TRIVIAL -> (subject + body).toByteArray()
IGNORE -> ByteArray(0)
}
internal fun ackData(type: Plaintext.Type, ackData: ByteArray?): ByteArray? {
private fun ackData(type: Plaintext.Type, ackData: ByteArray?): ByteArray? {
if (ackData != null) {
return ackData
} else if (type == MSG) {
@ -54,7 +54,7 @@ internal fun ackData(type: Plaintext.Type, ackData: ByteArray?): ByteArray? {
}
/**
* The unencrypted message to be sent by 'msg' or 'broadcast'.
* A plaintext message before encryption or after decryption.
*/
class Plaintext private constructor(
val type: Type,
@ -464,7 +464,7 @@ class Plaintext private constructor(
}
fun removeLabel(type: Label.Type) {
labels.removeIf { it.type == type }
labels.removeAll { it.type == type }
}
fun isUnread(): Boolean {

View File

@ -21,11 +21,11 @@ import java.util.*
data class Label(
private val label: String,
val type: Label.Type?,
val type: Label.Type? = null,
/**
* RGBA representation for the color.
*/
var color: Int
var color: Int = 0
) : Serializable {
var id: Any? = null

View File

@ -111,7 +111,6 @@ abstract class AbstractCryptography protected constructor(@JvmField protected va
}
}
@Throws(GeneralSecurityException::class)
protected fun doSign(data: ByteArray, privKey: java.security.PrivateKey): ByteArray {
// TODO: change this to ALGORITHM_EVP_SHA256 once it's generally used in the network
val sig = Signature.getInstance(ALGORITHM_ECDSA_SHA1, provider)
@ -121,7 +120,6 @@ abstract class AbstractCryptography protected constructor(@JvmField protected va
}
@Throws(GeneralSecurityException::class)
protected fun doCheckSignature(data: ByteArray, signature: ByteArray, publicKey: PublicKey): Boolean {
for (algorithm in arrayOf(ALGORITHM_ECDSA_SHA1, ALGORITHM_EVP_SHA256)) {
val sig = Signature.getInstance(algorithm, provider)