Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pyproject #503

Merged
merged 14 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Setup Python 3.9
- name: Setup Python 3.10
uses: actions/setup-python@v1
with:
python-version: 3.9
python-version: 3.10.15
- name: Build ChipWhisperer
run: >-
python setup.py bdist
run: |
python -m pip install build
python -m build
- name: Publish to pypi
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/test_install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This is a basic workflow to help you get started with Actions

name: Build Firmware

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the develop branch
push:
paths:
- 'hardware/victims/firmware/**'
- 'hardware/capture'
- '.github/workflows/build_firmware.yml'

pull_request:
paths:
- 'hardware/victims/firmware/**'
- 'hardware/capture'
- '.github/workflows/build_firmware.yml'


# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
fwbuild:
# The type of runner that the job will run on
name: Build all firmware to make sure everything works
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Install compilers
run: >-
sudo apt install -y make build-essential gcc-avr avr-libc gcc-arm-none-eabi
- name: Build firmware
run: >-
cd tests && bash test_fw_build.sh
- name: Build capture firmware
run: |
cd hardware/capture/chipwhisperer-lite/sam3u_fw/SAM3U_VendorExample/src
git submodule update --init naeusb
make -j
cd -
cd hardware/capture/chipwhisperer-nano/firmware/cwnano-firmware/src
git submodule update --init naeusb
make -j

15 changes: 7 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,15 @@ docs/make.bat
*.vcd
*.fst
**/.vscode/*
**/*.bin
**/*.eep
**/*.elf
**/*.hex
**/*.lss
**/*.map
**/*.sym
firmware/**/*.bin
firmware/**/*.eep
firmware/**/*.elf
firmware/**/*.hex
firmware/**/*.lss
firmware/**/*.map
firmware/**/*.sym
*.o.s
**/1
**/version.txt

# Explicit listing of the build artifacts so that they are not included in
# commits
Expand Down
12 changes: 6 additions & 6 deletions firmware/mcu/basic-passwdcheck/basic-passwdcheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ int main(void)
my_puts("*****Safe-o-matic 3000 Booting...\n");
//Print some fancy-sounding stuff so that attackers
//will get scared and leave us alone
my_puts("Aligning bits........[DONE]\n");
delay_2_ms();
my_puts("Checking Cesium RNG..[DONE]\n");
delay_2_ms();
my_puts("Masquerading flash...[DONE]\n");
delay_2_ms();
// my_puts("Aligning bits........[DONE]\n");
// delay_2_ms();
// my_puts("Checking Cesium RNG..[DONE]\n");
// delay_2_ms();
// my_puts("Masquerading flash...[DONE]\n");
// delay_2_ms();
my_puts("Decrypting database..[DONE]\n");
delay_2_ms();
my_puts("\n\n");
Expand Down
18 changes: 18 additions & 0 deletions firmware/mcu/simpleserial-aes/pyocd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
probes:
TG1001d4:
frequency: 200000000
ftdi.channel: 1
ftdi.gpio_dir_mask: 0x0038
ftdi.gpio_init_mask: 0x003b
ftdi.srst_mask: 0x0020
ftdi.trst_mask: 0x0020
ftdi.swd_en_mask: 0

50203220325531583330313237323034:
ftdi.channel: 1
ftdi.gpio_dir_mask: 0x001B
ftdi.gpio_init_mask: 0x001B
ftdi.std_en_mask: 0x0100
ftdi.stdio_en_mask: 0x0200
#ftdi.gpio_dir_mask 0x003b
#ftdi.gpio_init_mask 0x0038
2 changes: 1 addition & 1 deletion jupyter
Submodule jupyter updated 94 files
+0 −187 archive/!!Introduction_to_Jupyter!!.ipynb
+0 −156 archive/!!Suggested_Completion_Order!!.ipynb
+0 −805 archive/Fault_1-Introduction_to_Clock_Glitch_Attacks.ipynb
+0 −623 archive/Fault_2-Introduction_to_Vcc_Glitch_Attacks.ipynb
+0 −708 archive/Fault_3-Glitch_Buffer_Attacks.ipynb
+0 −1,112 archive/Fault_4-AES_Differential_Fault_Analysis_Attacks.ipynb
+0 −817 archive/Fault_5-RSA_Fault_Attack.ipynb
+0 −572 archive/Fault_6-LPC1114_Fuse_Bypass.ipynb
+0 −411 archive/Helper_Scripts/AES_differential_plotter.ipynb
+0 −66 archive/Helper_Scripts/Serial_Console.ipynb
+0 −67 archive/Helper_Scripts/Setup_CW308_87C51.ipynb
+0 −74 archive/Helper_Scripts/Setup_CW308_CEC1702.ipynb
+0 −73 archive/Helper_Scripts/Setup_CW308_D2000.ipynb
+0 −79 archive/Helper_Scripts/Setup_CW308_ESP32.ipynb
+0 −51 archive/Helper_Scripts/Setup_CW308_MPC5748G.ipynb
+0 −85 archive/Helper_Scripts/Setup_Generic.ipynb
+0 −47 archive/Helper_Scripts/Setup_Notduino.ipynb
+0 −21 archive/Helper_Scripts/Test_Run.ipynb
+0 −50 archive/Helper_Scripts/plot.ipynb
+0 −435 archive/Helpful_Code_Blocks.ipynb
+0 −792 archive/PA_CPA_1-Using_CW-Analyzer_for_CPA_Attack.ipynb
+0 −645 archive/PA_CPA_2-Manual_CPA_Attack.ipynb
+0 −515 archive/PA_CPA_3-Resynchronizing_Data_Traces.ipynb
+0 −493 archive/PA_CPA_4-Hardware_Crypto_Attack.ipynb
+0 −362 archive/PA_CPA_5-32bit_AES.ipynb
+0 −563 archive/PA_DPA_1-Hamming_Weight_Measurement.ipynb
+0 −310 archive/PA_DPA_2-Large_HW_Swings.ipynb
+0 −547 archive/PA_DPA_3-AES_DPA_Attack.ipynb
+0 −377 archive/PA_HW_CW305_1-Attacking_AES_on_an_FPGA.ipynb
+0 −574 archive/PA_HW_Pro_1-Attacking_AES_Without_A_Trigger.ipynb
+0 −498 archive/PA_Intro_1-Firmware_Build_Setup.ipynb
+0 −494 archive/PA_Intro_2-Instruction_Differences.ipynb
+0 −439 archive/PA_Intro_3-Measuring_SNR_of_Target.ipynb
+0 −1,800 archive/PA_Multi_1-Breaking_AES-256_Bootloader.ipynb
+0 −1,065 archive/PA_Profiling_1-Template_Attacks_HW_Assumption.ipynb
+0 −772 archive/PA_SPA_1-Timing_Analysis_with_Power_for_Password_Bypass.ipynb
+0 −35 archive/PA_SPA_1_answers.py
+0 −547 archive/PA_SPA_2-RSA_on_XMEGA_8bit.ipynb
+0 −315 archive/PA_TVLA_1-Performing_TVLA_Testing_for_Crypto_Validation.ipynb
+0 −17 archive/README.md
+0 −0 archive/external/__init__.py
+ archive/external/lpc1114_first4096.bin
+0 −1,105 archive/external/nxpprog.py
+ archive/img/A9_LPC1114_CHANGES.jpg
+ archive/img/A9_LPC_CWLITE_Conn.jpg
+ archive/img/Sbox_cpa_detail.png
+ archive/img/aes_operations.png
+ archive/img/clock_glitches.png
+ archive/img/dpa_4bits_powerhw.png
+ archive/img/dpa_4bits_powerhw_scaled.png
+ archive/img/resync_goodbad.png
+ archive/img/vmeasure.png
+0 −18 archive/requirements.txt
+3 −3 courses/sca101/Lab 2_1A - Instruction Power Differences (SIMULATED).ipynb
+4 −3 courses/sca101/Lab 2_1B - Power Analysis for Password Bypass (SIMULATED).ipynb
+8 −8 courses/sca101/Lab 3_1 - Large Hamming Weight Swings (SIMULATED).ipynb
+8 −9 courses/sca101/Lab 3_3 - DPA on Firmware Implementation of AES (SIMULATED).ipynb
+7 −10 courses/sca101/Lab 4_1 - Power and Hamming Weight Relationship (SIMULATED).ipynb
+6 −9 courses/sca101/Lab 4_2 - CPA on Firmware Implementation of AES (SIMULATED).ipynb
+7 −4 courses/sca101/Lab 4_3 - ChipWhisperer Analyzer CPA Attack (SIMULATED).ipynb
+7 −7 courses/sca101/SOLN_Lab 2_1B - Power Analysis for Password Bypass.ipynb
+5 −10 courses/sca101/SOLN_Lab 3_1 - Large Hamming Weight Swings.ipynb
+3 −3 courses/sca101/SOLN_Lab 3_2 - Recovering Data from a Single Bit.ipynb
+9 −3 courses/sca101/SOLN_Lab 3_3 - DPA on Firmware Implementation of AES.ipynb
+6 −11 courses/sca101/SOLN_Lab 4_1 - Power and Hamming Weight Relationship.ipynb
+4 −3 courses/sca101/SOLN_Lab 4_2 - CPA on Firmware Implementation of AES.ipynb
+13 −1,869 courses/sca101/generators/Lab3_3 - GENERATOR.ipynb
+13 −1,840 courses/sca101/generators/Lab4_1 - GENERATOR.ipynb
+13 −1,821 courses/sca101/generators/Lab4_2 - GENERATOR.ipynb
+12 −1,869 courses/sca101/generators/Lab4_3 - GENERATOR.ipynb
+0 −10 courses/sca101/traces/Lab_4_3.cwp
+ courses/sca101/traces/Lab_4_3_data/traces/2020.06.05-20.35.52_0keylist.npy
+ courses/sca101/traces/Lab_4_3_data/traces/2020.06.05-20.35.52_0knownkey.npy
+ courses/sca101/traces/Lab_4_3_data/traces/2020.06.05-20.35.52_0textin.npy
+ courses/sca101/traces/Lab_4_3_data/traces/2020.06.05-20.35.52_0textout.npy
+ courses/sca101/traces/Lab_4_3_data/traces/2020.06.05-20.35.52_0traces.npy
+0 −13 courses/sca101/traces/Lab_4_3_data/traces/config_2020.06.05-20.35.52_0.cfg
+0 −40 courses/sca101/traces/aes_2500traces_random.ipynb
+ courses/sca101/traces/lab2_1A_trace0.npy
+ courses/sca101/traces/lab2_1A_trace1.npy
+ courses/sca101/traces/lab2_1A_trace2.npy
+ courses/sca101/traces/lab2_1A_trace3.npy
+ courses/sca101/traces/lab2_1b_passwords_full.p
+ courses/sca101/traces/lab3_1_textin.npy
+ courses/sca101/traces/lab3_1_traces.npy
+ courses/sca101/traces/lab3_3_textin.npy
+ courses/sca101/traces/lab3_3_traces.npy
+ courses/sca101/traces/lab4_1_key.npy
+ courses/sca101/traces/lab4_1_textin.npy
+ courses/sca101/traces/lab4_1_traces.npy
+ courses/sca101/traces/lab4_2_key.npy
+ courses/sca101/traces/lab4_2_textin.npy
+ courses/sca101/traces/lab4_2_traces.npy
+0 −68 courses/sca101/traces/password_sim.ipynb
Binary file added openocd/cwhusky_top.bit
Binary file not shown.
56 changes: 56 additions & 0 deletions openocd/lpc.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# SPDX-License-Identifier: GPL-2.0-or-later
source [find target/swj-dp.tcl]
adapter speed 1000
if { [info exists CHIPNAME] } {
set _CHIPNAME $CHIPNAME
} else {
set _CHIPNAME lpc55xx
}
if { [info exists CPUTAPID] } {
set _CPUTAPID $CPUTAPID
} else {
# Cortex-M33 SWD DPIDR
set _CPUTAPID 0x6ba02477
}
swj_newdap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME cortex_m -endian little -dap $_CHIPNAME.dap
# Reserved RAM regions for ROM functions
# 0x14000000 -- 0x14003fff
# 0x30001000 -- 0x30007fff
#
# Use 16 KiB of SRAM2 (on LPC553x) for working area
if { [info exists WORKAREASIZE] } {
set _WORKAREASIZE $WORKAREASIZE
} else {
set _WORKAREASIZE 0x4000
}
$_TARGETNAME configure -work-area-phys 0x20008000 \
-work-area-size $_WORKAREASIZE -work-area-backup 0
if { [info exists FLASH_API_ADDRESS] } {
set _FLASH_API_ADDRESS $FLASH_API_ADDRESS
} else {
set _FLASH_API_ADDRESS 0
}
# Using SRST is not recommended as that also resets the debug domain
if {![using_hla]} {
cortex_m reset_config sysresetreq
}
proc init_reset { mode } {
if { $mode ne "run" } {
halt
wp 0x50000040 4 r
resume
}
}
$_TARGETNAME configure -event reset-end { catch { rwp 0x50000040 } }
# Run this to initiate a debug session with a target that doesn't have
# valid firmware on flash
proc lpc55xx_start_debug_session { } {
global _CHIPNAME
$_CHIPNAME.dap apreg 2 0 0x21
$_CHIPNAME.dap apreg 2 4 7
$_CHIPNAME.cpu arp_examine
}
flash bank $_TARGETNAME.flash lpc55xx 0x00000000 0 0 0 0 $_FLASH_API_ADDRESS
41 changes: 41 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[build-system]
requires = ["setuptools >= 61.0", "setuptools_scm>=8"]
build-backend = "setuptools.build_meta"

[project]
#version = "0.0.1" # Remove any existing version parameter.
dynamic = ["version"]
description="ChipWhisperer Side-Channel Analysis Tool"
name = "chipwhisperer"
authors=[{name="Colin O'Flynn", email="[email protected]"}]
requires-python = ">=3.9"
dependencies = [
"configobj",
"pyserial",
"numpy",
"libusb1",
"ECpy",
"fastdtw",
"Cython",
"tqdm",
"libusb1",
]
license = {file = "LICENSE.txt"}
readme = "README.md"

[project.optional-dependencies]
trace = ["software"]

[project.urls]
Homepage = "https://www.chipwhisperer.com"
Documentation = "https://chipwhisperer.readthedocs.io/en/latest/"
Repository = "https://github.com/newaetech/chipwhisperer"

[tool.setuptools]
include-package-data = true

[tool.setuptools.packages.find]
where = ["software"]

[tool.setuptools.dynamic]
version = {attr = "chipwhisperer.__version__"}
37 changes: 0 additions & 37 deletions setup.py

This file was deleted.

2 changes: 1 addition & 1 deletion software/chipwhisperer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Main module for ChipWhisperer.
"""
from .version import __version__
__version__ = '5.7.0'

try:
import usb1 # type: ignore
Expand Down
16 changes: 8 additions & 8 deletions software/chipwhisperer/capture/scopes/OpenADC.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def _getFWPy(self):
from ...hardware.firmware.cwlite import fwver
elif cw_type == "cw1200":
from ...hardware.firmware.cw1200 import fwver # type: ignore
elif cw_type in ["cwhusky", "cwhusky-plus"]:
elif cw_type in ["cwhusky", "cwhuskyplus"]:
from ...hardware.firmware.cwhusky import fwver # type: ignore
else:
raise ValueError('Unknown cw_type: %s' % cw_type)
Expand Down Expand Up @@ -419,7 +419,7 @@ def _getCWType(self) -> str:
elif "CW1200" in hwInfoVer:
return "cw1200"
elif "Husky-Plus" in hwInfoVer:
return "cwhusky-plus"
return "cwhuskyplus"
elif "Husky" in hwInfoVer:
return "cwhusky"
else:
Expand All @@ -440,7 +440,7 @@ def get_name(self):
return "ChipWhisperer Pro"
elif name == "cwhusky":
return "ChipWhisperer Husky"
elif name == "cwhusky-plus":
elif name == "cwhuskyplus":
return "ChipWhisperer Husky Plus"

def adc_test(self, samples=131070, reps=3, verbose=False):
Expand Down Expand Up @@ -659,7 +659,7 @@ def con(self, sn=None, idProduct=None, bitstream=None, force=False, prog_speed=1
self.sc = OpenADCInterface(self.scopetype.ser, self.scopetype.registers) # important to instantiate this before other FPGA components, since this does an FPGA reset
self.hwinfo = HWInformation(self.sc)
cwtype = self._getCWType()
if cwtype in ["cwhusky", "cwhusky-plus"]:
if cwtype in ["cwhusky", "cwhuskyplus"]:
self.sc._is_husky = True
self.sc._setReset(True)
self.sc._setReset(False)
Expand All @@ -683,7 +683,7 @@ def con(self, sn=None, idProduct=None, bitstream=None, force=False, prog_speed=1
self.SAD = ChipWhispererSAD.ChipWhispererSAD(self.sc)
self.decode_IO = ChipWhispererDecodeTrigger.ChipWhispererDecodeTrigger(self.sc)

if cwtype in ["cwhusky", "cwhusky-plus"]:
if cwtype in ["cwhusky", "cwhuskyplus"]:
# self.pll = ChipWhispererHuskyClock.CDCI6214(self.sc)
self._fpga_clk = ClockSettings(self.sc, hwinfo=self.hwinfo, is_husky=True)
self.glitch_drp1 = XilinxDRP(self.sc, "CG1_DRP_DATA", "CG1_DRP_ADDR", "CG1_DRP_RESET")
Expand Down Expand Up @@ -715,7 +715,7 @@ def con(self, sn=None, idProduct=None, bitstream=None, force=False, prog_speed=1
self._fpga_clk._is_husky = True
self.sc._is_husky = True
self.adc.bits_per_sample = 12
if cwtype == "cwhusky-plus":
if cwtype == "cwhuskyplus":
self._is_husky_plus = True
self.LA._is_husky_plus = True
else:
Expand All @@ -730,7 +730,7 @@ def con(self, sn=None, idProduct=None, bitstream=None, force=False, prog_speed=1
self.io = self.advancedSettings.cwEXTRA.gpiomux
self.trigger = self.advancedSettings.cwEXTRA.triggermux
self.glitch = self.advancedSettings.glitch.glitchSettings
if cwtype in ['cwhusky', 'cwhusky-plus']:
if cwtype in ['cwhusky', 'cwhuskyplus']:
# TODO: cleaner way to do this?
self.glitch.pll = self.clock.pll
self.clock.pll._glitch = self.glitch
Expand All @@ -739,7 +739,7 @@ def con(self, sn=None, idProduct=None, bitstream=None, force=False, prog_speed=1
if cwtype == "cw1200":
self.trigger = self.advancedSettings.cwEXTRA.protrigger

if cwtype in ["cwhusky", "cwhusky-plus"]:
if cwtype in ["cwhusky", "cwhuskyplus"]:
# these are the power-up defaults, but just in case e.g. test script left these on:
self.adc.test_mode = False
self.ADS4128.mode = 'normal'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def __init__(self, oa, cwtype):
hasPLL=False
hasAux=True
hasUserio=False
elif cwtype in ["cwhusky", "cwhusky-plus"]:
elif cwtype in ["cwhusky", "cwhuskyplus"]:
hasFPAFPB=False
hasGlitchOut=True
hasPLL=False
Expand All @@ -188,7 +188,7 @@ def __init__(self, oa, cwtype):
self.protrigger = ProTrigger(self)
self.huskytrigger = HuskyTrigger(self)

if cwtype in ["cwhusky", "cwhusky-plus"]:
if cwtype in ["cwhusky", "cwhuskyplus"]:
self.gpiomux._is_husky = True
self.triggermux._is_husky = True
self._addr_trigsrc_size = 2
Expand Down
Loading
Loading