SPAKE2/SPAKE2+ password-authenticated key exchange for OCaml
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

test(crypto): expand test suites for pbkdf, spake2, srp

+29
+29
test/test_spake2.ml
··· 36 36 Alcotest.(check int) "N encoded length" 65 (String.length encoded); 37 37 Alcotest.(check char) "N uncompressed prefix" '\x04' encoded.[0] 38 38 39 + (* RFC 9382 Section 4 test: verify M and N point constants match the RFC values 40 + for P-256 (secp256r1). 41 + 42 + M = 43 + x: 886e2f97ace46e55ba9dd7242579f2993b64e16ef3dcab95afd497333d8fa12f 44 + y: 5ff355163e43ce224e0b0e65ff02ac8e5c7be09419c785e0ca547d55a12e2d20 45 + 46 + N = 47 + x: d8bbd6c639c62937b04d997f38c3770719c629d7014d49a24b4f98baa1292b49 48 + y: 07d60aa6bfade45008a636337f5168c64d9bd36034808cd564490b1e656edbe7 *) 49 + 50 + let test_p256_m_rfc9382 () = 51 + let encoded = Spake2.P256.to_bytes Spake2.P256.m in 52 + let hex = Ohex.encode encoded in 53 + let expected = 54 + "04886e2f97ace46e55ba9dd7242579f2993b64e16ef3dcab95afd497333d8fa12f5ff355163e43ce224e0b0e65ff02ac8e5c7be09419c785e0ca547d55a12e2d20" 55 + in 56 + Alcotest.(check string) "M matches RFC 9382" expected hex 57 + 58 + let test_p256_n_rfc9382 () = 59 + let encoded = Spake2.P256.to_bytes Spake2.P256.n in 60 + let hex = Ohex.encode encoded in 61 + let expected = 62 + "04d8bbd6c639c62937b04d997f38c3770719c629d7014d49a24b4f98baa1292b4907d60aa6bfade45008a636337f5168c64d9bd36034808cd564490b1e656edbe7" 63 + in 64 + Alcotest.(check string) "N matches RFC 9382" expected hex 65 + 39 66 (* SPAKE2 protocol tests *) 40 67 41 68 let test_spake2_basic () = ··· 193 220 Alcotest.test_case "negate" `Quick test_p256_negate; 194 221 Alcotest.test_case "M encoding" `Quick test_p256_m_encoding; 195 222 Alcotest.test_case "N encoding" `Quick test_p256_n_encoding; 223 + Alcotest.test_case "M matches RFC 9382" `Quick test_p256_m_rfc9382; 224 + Alcotest.test_case "N matches RFC 9382" `Quick test_p256_n_rfc9382; 196 225 ] ); 197 226 ( "SPAKE2", 198 227 [