From e6394385850999564e19ca091e417788a4b7a1aa Mon Sep 17 00:00:00 2001 From: J08nY Date: Tue, 16 Sep 2025 18:29:09 +0800 Subject: More docs wrt cards in artifact. --- analysis/countermeasures/collect_leia.ipynb | 9 ++- analysis/countermeasures/measure.ipynb | 15 +++- analysis/countermeasures/results.ipynb | 117 ++++++++++++++++++---------- 3 files changed, 96 insertions(+), 45 deletions(-) diff --git a/analysis/countermeasures/collect_leia.ipynb b/analysis/countermeasures/collect_leia.ipynb index 5cdbd51..bad6376 100644 --- a/analysis/countermeasures/collect_leia.ipynb +++ b/analysis/countermeasures/collect_leia.ipynb @@ -74,7 +74,12 @@ "metadata": {}, "source": [ "## Initialize scope and card\n", - "Connect to the card and setup the scope/measurement parameters based on it." + "Connect to the card and setup the scope/measurement parameters based on it.\n", + "\n", + "Note that several smartcards really are the same model and thus we merged them:\n", + " - N4 = N5 = N10\n", + " - N6 = N7\n", + " - N3 = N8" ] }, { @@ -838,7 +843,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.13.5" + "version": "3.13.7" } }, "nbformat": 4, diff --git a/analysis/countermeasures/measure.ipynb b/analysis/countermeasures/measure.ipynb index 2e963f1..99b208e 100644 --- a/analysis/countermeasures/measure.ipynb +++ b/analysis/countermeasures/measure.ipynb @@ -70,6 +70,19 @@ "target.select_applet()" ] }, + { + "cell_type": "markdown", + "id": "abebcd10-a405-4622-84d0-b96414c78b34", + "metadata": {}, + "source": [ + "Select a card below, it should correspond to the one you have inserted into the reader. If you are testing a new card, add its ATR to the map below.\n", + "\n", + "Note that several smartcards really are the same model and thus we merged them:\n", + " - N4 = N5 = N10\n", + " - N6 = N7\n", + " - N3 = N8" + ] + }, { "cell_type": "code", "execution_count": null, @@ -1599,7 +1612,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.13.5" + "version": "3.13.7" } }, "nbformat": 4, diff --git a/analysis/countermeasures/results.ipynb b/analysis/countermeasures/results.ipynb index 7c81feb..81ed21a 100644 --- a/analysis/countermeasures/results.ipynb +++ b/analysis/countermeasures/results.ipynb @@ -1,15 +1,5 @@ { "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", @@ -17,6 +7,8 @@ "source": [ "## Test results\n", "\n", + "This notebook takes in the raw results created by the [measure.ipynb](measure.ipynb) notebook and evaluates them.\n", + "\n", "[Test 3n](#Test-3n)\n", "\n", "[Test composite](#Test-composite-(inverse))\n", @@ -28,6 +20,16 @@ "[Test n+epsilon Multiplicative](#Test-n+epsilon-Multiplicative)" ] }, + { + "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": "code", "execution_count": null, @@ -38,6 +40,19 @@ "cards = ['A1','F1','F2','G1','I1','I2','N1','N10','N2','N3','N4','N5','N6','N7','N8','N9','S1','S2']" ] }, + { + "cell_type": "markdown", + "id": "6e544e0f-1249-41b8-87bd-69d8c3e90c0f", + "metadata": {}, + "source": [ + "For each test evaluation call below you can choose one of the cards above.\n", + "\n", + "Note that several smartcards really are the same model and thus we merge them:\n", + " - N4 = N5 = N10\n", + " - N6 = N7\n", + " - N3 = N8" + ] + }, { "cell_type": "markdown", "id": "7a53b79a", @@ -124,6 +139,15 @@ "testinverse.print_ecdh(\"N1\")" ] }, + { + "cell_type": "markdown", + "id": "182766b2-aa74-47ea-9d21-3988604c3b6b", + "metadata": {}, + "source": [ + "For some cards, multiple measurements were done (e.g., with a fixed private key).\n", + "There is an optional prefix argument to process only files with the specified prefix." + ] + }, { "cell_type": "code", "execution_count": null, @@ -131,9 +155,6 @@ "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\")" ] }, @@ -156,13 +177,11 @@ ] }, { - "cell_type": "code", - "execution_count": null, - "id": "b749a7d0", + "cell_type": "markdown", + "id": "c9d7bb23-b5f3-430f-ad08-cccfb272eede", "metadata": {}, - "outputs": [], "source": [ - "# The test only makes sense for ecdh" + "The test only makes sense for ECDH." ] }, { @@ -197,18 +216,15 @@ ] }, { - "cell_type": "code", - "execution_count": null, - "id": "66833471", + "cell_type": "markdown", + "id": "2b6474c2-0015-45bb-8a08-503d21662662", "metadata": {}, - "outputs": [], "source": [ - "# The test makes sense only for implementations of GSR (or BT bit-length fixing) \n", - "# that permit input parameters, including\n", + "The test makes sense only for implementations of GSR (or BT bit-length fixing) 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" + "- ECDH: N6, N8, I1\n", + "- ECDSA: N1, N2, N6, N8, N9, I2\n", + "- Keygen: N1, N2, N6, N9, I2" ] }, { @@ -245,6 +261,14 @@ "testepsilon.recover_keygen(\"N1\")" ] }, + { + "cell_type": "markdown", + "id": "444caf43-4f62-4db6-aa67-d8f79f608ce7", + "metadata": {}, + "source": [ + "N8 and I1 needed different parameters for ECDH." + ] + }, { "cell_type": "code", "execution_count": null, @@ -252,8 +276,6 @@ "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", @@ -280,17 +302,14 @@ ] }, { - "cell_type": "code", - "execution_count": null, - "id": "312885ab", + "cell_type": "markdown", + "id": "67afdd25-f8b6-47d0-bdd4-e128e5e5724d", "metadata": {}, - "outputs": [], "source": [ - "# The test makes sense only for implementations of GSR (or BT bit-length fixing) \n", - "# that permit input parameters, including\n", + "The test makes sense only for implementations of GSR (or BT bit-length fixing) that permit input parameters, including:\n", "\n", - "# ecdh: N10\n", - "# ecdsa: N10 - strange behaviour, does not work " + " - ECDH: N10\n", + " - ECDSA: N10 - strange behaviour, does not work " ] }, { @@ -307,6 +326,14 @@ "testepsilon = TestEpsilon_Multiplicative(curve_path,point_path,realn_path)" ] }, + { + "cell_type": "markdown", + "id": "65bddf04-3572-4a2b-a459-037222d05e87", + "metadata": {}, + "source": [ + "First, we can approximate the bitsizes of the used masks:" + ] + }, { "cell_type": "code", "execution_count": null, @@ -314,10 +341,17 @@ "metadata": {}, "outputs": [], "source": [ - "# At first, we can approximate the bitsizes of the used masks\n", "testepsilon.recover_ecdh_plain_size(\"N10\")" ] }, + { + "cell_type": "markdown", + "id": "6bdcb776-dbac-4314-b302-270b2f1e4710", + "metadata": {}, + "source": [ + "Second, we list the number of candidates with bitsizes in the specified range:" + ] + }, { "cell_type": "code", "execution_count": null, @@ -325,7 +359,6 @@ "metadata": {}, "outputs": [], "source": [ - "# Second, we list the number of candidates with bitsizes in the specified range\n", "testepsilon.compute_candidates(61,65)" ] }, @@ -343,9 +376,9 @@ ], "metadata": { "kernelspec": { - "display_name": "env", + "display_name": "Python 3 (ipykernel)", "language": "python", - "name": "env" + "name": "python3" }, "language_info": { "codemirror_mode": { @@ -357,7 +390,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.13.7" } }, "nbformat": 4, -- cgit v1.2.3-70-g09d2