diff options
Diffstat (limited to 'analysis/countermeasures/results.ipynb')
| -rw-r--r-- | analysis/countermeasures/results.ipynb | 365 |
1 files changed, 365 insertions, 0 deletions
diff --git a/analysis/countermeasures/results.ipynb b/analysis/countermeasures/results.ipynb new file mode 100644 index 0000000..7c81feb --- /dev/null +++ b/analysis/countermeasures/results.ipynb @@ -0,0 +1,365 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "e3313aa9-5cc6-47ff-8db0-b4419e1afb4d", + "metadata": {}, + "outputs": [], + "source": [ + "from test_eval import Test3n, Testinverse, Testk10, TestEpsilon_GSR, TestEpsilon_Multiplicative" + ] + }, + { + "cell_type": "markdown", + "id": "15ac247f", + "metadata": {}, + "source": [ + "## Test results\n", + "\n", + "[Test 3n](#Test-3n)\n", + "\n", + "[Test composite](#Test-composite-(inverse))\n", + "\n", + "[Test k=10](#Test-k=10)\n", + "\n", + "[Test n+epsilon GSR](#Test-n+epsilon-GSR)\n", + "\n", + "[Test n+epsilon Multiplicative](#Test-n+epsilon-Multiplicative)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "aeb9bd2b", + "metadata": {}, + "outputs": [], + "source": [ + "cards = ['A1','F1','F2','G1','I1','I2','N1','N10','N2','N3','N4','N5','N6','N7','N8','N9','S1','S2']" + ] + }, + { + "cell_type": "markdown", + "id": "7a53b79a", + "metadata": {}, + "source": [ + "## Test 3n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "75a7366e", + "metadata": {}, + "outputs": [], + "source": [ + "curve_path = \"tests/test3n/curve.csv\"\n", + "point_path = \"tests/test3n/point_3n.csv\"\n", + "test3n = Test3n(curve_path,point_path)\n", + "test3n.existing_measurements(cards,\"ecdh\")\n", + "test3n.existing_measurements(cards,\"ecdsa\")\n", + "test3n.existing_measurements(cards,\"keygen\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "495f4854", + "metadata": {}, + "outputs": [], + "source": [ + "test3n.print_ecdh(\"N1\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "706ef56e", + "metadata": {}, + "outputs": [], + "source": [ + "test3n.print_keygen(\"N1\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7e007ee6-cb16-40e4-9217-7e0d08047a7a", + "metadata": {}, + "outputs": [], + "source": [ + "test3n.print_ecdsa(\"N1\")" + ] + }, + { + "cell_type": "markdown", + "id": "c0cad787", + "metadata": {}, + "source": [ + "## Test composite (inverse)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c7c5f56e", + "metadata": {}, + "outputs": [], + "source": [ + "curve_path = \"tests/testinverse/cofactor256p11_full.csv\"\n", + "point_path = \"tests/testinverse/point_11n.csv\"\n", + "testinverse = Testinverse(curve_path, point_path, 11)\n", + "testinverse.existing_measurements(cards,\"ecdh\")\n", + "testinverse.existing_measurements(cards,\"ecdsa\")\n", + "testinverse.existing_measurements(cards,\"keygen\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8397c88e", + "metadata": {}, + "outputs": [], + "source": [ + "testinverse.print_ecdh(\"N1\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "405df6fc", + "metadata": {}, + "outputs": [], + "source": [ + "# For some cards, multiple measurements were done (e.g., with fixed private key)\n", + "# There is an optional prefix argument to process only files with the specified prefix.\n", + "\n", + "testinverse.print_ecdsa(\"N1\",\"ecdsa_fixed_11\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2bc5803b", + "metadata": {}, + "outputs": [], + "source": [ + "testinverse.print_keygen(\"N1\")" + ] + }, + { + "cell_type": "markdown", + "id": "7a39d841", + "metadata": {}, + "source": [ + "## Test k=10" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b749a7d0", + "metadata": {}, + "outputs": [], + "source": [ + "# The test only makes sense for ecdh" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b197e324", + "metadata": {}, + "outputs": [], + "source": [ + "curve_path = \"tests/testk10/secp256r1.csv\"\n", + "point_path = \"tests/testk10/secgpoint.csv\"\n", + "testk10 = Testk10(curve_path, point_path, 10)\n", + "testk10.existing_measurements(cards,\"ecdh\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "92616fc3", + "metadata": {}, + "outputs": [], + "source": [ + "testk10.print_ecdh(\"N1\")" + ] + }, + { + "cell_type": "markdown", + "id": "741ae1f0-b943-4421-b936-30ae8ddaa1be", + "metadata": {}, + "source": [ + "## Test n+epsilon GSR" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "66833471", + "metadata": {}, + "outputs": [], + "source": [ + "# The test makes sense only for implementations of GSR (or BT bit-length fixing) \n", + "# that permit input parameters, including\n", + "\n", + "# ecdh: N6, N8, I1\n", + "# ecdsa: N1, N2, N6, N8, N9, I2\n", + "# keygen: N1, N2, N6, N9, I2" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "eb2b8923-5977-4d73-b127-b2773bdde91e", + "metadata": {}, + "outputs": [], + "source": [ + "curve_path = \"tests/testdn/weakcurve_32_n_1.csv\"\n", + "point_path = \"tests/testdn/weakcurve_32_n_1_point.csv\"\n", + "realn_path = \"tests/testdn/realn.csv\"\n", + "\n", + "testepsilon = TestEpsilon_GSR(curve_path,point_path,realn_path)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "40dceab4", + "metadata": {}, + "outputs": [], + "source": [ + "testepsilon.recover_ecdsa(\"N1\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fa3ecd8d", + "metadata": {}, + "outputs": [], + "source": [ + "testepsilon.recover_keygen(\"N1\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "adba1ff5-4235-4084-b1dd-ab206903bb24", + "metadata": {}, + "outputs": [], + "source": [ + "# N8 and I1 needed different parameters for ecdh\n", + "\n", + "curve_path = \"tests/testdn/weakcurve_32_n_good_gen.csv\"\n", + "point_path = \"tests/testdn/weakcurve_32_n_1_point.csv\"\n", + "realn_path = \"tests/testdn/realn.csv\"\n", + "\n", + "testepsilon = TestEpsilon_GSR(curve_path,point_path,realn_path)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "609ee23f", + "metadata": {}, + "outputs": [], + "source": [ + "testepsilon.recover_ecdh_plain(\"N8\")" + ] + }, + { + "cell_type": "markdown", + "id": "c4395ea6", + "metadata": {}, + "source": [ + "## Test n+epsilon Multiplicative" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "312885ab", + "metadata": {}, + "outputs": [], + "source": [ + "# The test makes sense only for implementations of GSR (or BT bit-length fixing) \n", + "# that permit input parameters, including\n", + "\n", + "# ecdh: N10\n", + "# ecdsa: N10 - strange behaviour, does not work " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "bab76405", + "metadata": {}, + "outputs": [], + "source": [ + "curve_path = \"tests/testdn/weakcurve_32_n_1.csv\"\n", + "point_path = \"tests/testdn/weakcurve_32_n_1_point.csv\"\n", + "realn_path = \"tests/testdn/realn.csv\"\n", + "\n", + "testepsilon = TestEpsilon_Multiplicative(curve_path,point_path,realn_path)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "76362134", + "metadata": {}, + "outputs": [], + "source": [ + "# At first, we can approximate the bitsizes of the used masks\n", + "testepsilon.recover_ecdh_plain_size(\"N10\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4c9d9898", + "metadata": {}, + "outputs": [], + "source": [ + "# Second, we list the number of candidates with bitsizes in the specified range\n", + "testepsilon.compute_candidates(61,65)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "66de5424", + "metadata": {}, + "outputs": [], + "source": [ + "# does not work\n", + "# testepsilon.recover_ecdsa_size(\"N10\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "env", + "language": "python", + "name": "env" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.12" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} |
