Remove all annotations

This commit is contained in:
Ugljesa Jovanovic authored and Ugljesa Jovanovic committed 2020-06-05 20:13:21 +02:00
1 parent d901a45b87
commit 3ad86e284a
46 files changed
+142 -142

No files matched your search

@@ -27,7 +27,7 @@ import com.ionspin.kotlin.crypto.util.rotateRight
* on 14-Jul-2019
*/
@ExperimentalUnsignedTypes
class Blake2bPure(val key: UByteArray? = null, val hashLength: Int = 64) : Blake2b {
companion object : Blake2bStatelessInterface {
@@ -144,7 +144,7 @@ class Blake2bPure(val key: UByteArray? = null, val hashLength: Int = 64) : Blake
return h
}
@ExperimentalStdlibApi
override fun digest(inputString: String, key: String?, hashLength: Int): UByteArray {
val array = inputString.encodeToByteArray().toUByteArray()
val keyBytes = key?.run {
@@ -243,7 +243,7 @@ class Blake2bPure(val key: UByteArray? = null, val hashLength: Int = 64) : Blake
}
}
@ExperimentalStdlibApi
constructor(
key: String?,
requestedHashLenght: Int = 64
@@ -308,7 +308,7 @@ class Blake2bPure(val key: UByteArray? = null, val hashLength: Int = 64) : Blake
}
}
@ExperimentalStdlibApi
override fun update(data: String) {
update(data.encodeToByteArray().toUByteArray())
}
@@ -28,7 +28,7 @@ import com.ionspin.kotlin.crypto.util.rotateRight
*/
@ExperimentalUnsignedTypes
class Sha256Pure : Sha256 {
override val MAX_HASH_BYTES: Int = 32
@@ -65,7 +65,7 @@ class Sha256Pure : Sha256 {
0x748f82eeU, 0x78a5636fU, 0x84c87814U, 0x8cc70208U, 0x90befffaU, 0xa4506cebU, 0xbef9a3f7U, 0xc67178f2U
)
@ExperimentalStdlibApi
override fun digest(inputString: String, key: String?, hashLength: Int): UByteArray {
return digest(
inputString.encodeToByteArray().toUByteArray(),
@@ -243,7 +243,7 @@ class Sha256Pure : Sha256 {
var bufferCounter = 0
var buffer = UByteArray(BLOCK_SIZE_IN_BYTES) { 0U }
@ExperimentalStdlibApi
override fun update(data: String) {
return update(data.encodeToByteArray().toUByteArray())
}
@@ -26,7 +26,7 @@ import com.ionspin.kotlin.crypto.util.rotateRight
* on 18-Jul-2019
*/
@ExperimentalUnsignedTypes
class Sha512Pure : Sha512 {
override val MAX_HASH_BYTES: Int = 32
@@ -133,7 +133,7 @@ class Sha512Pure : Sha512 {
0x5be0cd19137e2179UL
)
@ExperimentalStdlibApi
override fun digest(inputString: String, key: String?, hashLength: Int): UByteArray {
return digest(
inputString.encodeToByteArray().toUByteArray(),
@@ -318,7 +318,7 @@ class Sha512Pure : Sha512 {
var bufferCounter = 0
var buffer = UByteArray(BLOCK_SIZE_IN_BYTES) { 0U }
@ExperimentalStdlibApi
override fun update(data: String) {
return update(data.encodeToByteArray().toUByteArray())
}
@@ -53,7 +53,7 @@ data class ArgonResult(
@ExperimentalStdlibApi
class Argon2Pure(
private val password: UByteArray,
private val salt: UByteArray = ubyteArrayOf(),
@@ -161,7 +161,7 @@ object Argon2Utils {
// ------------ Arithmetic and other utils
@ExperimentalUnsignedTypes
fun UByteArray.xorWithBlock(other : ArgonMatrix, rowPosition: Int, columnPosition: Int) : UByteArray {
return UByteArray(BLOCK_SIZE) { this[it] xor other[rowPosition, columnPosition, it] }
}
@@ -30,7 +30,7 @@ import com.ionspin.kotlin.crypto.util.xor
* ugljesa.jovanovic@ionspin.com
* on 21-Sep-2019
*/
@ExperimentalUnsignedTypes
class AesCbcPure internal constructor(val aesKey: AesKey, val mode: Mode, initializationVector: UByteArray? = null) {
companion object {
@@ -219,7 +219,7 @@ class AesCbcPure internal constructor(val aesKey: AesKey, val mode: Mode, initia
}
@ExperimentalUnsignedTypes
data class EncryptedDataAndInitializationVector(val encryptedData : UByteArray, val initilizationVector : UByteArray) {
override fun equals(other: Any?): Boolean {
if (this === other) return true
@@ -35,7 +35,7 @@ import com.ionspin.kotlin.crypto.util.xor
* ugljesa.jovanovic@ionspin.com
* on 22-Sep-2019
*/
@ExperimentalUnsignedTypes
class AesCtrPure internal constructor(val aesKey: AesKey, val mode: Mode, initialCounter: UByteArray? = null) {
companion object {
@@ -186,7 +186,7 @@ class AesCtrPure internal constructor(val aesKey: AesKey, val mode: Mode, initia
}
@ExperimentalUnsignedTypes
data class EncryptedDataAndInitialCounter(val encryptedData : UByteArray, val initialCounter : UByteArray) {
override fun equals(other: Any?): Boolean {
if (this === other) return true
@@ -5,7 +5,7 @@ import com.ionspin.kotlin.crypto.util.flattenToUByteArray
/**
* Created by Ugljesa Jovanovic (jovanovic.ugljesa@gmail.com) on 07/Sep/2019
*/
@ExperimentalUnsignedTypes
internal class AesPure internal constructor(val aesKey: AesKey, val input: UByteArray) {
companion object {
private val debug = false
@@ -62,17 +62,17 @@ inline fun <reified T> Array<T>.chunked(sliceSize: Int): Array<Array<T>> {
}
@ExperimentalUnsignedTypes
infix fun UInt.rotateRight(places: Int): UInt {
return (this shr places) xor (this shl (32 - places))
}
@ExperimentalUnsignedTypes
infix fun ULong.rotateRight(places: Int): ULong {
return (this shr places) xor (this shl (64 - places))
}
@ExperimentalUnsignedTypes
infix fun Array<UByte>.xor(other : Array<UByte>) : Array<UByte> {
if (this.size != other.size) {
throw RuntimeException("Operands of different sizes are not supported yet")
@@ -80,7 +80,7 @@ infix fun Array<UByte>.xor(other : Array<UByte>) : Array<UByte> {
return Array(this.size) { this[it] xor other[it] }
}
@ExperimentalUnsignedTypes
infix fun UByteArray.xor(other : UByteArray) : UByteArray {
if (this.size != other.size) {
throw RuntimeException("Operands of different sizes are not supported yet")
@@ -88,17 +88,17 @@ infix fun UByteArray.xor(other : UByteArray) : UByteArray {
return UByteArray(this.size) { this[it] xor other[it] }
}
@ExperimentalUnsignedTypes
fun String.hexStringToTypedUByteArray() : Array<UByte> {
return this.chunked(2).map { it.toUByte(16) }.toTypedArray()
}
@ExperimentalUnsignedTypes
fun String.hexStringToUByteArray() : UByteArray {
return this.chunked(2).map { it.toUByte(16) }.toUByteArray()
}
@ExperimentalUnsignedTypes
fun Array<UByte>.toHexString() : String {
return this.joinToString(separator = "") {
if (it <= 0x0FU) {
@@ -109,7 +109,7 @@ fun Array<UByte>.toHexString() : String {
}
}
@ExperimentalUnsignedTypes
fun UByteArray.toHexString() : String {
return this.joinToString(separator = "") {
if (it <= 0x0FU) {
@@ -121,20 +121,20 @@ fun UByteArray.toHexString() : String {
}
// UInt / Array utils
@ExperimentalUnsignedTypes
fun UInt.toBigEndianUByteArray() : Array<UByte> {
return Array<UByte> (4) {
((this shr (24 - (it * 8))) and 0xFFU).toUByte()
}
}
@ExperimentalUnsignedTypes
fun UInt.toLittleEndianTypedUByteArray() : Array<UByte> {
return Array<UByte> (4) {
((this shr (it * 8)) and 0xFFU).toUByte()
}
}
@ExperimentalUnsignedTypes
fun UInt.toLittleEndianUByteArray() : UByteArray {
return UByteArray (4) {
((this shr (it * 8)) and 0xFFU).toUByte()
@@ -142,27 +142,27 @@ fun UInt.toLittleEndianUByteArray() : UByteArray {
}
// UInt / Array utils
@ExperimentalUnsignedTypes
fun ULong.toBigEndianUByteArray() : Array<UByte> {
return Array<UByte> (8) {
((this shr (56 - (it * 8))) and 0xFFU).toUByte()
}
}
@ExperimentalUnsignedTypes
fun ULong.toLittleEndianTypedUByteArray() : Array<UByte> {
return Array<UByte> (8) {
((this shr (it * 8)) and 0xFFU).toUByte()
}
}
@ExperimentalUnsignedTypes
fun ULong.toLittleEndianUByteArray() :UByteArray {
return UByteArray (8) {
((this shr (it * 8)) and 0xFFU).toUByte()
}
}
@ExperimentalUnsignedTypes
fun Array<UByte>.fromLittleEndianArrayToULong() : ULong {
if (this.size > 8) {
throw RuntimeException("ore than 8 bytes in input, potential overflow")
@@ -171,7 +171,7 @@ fun Array<UByte>.fromLittleEndianArrayToULong() : ULong {
return ulong
}
@ExperimentalUnsignedTypes
fun UByteArray.fromLittleEndianArrayToULong() : ULong {
if (this.size > 8) {
throw RuntimeException("ore than 8 bytes in input, potential overflow")
@@ -199,7 +199,7 @@ fun UByteArray.arrayChunked(sliceSize: Int): List<UByteArray> {
}
@ExperimentalUnsignedTypes
fun Array<UByte>.fromBigEndianArrayToULong() : ULong {
if (this.size > 8) {
throw RuntimeException("ore than 8 bytes in input, potential overflow")
@@ -213,7 +213,7 @@ fun Array<UByte>.fromBigEndianArrayToULong() : ULong {
return ulong
}
@ExperimentalUnsignedTypes
fun Array<UByte>.fromLittleEndianArrayToUInt() : UInt {
if (this.size > 4) {
throw RuntimeException("ore than 8 bytes in input, potential overflow")
@@ -222,7 +222,7 @@ fun Array<UByte>.fromLittleEndianArrayToUInt() : UInt {
return uint
}
@ExperimentalUnsignedTypes
fun UByteArray.fromLittleEndianArrayToUInt() : UInt {
if (this.size > 4) {
throw RuntimeException("ore than 8 bytes in input, potential overflow")
@@ -234,7 +234,7 @@ fun UByteArray.fromLittleEndianArrayToUInt() : UInt {
@ExperimentalUnsignedTypes
fun Array<UByte>.fromBigEndianArrayToUInt() : UInt {
if (this.size > 4) {
throw RuntimeException("ore than 8 bytes in input, potential overflow")
@@ -243,7 +243,7 @@ fun Array<UByte>.fromBigEndianArrayToUInt() : UInt {
return uint
}
@ExperimentalUnsignedTypes
operator fun UInt.plus(other : UByteArray) : UByteArray {
return this.toLittleEndianUByteArray() + other
}
@@ -34,8 +34,8 @@ import kotlin.time.measureTime
* ugljesa.jovanovic@ionspin.com
* on 20-Jul-2019
*/
@ExperimentalUnsignedTypes
@ExperimentalStdlibApi
class ReadmeTest {
@Test
@@ -76,7 +76,7 @@ class ReadmeTest {
}
}
@ExperimentalStdlibApi
@Test
fun sha256Example() {
val input = "abc"
@@ -89,7 +89,7 @@ class ReadmeTest {
}
@ExperimentalStdlibApi
@Test
fun sha512Example() {
val input = "abc"
@@ -104,7 +104,7 @@ class ReadmeTest {
}
@ExperimentalStdlibApi
@Test
fun sha256UpdatableExample() {
val sha256 = Sha256Pure()
@@ -116,7 +116,7 @@ class ReadmeTest {
}
}
@ExperimentalStdlibApi
@Test
fun sha512UpdatableExample() {
val sha512 = Sha512Pure()
@@ -30,7 +30,7 @@ import kotlin.test.assertTrue
* ugljesa.jovanovic@ionspin.com
* on 10-May-2020
*/
@ExperimentalStdlibApi
class Argon2KATTest {
@Test
@@ -25,8 +25,8 @@ import kotlin.test.assertTrue
* ugljesa.jovanovic@ionspin.com
* on 14-Jul-2019
*/
@ExperimentalUnsignedTypes
@ExperimentalStdlibApi
class Blake2BTest {
@Test
@@ -24,8 +24,8 @@ import kotlin.test.assertTrue
* ugljesa.jovanovic@ionspin.com
* on 20-Jul-2019
*/
@ExperimentalUnsignedTypes
@ExperimentalStdlibApi
class Blake2bInstanceTest {
@Test
@@ -30,8 +30,8 @@ data class KnownAnswerTest(
val hash: String
)
@ExperimentalUnsignedTypes
@ExperimentalStdlibApi
class Blake2bKnowAnswerTests {
@Test
fun knownAnswerTest() {
@@ -24,10 +24,10 @@ import kotlin.test.assertTrue
* ugljesa.jovanovic@ionspin.com
* on 17-Jul-2019
*/
@ExperimentalUnsignedTypes
class Sha256Test {
@ExperimentalStdlibApi
@Test
fun testWellKnownValue() {
@@ -40,7 +40,7 @@ class Sha256Test {
}
@ExperimentalStdlibApi
@Test
fun testWellKnownDoubleBlock() {
@@ -51,7 +51,7 @@ class Sha256Test {
}
}
@ExperimentalStdlibApi
@Test
fun testWellKnown3() { //It's good that I'm consistent with names.
@@ -64,7 +64,7 @@ class Sha256Test {
}
}
@ExperimentalStdlibApi
@Test
fun testWellKnownLong() {
val inputBuilder = StringBuilder()
@@ -25,10 +25,10 @@ import kotlin.test.assertTrue
* ugljesa.jovanovic@ionspin.com
* on 17-Jul-2019
*/
@ExperimentalUnsignedTypes
class Sha256UpdatableTest {
@ExperimentalStdlibApi
@Test
fun testWellKnownValue() {
val sha256 = Sha256Pure()
@@ -40,7 +40,7 @@ class Sha256UpdatableTest {
}
}
@ExperimentalStdlibApi
@Test
fun testWellKnownDoubleBlock() {
val sha256 = Sha256Pure()
@@ -53,7 +53,7 @@ class Sha256UpdatableTest {
}
}
@ExperimentalStdlibApi
@Test
fun testWellKnown3() { //It's good that I'm consistent with names.
val sha256 = Sha256Pure()
@@ -66,7 +66,7 @@ class Sha256UpdatableTest {
}
}
@ExperimentalStdlibApi
@Test
fun testWellKnownLong() {
val sha256 = Sha256Pure()
@@ -81,7 +81,7 @@ class Sha256UpdatableTest {
}
@Ignore()
@ExperimentalStdlibApi
@Test
fun testWellKnownLonger() {
val sha256 = Sha256Pure()
@@ -26,7 +26,7 @@ import kotlin.test.assertTrue
*/
class Sha512Test {
@ExperimentalStdlibApi
@Test
fun testWellKnownValue() {
@@ -41,8 +41,8 @@ class Sha512Test {
}
@ExperimentalUnsignedTypes
@ExperimentalStdlibApi
@Test
fun testWellKnown3() {
val sha512 = Sha512Pure()
@@ -55,7 +55,7 @@ class Sha512Test {
}
}
@ExperimentalStdlibApi
@Test
fun testWellKnownLong() {
val inputBuilder = StringBuilder()
@@ -26,7 +26,7 @@ import kotlin.test.assertTrue
* on 21-Jul-2019
*/
class Sha512UpdatableTest {
@ExperimentalStdlibApi
@Test
fun testWellKnownValue() {
val sha512 = Sha512Pure()
@@ -41,7 +41,7 @@ class Sha512UpdatableTest {
}
@ExperimentalStdlibApi
@Test
fun testWellKnownDoubleBlock() {
val sha512 = Sha512Pure()
@@ -55,7 +55,7 @@ class Sha512UpdatableTest {
}
}
@ExperimentalStdlibApi
@Test
fun testWellKnownLong() {
val sha512 = Sha512Pure()
@@ -70,7 +70,7 @@ class Sha512UpdatableTest {
}
@Ignore() //Interestingly enough I'm not the only one having trouble with this test.
@ExperimentalStdlibApi
@Test
fun testWellKnownLonger() {
val sha512 = Sha512Pure()
@@ -26,7 +26,7 @@ import kotlin.test.assertTrue
* ugljesa.jovanovic@ionspin.com
* on 21-Sep-2019
*/
@ExperimentalUnsignedTypes
class AesCbcTest {
@Test
@@ -26,7 +26,7 @@ import kotlin.test.assertTrue
* ugljesa.jovanovic@ionspin.com
* on 21-Sep-2019
*/
@ExperimentalUnsignedTypes
class AesCtrTest {
@Test
@@ -6,7 +6,7 @@ import kotlin.test.assertTrue
/**
* Created by Ugljesa Jovanovic (jovanovic.ugljesa@gmail.com) on 10/Sep/2019
*/
@ExperimentalUnsignedTypes
class AesTest {
val irrelevantKey = "01234567890123345678901234567890"
@@ -24,7 +24,7 @@ import kotlin.test.assertTrue
* ugljesa.jovanovic@ionspin.com
* on 17-Jul-2019
*/
@ExperimentalUnsignedTypes
class UtilTest {
@Test
@@ -25,7 +25,7 @@ import kotlin.browser.window
*/
actual object SRNG {
var counter = 0
@ExperimentalUnsignedTypes
actual fun getRandomBytes(amount: Int): UByteArray {
val runningOnNode = jsTypeOf(window) == "undefined"
val randomBytes = if (runningOnNode) {
@@ -24,7 +24,7 @@ import kotlin.test.assertTrue
* ugljesa.jovanovic@ionspin.com
* on 05-Jan-2020
*/
@ExperimentalUnsignedTypes
class SRNGJsTest {
@Test
@@ -23,7 +23,7 @@ import java.security.SecureRandom
* ugljesa.jovanovic@ionspin.com
* on 21-Sep-2019
*/
@ExperimentalUnsignedTypes
actual object SRNG {
val secureRandom = SecureRandom()
actual fun getRandomBytes(amount: Int): UByteArray {