package eu.friedcutlet.yokan.services.extensions.js import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNull import eu.friedcutlet.yokan.util.sha256 import eu.friedcutlet.yokan.util.sha1 class CryptoBridgeWasmTest { @Test fun hashesMatchStandardAbcVectors() { val input = "abc".encodeToByteArray() assertEquals( "a9993e364706816aba3e25717850c26c9cd0d89d", sha1(input).toHexString(), ) assertEquals( "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad", sha256(input).toHexString(), ) } // The browser only exposes AES through the async WebCrypto API, so the synchronous // bridge is deliberately unavailable here (CryptoBridge.wasm.kt). Callers rely on the // null return rather than a thrown error; the real vectors are covered in nonWebTest. @Test fun aesGcmIsUnsupported() { assertNull(aesGcmEncrypt(ByteArray(16), ByteArray(12), ByteArray(0))) assertNull(aesGcmDecrypt(ByteArray(16), ByteArray(12), ByteArray(32))) } }