Yokan / rebuild
Course 1 8624561

CryptoBridgeWasmTest.kt

composeApp/src/wasmJsTest/kotlin/eu/friedcutlet/yokan/services/extensions/js/CryptoBridgeWasmTest.kt

test / fixture32 lines
1package eu.friedcutlet.yokan.services.extensions.js23import kotlin.test.Test4import kotlin.test.assertEquals5import kotlin.test.assertNull6import eu.friedcutlet.yokan.util.sha2567import eu.friedcutlet.yokan.util.sha189class CryptoBridgeWasmTest {10    @Test11    fun hashesMatchStandardAbcVectors() {12        val input = "abc".encodeToByteArray()1314        assertEquals(15            "a9993e364706816aba3e25717850c26c9cd0d89d",16            sha1(input).toHexString(),17        )18        assertEquals(19            "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",20            sha256(input).toHexString(),21        )22    }2324    // The browser only exposes AES through the async WebCrypto API, so the synchronous25    // bridge is deliberately unavailable here (CryptoBridge.wasm.kt). Callers rely on the26    // null return rather than a thrown error; the real vectors are covered in nonWebTest.27    @Test28    fun aesGcmIsUnsupported() {29        assertNull(aesGcmEncrypt(ByteArray(16), ByteArray(12), ByteArray(0)))30        assertNull(aesGcmDecrypt(ByteArray(16), ByteArray(12), ByteArray(32)))31    }32}33

Search chapters, reference and source filenames.