Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
bc12015
Use 4-way key shares for AES private keys
will-v-pi Jan 14, 2025
78f27fb
Remove check that ELF segments are between metadata blocks
will-v-pi Jan 15, 2025
d1088ff
Fix overlapping memory ranges issue for encrypted binaries
will-v-pi Jan 15, 2025
a65daa7
Update share as word-wise
will-v-pi Jan 20, 2025
4eac457
Add enc_bootloader binary
will-v-pi Jan 20, 2025
76baca1
Apply encrypted-example 6de8084b6eda
will-v-pi Jan 20, 2025
cc6fbab
Fixup no libusb build
will-v-pi Jan 20, 2025
0d81600
Remove debug prints, and add USE_USB_DPRAM option
will-v-pi Jan 20, 2025
d0dd100
Reduce binary size
will-v-pi Jan 20, 2025
5596923
Remove pico_rand and use boot random instead
will-v-pi Jan 21, 2025
0dc6c62
Update precompiled enc_bootloader.elf
will-v-pi Jan 21, 2025
83de3e3
Remove unused use_usb_dpram
will-v-pi Jan 21, 2025
a605be7
Re-jig to create more space for the AES code
will-v-pi Jan 21, 2025
cff9a9e
Integrate new aes.S
will-v-pi Jan 22, 2025
d04d513
Use minimal vector table
will-v-pi Jan 22, 2025
d2c8419
Pass TBYB and version from encrypted binary metadata to the decryptio…
will-v-pi Jan 22, 2025
af31a00
Add --otp-key-page argument
will-v-pi Jan 23, 2025
6e62875
Update aes.S
will-v-pi Jan 23, 2025
4ef6450
Shrink enc_bootloader.c code further
will-v-pi Jan 29, 2025
e17112d
Add otp file to enc
will-v-pi Jan 29, 2025
82d6116
Increase stack size by 0x80 to provide some headroom
will-v-pi Jan 29, 2025
9cf530f
Integrate latest aes.S code
will-v-pi Feb 4, 2025
1640e86
Use ROSC randomisation instead of CK_JITTER
will-v-pi Feb 7, 2025
b1b0015
Fix SDK branch for enc_bootloader
will-v-pi Feb 7, 2025
3251f22
Add comments and slight size reduction
will-v-pi Feb 7, 2025
4819b55
Uncomment chaff assertion
will-v-pi Feb 10, 2025
922c3e3
Shrink IV storage size
will-v-pi Feb 10, 2025
4eab13e
Update enc_bootloader.elf with latest
will-v-pi Feb 10, 2025
e86b6c5
Rejig clock init to prevent overclocking
will-v-pi Feb 10, 2025
7d8db46
Update with latest aes.S
will-v-pi Feb 12, 2025
2766a7d
Seed ROSC random using rstate_lfsr
will-v-pi Feb 12, 2025
9f01c2c
Use CK_JITTER to enable/disable ROSC randomisation
will-v-pi Feb 12, 2025
baf011f
Add IV XOR code, but turn it off with IV0_XOR for now
will-v-pi Feb 19, 2025
aa6a0ba
Disable calibration using XOSC by default
will-v-pi Feb 20, 2025
8781004
Update with latest aes.S
will-v-pi Feb 20, 2025
d7aa177
Add fast-rosc option
will-v-pi Feb 20, 2025
c8b03fd
clock_configure_mhz no longer used
will-v-pi Feb 24, 2025
854e147
Tidy up indents in CMakeLists.txt
will-v-pi Feb 24, 2025
8af552d
Remove CK_JITTER from aes.S, as this is now handled in the C code
will-v-pi Feb 24, 2025
e20a3a5
Throw error when using AES key share file of incorrect size
will-v-pi Feb 24, 2025
bd403b4
Incorporate latest aes.S code, and add IV salt
will-v-pi Feb 26, 2025
aef73b1
Update enc_bootloader.elf with latest
will-v-pi Feb 26, 2025
abb4e63
Remove pico-sdk branch handling
will-v-pi Feb 26, 2025
e96ff1c
Update aes.S
will-v-pi Feb 26, 2025
c29bad5
Add USE_MBEDTLS variant
will-v-pi Feb 26, 2025
7080fdf
Update with latest aes.S
will-v-pi Mar 4, 2025
8e9eaba
Better fix for #210
will-v-pi Mar 4, 2025
eef5d24
Add --use-mbedtls option to use mbedtls version of the decryption stage
will-v-pi Mar 4, 2025
15f059c
Add enc_bootloader_mbedtls to bazel build
will-v-pi Mar 4, 2025
8c4a66c
Fix build without mbedtls
will-v-pi Mar 4, 2025
bbbd032
Review fixups
will-v-pi Mar 13, 2025
fce50e1
Reword readme, to reflect word-wise aes file
will-v-pi Mar 13, 2025
cd21a1e
Add IV salt to regular encrypted binaries too
will-v-pi Mar 20, 2025
fd7e89b
Rename xip_ram_perms.cpp and enc_bootloader.cpp to get_....cpp
will-v-pi Mar 20, 2025
d26ccd0
Use include_directories for lib/include
will-v-pi Mar 20, 2025
5030525
Use newer VTABLE related variables
kilograham Mar 22, 2025
d838946
Copy last block when signing/encrypting, if it has an image_def
will-v-pi Mar 24, 2025
e0db243
Review fixups
will-v-pi Mar 24, 2025
3fdc556
Review fixups
will-v-pi Mar 25, 2025
64fe3d4
don't include RAM vector table
kilograham Mar 25, 2025
091cf6f
Mention file size in bits & bytes
will-v-pi Mar 31, 2025
04d8819
Remove OTP key workaround
will-v-pi Mar 31, 2025
90ddbc4
Remove load_map, hash and signature from chosen ELF blocks
will-v-pi Mar 31, 2025
e370a20
Clear SRAM in load_map of self-decrypting binary
will-v-pi Mar 31, 2025
33419cf
Add ability to generate key share from 256 bit key
will-v-pi Mar 31, 2025
b35d9a9
Remove -t argument when not needed
will-v-pi Mar 31, 2025
4adbf75
Support passing AES key and IV salt as hex strings instead of files
will-v-pi Mar 31, 2025
cbfab7c
Improve encrypt docs
will-v-pi Apr 1, 2025
eb5c981
Review fixups
will-v-pi Apr 1, 2025
ba3bf03
Improve external project inclusion
will-v-pi Apr 2, 2025
954120f
Use named_untyped_file_selection for coprodis as well
will-v-pi Apr 3, 2025
1ff20e0
Implement FIB workaround by storing inverse of row n in row n+32 of e…
will-v-pi Apr 3, 2025
d6c5171
Only delete existing load_maps when encrypting
will-v-pi Apr 7, 2025
61bf7c3
Tidy up string_to_hex_array function
will-v-pi Apr 15, 2025
f018f89
Add permission handling to OTP dump
will-v-pi Apr 7, 2025
6743582
Modify bootloader to work with FIB workaround
will-v-pi Apr 16, 2025
f9bf5e7
Review fixups
will-v-pi Apr 24, 2025
861a153
Mention mbedtls is "faster but less secure" in help text
will-v-pi Apr 24, 2025
9ea5a40
Merge branch 'develop' into encrypted-shares
will-v-pi Apr 28, 2025
b637421
Update README help text
will-v-pi Apr 28, 2025
b89a7e8
Prevent PRs running test-examples twice, and give it a name
will-v-pi Apr 28, 2025
4b49a6d
Fix mbedtls for FIB workaround
will-v-pi May 19, 2025
0c354a1
Improve error message when sealing an RP2040 binary with no metadata …
will-v-pi May 21, 2025
b42e72a
Improve RP2040 sealing error
will-v-pi May 22, 2025
3757973
Throw clearer error when using picotool >2.1.1 with SDK <=2.1.1
will-v-pi May 29, 2025
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
92 changes: 35 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ SYNOPSIS:
picotool config [-s <key> <value>] [-g <group>] <filename> [-t <type>]
picotool load [--ignore-partitions] [--family <family_id>] [-p <partition>] [-n] [-N] [-u] [-v] [-x] <filename> [-t <type>] [-o
<offset>] [device-selection]
picotool encrypt [--quiet] [--verbose] [--hash] [--sign] <infile> [-t <type>] [-o <offset>] <outfile> [-t <type>] <aes_key> [-t <type>]
[<signing_key>] [-t <type>]
picotool seal [--quiet] [--verbose] [--hash] [--sign] [--clear] <infile> [-t <type>] [-o <offset>] <outfile> [-t <type>] [<key>] [-t
<type>] [<otp>] [-t <type>] [--major <major>] [--minor <minor>] [--rollback <rollback> [<rows>..]]
picotool encrypt [--quiet] [--verbose] [--embed] [--fast-rosc] [--use-mbedtls] [--otp-key-page <page>] [--hash] [--sign] <infile> [-t
<type>] [-o <offset>] <outfile> [-t <type>] <aes_key> <iv_salt> <signing_key> <otp>
picotool seal [--quiet] [--verbose] [--hash] [--sign] [--clear] <infile> [-t <type>] [-o <offset>] <outfile> [-t <type>] <key> <otp>
[--major <major>] [--minor <minor>] [--rollback <rollback> [<rows>..]]
picotool link [--quiet] [--verbose] <outfile> [-t <type>] <infile1> [-t <type>] <infile2> [-t <type>] [<infile3>] [-t <type>] [-p <pad>]
picotool save [-p] [-v] [--family <family_id>] <filename> [-t <type>] [device-selection]
picotool save -a [-v] [--family <family_id>] <filename> [-t <type>] [device-selection]
Expand All @@ -33,7 +33,7 @@ SYNOPSIS:
picotool partition info|create
picotool uf2 info|convert
picotool version [-s] [<version>]
picotool coprodis [--quiet] [--verbose] <infile> [-t <type>] <outfile> [-t <type>]
picotool coprodis [--quiet] [--verbose] <infile> <outfile>
picotool help [<cmd>]

COMMANDS:
Expand Down Expand Up @@ -578,14 +578,18 @@ SEAL:
Add final metadata to a binary, optionally including a hash and/or signature.

SYNOPSIS:
picotool seal [--quiet] [--verbose] [--hash] [--sign] [--clear] <infile> [-t <type>] [-o <offset>] <outfile> [-t <type>] [<key>] [-t
<type>] [<otp>] [-t <type>] [--major <major>] [--minor <minor>] [--rollback <rollback> [<rows>..]]
picotool seal [--quiet] [--verbose] [--hash] [--sign] [--clear] <infile> [-t <type>] [-o <offset>] <outfile> [-t <type>] <key> <otp>
[--major <major>] [--minor <minor>] [--rollback <rollback> [<rows>..]]

OPTIONS:
--quiet
Don't print any output
--verbose
Print verbose output
<key>
Key file (.pem)
<otp>
JSON file to save OTP to (will edit existing file if it exists)
--major <major>
Add Major Version
--minor <minor>
Expand Down Expand Up @@ -614,16 +618,6 @@ OPTIONS:
The file name
-t <type>
Specify file type (uf2 | elf | bin) explicitly, ignoring file extension
Key file
<key>
The file name
-t <type>
Specify file type (pem) explicitly, ignoring file extension
File to save OTP to (will edit existing file if it exists)
<otp>
The file name
-t <type>
Specify file type (json) explicitly, ignoring file extension
```

## encrypt
Expand Down Expand Up @@ -654,8 +648,8 @@ ENCRYPT:
Encrypt the program.

SYNOPSIS:
picotool encrypt [--quiet] [--verbose] [--embed] [--fast-rosc] [--use-mbedtls] [--otp-key-page <page>] [--hash] [--sign] <infile>
[-t <type>] [-o <offset>] <outfile> [-t <type>] <aes_key> <iv_otp> <signing_key> <otp>
picotool encrypt [--quiet] [--verbose] [--embed] [--fast-rosc] [--use-mbedtls] [--otp-key-page <page>] [--hash] [--sign] <infile> [-t
<type>] [-o <offset>] <outfile> [-t <type>] <aes_key> <iv_salt> <signing_key> <otp>
Comment on lines +651 to +652
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How hard would it be to modify the line-wrapping to prevent a line-break getting inserted in the middle of e.g. [-t <type>] ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's handled by the CLIPP library, so probably a question for @kilograham whether we want to change that code?

picotool/clipp/clipp.h

Lines 317 to 363 in c56c005

/** @brief handle line wrapping due to column constraints */
template<class Iter>
void write_line(Iter first, Iter last)
{
if(first == last) return;
if(only_whitespace(first, last)) return;
if(right_of_text_area()) wrap_soft();
if(at_begin_of_line()) {
//discard whitespace, it we start a new line
first = std::find_if(first, last,
[](char_type c) { return !std::isspace(c); });
if(first == last) return;
}
const auto n = int(std::distance(first,last));
const auto m = columns_left_in_line();
//if text to be printed is too long for one line -> wrap
if(n > m) {
//break before word, if break is mid-word
auto breakat = first + m;
while(breakat > first && !std::isspace(*breakat)) --breakat;
//could not find whitespace before word -> try after the word
if(!std::isspace(*breakat) && breakat == first) {
breakat = std::find_if(first+m, last,
[](char_type c) { return std::isspace(c); });
}
if(breakat > first) {
if(curCol_ < 1) ++totalNonBlankLines_;
fix_indent();
std::copy(first, breakat, std::ostream_iterator<char_type>(os_));
curBlankLines_ = 0;
}
if(breakat < last) {
wrap_soft();
write_line(breakat, last);
}
}
else {
if(curCol_ < 1) ++totalNonBlankLines_;
fix_indent();
std::copy(first, last, std::ostream_iterator<char_type>(os_));
curCol_ += n;
curBlankLines_ = 0;
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, sounds like There Be Dragons 🐉


OPTIONS:
--quiet
Expand All @@ -667,19 +661,19 @@ OPTIONS:
--fast-rosc
Use ~180MHz ROSC configuration for embedded bootloader
--use-mbedtls
Use MbedTLS implementation of embedded bootloader
Use MbedTLS implementation of embedded bootloader (faster but less secure)
--otp-key-page
Specify the OTP page storing the AES key (IV salt is stored on the next page)
<page>
OTP page (default 30)
<aes_key>
AES Key Share or AES Key
<iv_otp>
IV OTP Salt
<iv_salt>
IV Salt
<signing_key>
Signing Key file
Signing Key file (.pem)
<otp>
File to save OTP to (will edit existing file if it exists)
JSON file to save OTP to (will edit existing file if it exists)
Signing Configuration
--hash
Hash the encrypted file
Expand Down Expand Up @@ -768,19 +762,16 @@ PARTITION CREATE:
Create a partition table from json

SYNOPSIS:
picotool partition create [--quiet] [--verbose] <infile> [-t <type>] <outfile> [-t <type>] [[-o <offset>] [--family <family_id>]]
[<bootloader>] [-t <type>] [[--sign <keyfile>] [-t <type>] [--no-hash] [--singleton]] [[--abs-block] [<abs_block_loc>]]
picotool partition create [--quiet] [--verbose] <infile> <outfile> [-t <type>] [[-o <offset>] [--family <family_id>]] [<bootloader>] [-t
<type>] [[--sign <keyfile>] [-t <type>] [--no-hash] [--singleton]] [[--abs-block] [<abs_block_loc>]]

OPTIONS:
--quiet
Don't print any output
--verbose
Print verbose output
partition table JSON
<infile>
The file name
-t <type>
Specify file type (json) explicitly, ignoring file extension
partition table JSON
output file
<outfile>
The file name
Expand Down Expand Up @@ -915,9 +906,9 @@ SYNOPSIS:
picotool otp get [-c <copies>] [-r] [-e] [-n] [-i <filename>] [device-selection] [-z] [<selector>..]
picotool otp set [-c <copies>] [-r] [-e] [-s] [-i <filename>] [-z] <selector> <value> [device-selection]
picotool otp load [-r] [-e] [-s <row>] [-i <filename>] <filename> [-t <type>] [device-selection]
picotool otp dump [-r] [-e] [device-selection]
picotool otp permissions <filename> [-t <type>] [--led <pin>] [--hash] [--sign] [<key>] [-t <type>] [device-selection]
picotool otp white-label -s <row> <filename> [-t <type>] [device-selection]
picotool otp dump [-r] [-e] [-p] [device-selection]
picotool otp permissions <filename> [--led <pin>] [--hash] [--sign] <key> [device-selection]
picotool otp white-label -s <row> <filename> [device-selection]

SUB COMMANDS:
list List matching known registers/fields
Expand Down Expand Up @@ -1120,14 +1111,11 @@ OTP WHITE-LABEL:
Set the white labelling values in OTP

SYNOPSIS:
picotool otp white-label -s <row> <filename> [-t <type>] [device-selection]
picotool otp white-label -s <row> <filename> [device-selection]

OPTIONS:
File with white labelling values
<filename>
The file name
-t <type>
Specify file type (json) explicitly, ignoring file extension
JSON file with white labelling values
Target device selection
--bus <bus>
Filter devices by USB bus number
Expand Down Expand Up @@ -1199,26 +1187,20 @@ OTP PERMISSIONS:
Set the OTP access permissions

SYNOPSIS:
picotool otp permissions <filename> [-t <type>] [--led <pin>] [--hash] [--sign] [<key>] [-t <type>] [device-selection]
picotool otp permissions <filename> [--led <pin>] [--hash] [--sign] <key> [device-selection]

OPTIONS:
File to load permissions from
<filename>
The file name
-t <type>
Specify file type (json) explicitly, ignoring file extension
JSON file to load permissions from
--led <pin>
LED Pin to flash; default 25
Signing Configuration
--hash
Hash the executable
--sign
Sign the executable
Key file
<key>
The file name
-t <type>
Specify file type (pem) explicitly, ignoring file extension
Key file (.pem)
Target device selection
--bus <bus>
Filter devices by USB bus number
Expand Down Expand Up @@ -1269,14 +1251,16 @@ OTP DUMP:
Dump entire OTP

SYNOPSIS:
picotool otp dump [-r] [-e] [device-selection]
picotool otp dump [-r] [-e] [-p] [device-selection]

OPTIONS:
Row/field options
-r, --raw
Get raw 24-bit values. This is the default
-e, --ecc
Use error correction
-p, --pages
Index by page number & row number

TARGET SELECTION:
Target device selection
Expand Down Expand Up @@ -1348,23 +1332,17 @@ COPRODIS:
Post-process coprocessor instructions in disassembly files.

SYNOPSIS:
picotool coprodis [--quiet] [--verbose] <infile> [-t <type>] <outfile> [-t <type>]
picotool coprodis [--quiet] [--verbose] <infile> <outfile>

OPTIONS:
--quiet
Don't print any output
--verbose
Print verbose output
Input DIS
<infile>
The file name
-t <type>
Specify file type (uf2 | elf | bin) explicitly, ignoring file extension
Output DIS
Input DIS
<outfile>
The file name
-t <type>
Specify file type (uf2 | elf | bin) explicitly, ignoring file extension
Output DIS
```

## link
Expand Down
Loading