Skip to content

Commit a487f1b

Browse files
committed
Add usage notes to notebooks.
1 parent 2ef118a commit a487f1b

File tree

2 files changed

+55
-39
lines changed

2 files changed

+55
-39
lines changed

jupyter/CW340_AES_test.ipynb

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
{
22
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Basic HW AES CPA attack.\n",
8+
"\n",
9+
"**IMPORTANT NOTES!**\n",
10+
"- **VCCIOB jumper (JP9)** must be in **top position (3.3V)**, which is different from the other test notebook;\n",
11+
"- **nPOR jumper (JP5)** must be in **bottom position (1-3)**."
12+
]
13+
},
314
{
415
"cell_type": "code",
516
"execution_count": null,
@@ -15,7 +26,6 @@
1526
"metadata": {},
1627
"outputs": [],
1728
"source": [
18-
"#bsfile = '../fpga/vivado/cw341.runs/impl_1/cw341_top.bit'\n",
1929
"bsfile = '../fpga/vivado/cw341.runs/impl_20pin/cw341_top.bit'"
2030
]
2131
},
@@ -72,14 +82,13 @@
7282
]
7383
},
7484
{
75-
"cell_type": "code",
76-
"execution_count": null,
85+
"attachments": {},
86+
"cell_type": "markdown",
7787
"metadata": {},
78-
"outputs": [],
7988
"source": [
80-
"scope.clock.adc_mul = 4\n",
81-
"scope.clock.clkgen_freq = 40e6\n",
82-
"scope.clock.clkgen_src = 'extclk'"
89+
"**Once the `husky_clock_fix` branch is merged** (i.e. issues [490](https://github.com/newaetech/chipwhisperer/issues/490), [499](https://github.com/newaetech/chipwhisperer/issues/501) and [501](https://github.com/newaetech/chipwhisperer/issues/501) are closed), 4x sampling works well, and `CLOCKS_FIXED` can be set to `True`.\n",
90+
"\n",
91+
"Otherwise, we crank up to 20x sampling (`CLOCKS_FIXED = False`) to better catch the leakage."
8392
]
8493
},
8594
{
@@ -88,29 +97,27 @@
8897
"metadata": {},
8998
"outputs": [],
9099
"source": [
100+
"CLOCKS_FIXED = False\n",
101+
"\n",
102+
"if CLOCKS_FIXED:\n",
103+
" scope.clock.adc_mul = 4\n",
104+
" scope.clock.clkgen_freq = 10e6\n",
105+
" scope.clock.clkgen_src = 'extclk'\n",
106+
" scope.clock.adc_phase = 15\n",
107+
" scope.adc.samples = 60\n",
108+
"else:\n",
109+
" scope.clock.adc_mul = 20\n",
110+
" scope.clock.clkgen_freq = 10e6\n",
111+
" scope.clock.clkgen_src = 'extclk'\n",
112+
" scope.clock.adc_phase = 0\n",
113+
" scope.adc.samples = 300\n",
114+
"\n",
115+
"scope.adc.presamples = 0\n",
116+
"scope.gain.db = 32\n",
117+
"\n",
91118
"assert scope.clock.adc_locked"
92119
]
93120
},
94-
{
95-
"cell_type": "code",
96-
"execution_count": null,
97-
"metadata": {},
98-
"outputs": [],
99-
"source": [
100-
"scope.adc.samples = 60\n",
101-
"scope.adc.presamples = 0"
102-
]
103-
},
104-
{
105-
"cell_type": "code",
106-
"execution_count": null,
107-
"metadata": {},
108-
"outputs": [],
109-
"source": [
110-
"# set gain accordingly:\n",
111-
"scope.gain.db = 40"
112-
]
113-
},
114121
{
115122
"cell_type": "code",
116123
"execution_count": null,
@@ -137,7 +144,7 @@
137144
"traces = []\n",
138145
"textin = []\n",
139146
"keys = []\n",
140-
"N = 5000 # Number of traces\n",
147+
"N = 10000 # Number of traces\n",
141148
"\n",
142149
"# initialize cipher to verify DUT result:\n",
143150
"key, text = ktp.next()\n",
@@ -223,7 +230,12 @@
223230
"metadata": {},
224231
"outputs": [],
225232
"source": [
226-
"np.average(attack_results.pge)"
233+
"avg_pge = np.average(attack_results.pge)\n",
234+
"if CLOCKS_FIXED:\n",
235+
" MAX_PGE = 10\n",
236+
"else:\n",
237+
" MAX_PGE = 50\n",
238+
"assert avg_pge < MAX_PGE, 'Average PGE is %d' % avg_pge"
227239
]
228240
},
229241
{
@@ -243,9 +255,9 @@
243255
],
244256
"metadata": {
245257
"kernelspec": {
246-
"display_name": "Python 3 (ipykernel)",
258+
"display_name": "Python (venv39)",
247259
"language": "python",
248-
"name": "python3"
260+
"name": "venv39"
249261
},
250262
"language_info": {
251263
"codemirror_mode": {

jupyter/CW340_test.ipynb

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
{
22
"cells": [
33
{
4-
"cell_type": "code",
5-
"execution_count": null,
4+
"cell_type": "markdown",
65
"metadata": {},
7-
"outputs": [],
86
"source": [
9-
"import chipwhisperer as cw"
7+
"# Basic tests.\n",
8+
"\n",
9+
"**IMPORTANT NOTES!**\n",
10+
"- **VCCIOB jumper (JP9)** must be in **middle position (1.8V)**, which is different from the AES test notebook;\n",
11+
"- **nPOR jumper (JP5)** must be in **bottom position (1-3)**."
1012
]
1113
},
1214
{
@@ -15,7 +17,7 @@
1517
"metadata": {},
1618
"outputs": [],
1719
"source": [
18-
"!pwd"
20+
"import chipwhisperer as cw"
1921
]
2022
},
2123
{
@@ -435,7 +437,9 @@
435437
"cell_type": "markdown",
436438
"metadata": {},
437439
"source": [
438-
"# Test Hyperrams:"
440+
"# Test Hyperrams:\n",
441+
"\n",
442+
"The hyperram controller is quite sensitive to the clock frequency. If the controller gets stuck, try a slightly different (higher or lower) frequency, e.g. 35 MHz or 45 MHz."
439443
]
440444
},
441445
{
@@ -630,9 +634,9 @@
630634
],
631635
"metadata": {
632636
"kernelspec": {
633-
"display_name": "Python 3 (ipykernel)",
637+
"display_name": "Python (venv39)",
634638
"language": "python",
635-
"name": "python3"
639+
"name": "venv39"
636640
},
637641
"language_info": {
638642
"codemirror_mode": {

0 commit comments

Comments
 (0)