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

Set keypair length in example issuer to value length #14869

Merged
merged 1 commit into from
Feb 8, 2022

Conversation

austinh0
Copy link
Contributor

@austinh0 austinh0 commented Feb 8, 2022

Problem

For ExampleOperationalCredentialsIssuer, calls to Serialize() occur without setting the length of serializedKey, which in the mbedTLS impl defaults to using the capacity.

This is buggy since capacity relies on size_t (architecture-dependent), so a keypair serialized on a 64-bit platform could not be deserialized on a 32-bit platform.

Change overview

Set keypair length to the size of the value retrieved from storage, which is uint16_t.

Testing

Use serialized keypairs on 32-bit and 64-bit platforms.

@github-actions
Copy link

github-actions bot commented Feb 8, 2022

PR #14869: Size comparison from 97cf4ff to 14b6a94

Increases (1 build for linux)
platform target config section 97cf4ff 14b6a94 change % change
linux chip-tool-ipv6only arm64 (read only) 7315220 7315412 192 0.0
.rodata 396380 396412 32 0.0
.text 6309684 6309844 160 0.0
Full report (24 builds for cyw30739, efr32, esp32, k32w, linux, mbed, p6, qpg, telink)
platform target config section 97cf4ff 14b6a94 change % change
cyw30739 light cyw930739m2evb_01 (read/write) 594398 594398 0 0.0
.app_xip_area 500252 500252 0 0.0
.bss 76868 76868 0 0.0
.data 624 624 0 0.0
.rodata 0 0 0 0.0
.text 0 0 0 0.0
lock cyw930739m2evb_01 (read/write) 552298 552298 0 0.0
.app_xip_area 459712 459712 0 0.0
.bss 75340 75340 0 0.0
.data 588 588 0 0.0
.rodata 0 0 0 0.0
.text 0 0 0 0.0
ota-requestor cyw930739m2evb_01 (read/write) 576306 576306 0 0.0
.app_xip_area 474400 474400 0 0.0
.bss 84332 84332 0 0.0
.data 532 532 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
efr32 lighting-app BRD4161A (read only) 865756 865756 0 0.0
(read/write) 126620 126620 0 0.0
.bss 124696 124696 0 0.0
.data 1924 1924 0 0.0
.text 865748 865748 0 0.0
BRD4161A+rpc (read only) 853212 853212 0 0.0
(read/write) 143280 143280 0 0.0
.bss 141256 141256 0 0.0
.data 2024 2024 0 0.0
.text 853204 853204 0 0.0
window-app BRD4161A (read only) 837960 837960 0 0.0
(read/write) 125264 125264 0 0.0
.bss 123384 123384 0 0.0
.data 1880 1880 0 0.0
.text 837952 837952 0 0.0
esp32 all-clusters-app c3devkit (read only) 937916 937916 0 0.0
(read/write) 1401098 1401098 0 0.0
.dram0.bss 69448 69448 0 0.0
.dram0.data 14276 14276 0 0.0
.flash.rodata 198464 198464 0 0.0
.flash.text 937916 937916 0 0.0
.iram0.text 62056 62056 0 0.0
m5stack (read only) 986251 986251 0 0.0
(read/write) 466136 466136 0 0.0
.dram0.bss 74592 74592 0 0.0
.dram0.data 34040 34040 0 0.0
.flash.rodata 225376 225376 0 0.0
.flash.text 980867 980867 0 0.0
.iram0.text 123399 123399 0 0.0
k32w light k32w061+release (read/write) 678488 678488 0 0.0
.bss 76568 76568 0 0.0
.data 1884 1884 0 0.0
.text 594236 594236 0 0.0
lock k32w061+release (read/write) 680388 680388 0 0.0
.bss 76896 76896 0 0.0
.data 1924 1924 0 0.0
.text 595768 595768 0 0.0
linux chip-tool-ipv6only arm64 (read only) 7315220 7315412 192 0.0
(read/write) 289681 289681 0 0.0
.bss 50641 50641 0 0.0
.data 1176 1176 0 0.0
.data.rel.ro 187544 187544 0 0.0
.dynamic 560 560 0 0.0
.got 46528 46528 0 0.0
.init 24 24 0 0.0
.init_array 192 192 0 0.0
.rodata 396380 396412 32 0.0
.text 6309684 6309844 160 0.0
thermostat-no-ble arm64 (read only) 2129612 2129612 0 0.0
(read/write) 140641 140641 0 0.0
.bss 57665 57665 0 0.0
.data 984 984 0 0.0
.data.rel.ro 74872 74872 0 0.0
.dynamic 560 560 0 0.0
.got 4152 4152 0 0.0
.init 24 24 0 0.0
.init_array 328 328 0 0.0
.rodata 131932 131932 0 0.0
.text 1779712 1779712 0 0.0
mbed all-clusters-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2389632 2389632 0 0.0
.bss 188356 188356 0 0.0
.data 5296 5296 0 0.0
.text 1352232 1352232 0 0.0
lighting-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2348800 2348800 0 0.0
.bss 180936 180936 0 0.0
.data 5600 5600 0 0.0
.text 1311400 1311400 0 0.0
lock-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2312720 2312720 0 0.0
.bss 180824 180824 0 0.0
.data 5584 5584 0 0.0
.text 1275320 1275320 0 0.0
pigweed-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 1139648 1139648 0 0.0
.bss 11756 11756 0 0.0
.data 4368 4368 0 0.0
.text 103032 103032 0 0.0
shell CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2302692 2302692 0 0.0
.bss 178100 178100 0 0.0
.data 5400 5400 0 0.0
.text 1265264 1265264 0 0.0
p6 all-clusters-app default (read/write) 2463712 2463712 0 0.0
.bss 117976 117976 0 0.0
.data 2584 2584 0 0.0
.text 1421976 1421976 0 0.0
light-app default (read/write) 2367176 2367176 0 0.0
.bss 107600 107600 0 0.0
.data 2432 2432 0 0.0
.text 1325440 1325440 0 0.0
lock-app default (read/write) 2332344 2332344 0 0.0
.bss 107304 107304 0 0.0
.data 2392 2392 0 0.0
.text 1290608 1290608 0 0.0
qpg lighting-app qpg6105+debug (read only) 585768 585768 0 0.0
(read/write) 146936 146936 0 0.0
.bss 88856 88856 0 0.0
.data 1084 1084 0 0.0
.text 580448 580448 0 0.0
lock-app qpg6105+debug (read only) 531844 531844 0 0.0
(read/write) 146940 146940 0 0.0
.bss 88304 88304 0 0.0
.data 1024 1024 0 0.0
.text 526524 526524 0 0.0
persistent-storage-app qpg6105+debug (read only) 99520 99520 0 0.0
(read/write) 146940 146940 0 0.0
.bss 24004 24004 0 0.0
.data 176 176 0 0.0
.text 94200 94200 0 0.0
telink lighting-app tlsr9518adk80d (read/write) 865702 865702 0 0.0
bss 88592 88592 0 0.0
noinit 37160 37160 0 0.0
text 607624 607624 0 0.0

@woody-apple
Copy link
Contributor

/rebase

@github-actions
Copy link

github-actions bot commented Feb 8, 2022

PR #14869: Size comparison from 29e6a34 to 3ada6bb

Increases (3 builds for linux)
platform target config section 29e6a34 3ada6bb change % change
linux chip-tool debug (read only) 7383957 7384293 336 0.0
.rodata 413077 413205 128 0.0
.text 6599045 6599253 208 0.0
chip-tool-ipv6only arm64 (read only) 7315220 7315412 192 0.0
.rodata 396380 396412 32 0.0
.text 6309684 6309844 160 0.0
tv-app debug (read only) 2525545 2525849 304 0.0
.rodata 195532 195628 96 0.0
.text 2156402 2156610 208 0.0
Full report (43 builds for cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
platform target config section 29e6a34 3ada6bb change % change
cyw30739 light cyw930739m2evb_01 (read/write) 594398 594398 0 0.0
.app_xip_area 500252 500252 0 0.0
.bss 76868 76868 0 0.0
.data 624 624 0 0.0
.rodata 0 0 0 0.0
.text 0 0 0 0.0
lock cyw930739m2evb_01 (read/write) 552298 552298 0 0.0
.app_xip_area 459712 459712 0 0.0
.bss 75340 75340 0 0.0
.data 588 588 0 0.0
.rodata 0 0 0 0.0
.text 0 0 0 0.0
ota-requestor cyw930739m2evb_01 (read/write) 576306 576306 0 0.0
.app_xip_area 474400 474400 0 0.0
.bss 84332 84332 0 0.0
.data 532 532 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
efr32 lighting-app BRD4161A (read only) 865756 865756 0 0.0
(read/write) 126620 126620 0 0.0
.bss 124696 124696 0 0.0
.data 1924 1924 0 0.0
.text 865748 865748 0 0.0
BRD4161A+rpc (read only) 853212 853212 0 0.0
(read/write) 143280 143280 0 0.0
.bss 141256 141256 0 0.0
.data 2024 2024 0 0.0
.text 853204 853204 0 0.0
window-app BRD4161A (read only) 837960 837960 0 0.0
(read/write) 125264 125264 0 0.0
.bss 123384 123384 0 0.0
.data 1880 1880 0 0.0
.text 837952 837952 0 0.0
esp32 all-clusters-app c3devkit (read only) 937916 937916 0 0.0
(read/write) 1401098 1401098 0 0.0
.dram0.bss 69448 69448 0 0.0
.dram0.data 14276 14276 0 0.0
.flash.rodata 198464 198464 0 0.0
.flash.text 937916 937916 0 0.0
.iram0.text 62056 62056 0 0.0
m5stack (read only) 986251 986251 0 0.0
(read/write) 466136 466136 0 0.0
.dram0.bss 74592 74592 0 0.0
.dram0.data 34040 34040 0 0.0
.flash.rodata 225376 225376 0 0.0
.flash.text 980867 980867 0 0.0
.iram0.text 123399 123399 0 0.0
k32w light k32w061+release (read/write) 678488 678488 0 0.0
.bss 76568 76568 0 0.0
.data 1884 1884 0 0.0
.text 594236 594236 0 0.0
lock k32w061+release (read/write) 680388 680388 0 0.0
.bss 76896 76896 0 0.0
.data 1924 1924 0 0.0
.text 595768 595768 0 0.0
linux all-clusters-app debug (read only) 2327337 2327337 0 0.0
(read/write) 140064 140064 0 0.0
.bss 54688 54688 0 0.0
.data 1200 1200 0 0.0
.data.rel.ro 78504 78504 0 0.0
.dynamic 592 592 0 0.0
.got 4136 4136 0 0.0
.init 27 27 0 0.0
.init_array 920 920 0 0.0
.rodata 205029 205029 0 0.0
.text 1960082 1960082 0 0.0
bridge-app debug+rpc (read only) 1704053 1704053 0 0.0
(read/write) 84296 84296 0 0.0
.bss 39088 39088 0 0.0
.data 1970 1970 0 0.0
.data.rel.ro 38088 38088 0 0.0
.dynamic 592 592 0 0.0
.got 3976 3976 0 0.0
.init 27 27 0 0.0
.init_array 560 560 0 0.0
.rodata 140172 140172 0 0.0
.text 1447429 1447429 0 0.0
chip-tool debug (read only) 7383957 7384293 336 0.0
(read/write) 185392 185392 0 0.0
.bss 32360 32360 0 0.0
.data 1152 1152 0 0.0
.data.rel.ro 145888 145888 0 0.0
.dynamic 608 608 0 0.0
.got 4760 4760 0 0.0
.init 27 27 0 0.0
.init_array 608 608 0 0.0
.rodata 413077 413205 128 0.0
.text 6599045 6599253 208 0.0
chip-tool-ipv6only arm64 (read only) 7315220 7315412 192 0.0
(read/write) 289681 289681 0 0.0
.bss 50641 50641 0 0.0
.data 1176 1176 0 0.0
.data.rel.ro 187544 187544 0 0.0
.dynamic 560 560 0 0.0
.got 46528 46528 0 0.0
.init 24 24 0 0.0
.init_array 192 192 0 0.0
.rodata 396380 396412 32 0.0
.text 6309684 6309844 160 0.0
door-lock-app debug (read only) 1908457 1908457 0 0.0
(read/write) 110552 110552 0 0.0
.bss 42096 42096 0 0.0
.data 946 946 0 0.0
.data.rel.ro 62096 62096 0 0.0
.dynamic 592 592 0 0.0
.got 4112 4112 0 0.0
.init 27 27 0 0.0
.init_array 672 672 0 0.0
.rodata 172786 172786 0 0.0
.text 1587250 1587250 0 0.0
lighting-app debug+rpc (read only) 2003289 2003289 0 0.0
(read/write) 115600 115600 0 0.0
.bss 43104 43104 0 0.0
.data 1368 1368 0 0.0
.data.rel.ro 65640 65640 0 0.0
.dynamic 608 608 0 0.0
.got 4144 4144 0 0.0
.init 27 27 0 0.0
.init_array 712 712 0 0.0
.rodata 162865 162865 0 0.0
.text 1685874 1685874 0 0.0
ota-provider-app debug (read only) 1711905 1711905 0 0.0
(read/write) 81336 81336 0 0.0
.bss 41120 41120 0 0.0
.data 1160 1160 0 0.0
.data.rel.ro 33528 33528 0 0.0
.dynamic 608 608 0 0.0
.got 4240 4240 0 0.0
.init 27 27 0 0.0
.init_array 624 624 0 0.0
.rodata 151206 151206 0 0.0
.text 1442114 1442114 0 0.0
ota-requestor-app debug (read only) 1701321 1701321 0 0.0
(read/write) 83288 83288 0 0.0
.bss 42272 42272 0 0.0
.data 1128 1128 0 0.0
.data.rel.ro 34584 34584 0 0.0
.dynamic 592 592 0 0.0
.got 4040 4040 0 0.0
.init 27 27 0 0.0
.init_array 624 624 0 0.0
.rodata 144823 144823 0 0.0
.text 1439698 1439698 0 0.0
shell debug (read only) 2300761 2300761 0 0.0
(read/write) 141616 141616 0 0.0
.bss 62080 62080 0 0.0
.data 800 800 0 0.0
.data.rel.ro 73040 73040 0 0.0
.dynamic 592 592 0 0.0
.got 4168 4168 0 0.0
.init 27 27 0 0.0
.init_array 904 904 0 0.0
.rodata 205778 205778 0 0.0
.text 1938562 1938562 0 0.0
thermostat-no-ble arm64 (read only) 2129596 2129596 0 0.0
(read/write) 140641 140641 0 0.0
.bss 57665 57665 0 0.0
.data 984 984 0 0.0
.data.rel.ro 74872 74872 0 0.0
.dynamic 560 560 0 0.0
.got 4152 4152 0 0.0
.init 24 24 0 0.0
.init_array 328 328 0 0.0
.rodata 131932 131932 0 0.0
.text 1779696 1779696 0 0.0
tv-app debug (read only) 2525545 2525849 304 0.0
(read/write) 139800 139800 0 0.0
.bss 57280 57280 0 0.0
.data 3168 3168 0 0.0
.data.rel.ro 73336 73336 0 0.0
.dynamic 592 592 0 0.0
.got 4528 4528 0 0.0
.init 27 27 0 0.0
.init_array 880 880 0 0.0
.rodata 195532 195628 96 0.0
.text 2156402 2156610 208 0.0
mbed all-clusters-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2389632 2389632 0 0.0
.bss 188356 188356 0 0.0
.data 5296 5296 0 0.0
.text 1352232 1352232 0 0.0
lighting-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2348800 2348800 0 0.0
.bss 180936 180936 0 0.0
.data 5600 5600 0 0.0
.text 1311400 1311400 0 0.0
lock-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2312720 2312720 0 0.0
.bss 180824 180824 0 0.0
.data 5584 5584 0 0.0
.text 1275320 1275320 0 0.0
pigweed-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 1139648 1139648 0 0.0
.bss 11756 11756 0 0.0
.data 4368 4368 0 0.0
.text 103032 103032 0 0.0
shell CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2302692 2302692 0 0.0
.bss 178100 178100 0 0.0
.data 5400 5400 0 0.0
.text 1265264 1265264 0 0.0
nrfconnect lighting-app nrf52840dk_nrf52840 (read/write) 1004731 1004731 0 0.0
bss 121280 121280 0 0.0
rodata 118072 118072 0 0.0
text 686436 686436 0 0.0
nrf52840dk_nrf52840+rpc (read/write) 976207 976207 0 0.0
bss 117136 117136 0 0.0
rodata 109532 109532 0 0.0
text 671076 671076 0 0.0
nrf52840dongle_nrf52840 (read/write) 1021535 1021535 0 0.0
bss 122644 122644 0 0.0
rodata 116960 116960 0 0.0
text 692004 692004 0 0.0
nrf5340dk_nrf5340_cpuapp (read/write) 911394 911394 0 0.0
bss 117840 117840 0 0.0
rodata 111332 111332 0 0.0
text 601460 601460 0 0.0
lock-app nrf52840dk_nrf52840 (read/write) 936987 936987 0 0.0
bss 119616 119616 0 0.0
rodata 106472 106472 0 0.0
text 632356 632356 0 0.0
nrf5340dk_nrf5340_cpuapp (read/write) 844482 844482 0 0.0
bss 116212 116212 0 0.0
rodata 99644 99644 0 0.0
text 548156 548156 0 0.0
pigweed-app nrf52840dk_nrf52840 (read/write) 541747 541747 0 0.0
bss 52588 52588 0 0.0
rodata 50048 50048 0 0.0
text 376920 376920 0 0.0
pump-app nrf52840dk_nrf52840 (read/write) 939219 939219 0 0.0
bss 119368 119368 0 0.0
rodata 106656 106656 0 0.0
text 634600 634600 0 0.0
pump-controller-app nrf52840dk_nrf52840 (read/write) 934559 934559 0 0.0
bss 119372 119372 0 0.0
rodata 105948 105948 0 0.0
text 630632 630632 0 0.0
shell nrf52840dk_nrf52840 (read/write) 803151 803151 0 0.0
bss 111232 111232 0 0.0
rodata 78532 78532 0 0.0
text 535824 535824 0 0.0
p6 all-clusters-app default (read/write) 2463712 2463712 0 0.0
.bss 117976 117976 0 0.0
.data 2584 2584 0 0.0
.text 1421976 1421976 0 0.0
light-app default (read/write) 2367176 2367176 0 0.0
.bss 107600 107600 0 0.0
.data 2432 2432 0 0.0
.text 1325440 1325440 0 0.0
lock-app default (read/write) 2332344 2332344 0 0.0
.bss 107304 107304 0 0.0
.data 2392 2392 0 0.0
.text 1290608 1290608 0 0.0
qpg lighting-app qpg6105+debug (read only) 585768 585768 0 0.0
(read/write) 146936 146936 0 0.0
.bss 88856 88856 0 0.0
.data 1084 1084 0 0.0
.text 580448 580448 0 0.0
lock-app qpg6105+debug (read only) 531844 531844 0 0.0
(read/write) 146940 146940 0 0.0
.bss 88304 88304 0 0.0
.data 1024 1024 0 0.0
.text 526524 526524 0 0.0
persistent-storage-app qpg6105+debug (read only) 99520 99520 0 0.0
(read/write) 146940 146940 0 0.0
.bss 24004 24004 0 0.0
.data 176 176 0 0.0
.text 94200 94200 0 0.0
telink lighting-app tlsr9518adk80d (read/write) 865702 865702 0 0.0
bss 88592 88592 0 0.0
noinit 37160 37160 0 0.0
text 607624 607624 0 0.0

@andy31415 andy31415 merged commit 092e707 into project-chip:master Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants