Skip to content

Commit d546c2f

Browse files
timothytrippelpamaury
authored andcommitted
[personalize] pad UJSON messages to fixed sizes
To facilitate bringup of the personalization flow in an ATE environment fixed sized UJSON messages are required. This updates the personalization flow to pad all UJSON messages between the host and device with whitespace before each message's trailing "}" character to ensure fixed size data transmissions. Signed-off-by: Tim Trippel <[email protected]> (cherry picked from commit b05b4f7)
1 parent 3a3ea8e commit d546c2f

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

sw/device/silicon_creator/manuf/base/ft_personalize.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,8 @@ static status_t personalize_endorse_certificates(ujson_t *uj) {
891891
// DO NOT CHANGE THE BELOW STRING without modifying the host code in
892892
// sw/host/provisioning/ft_lib/src/lib.rs
893893
base_printf("Exporting TBS certificates ...\n");
894-
RESP_OK(ujson_serialize_perso_blob_t, uj, &perso_blob_to_host);
894+
RESP_OK_PADDED_NO_CRC(ujson_serialize_with_padding_perso_blob_t, uj,
895+
&perso_blob_to_host, kPersoBlobSerializedMaxSize);
895896

896897
// Import endorsed certificates from the provisioning appliance.
897898
// DO NOT CHANGE THE BELOW STRING without modifying the host code in
@@ -1002,7 +1003,8 @@ static status_t personalize_endorse_certificates(ujson_t *uj) {
10021003

10031004
static status_t send_final_hash(ujson_t *uj, serdes_sha256_hash_t *hash) {
10041005
TRY(dif_gpio_write(&gpio, kGpioPinSpiConsoleTxReady, true));
1005-
TRY(RESP_OK(ujson_serialize_serdes_sha256_hash_t, uj, hash));
1006+
TRY(RESP_OK_PADDED_NO_CRC(ujson_serialize_with_padding_serdes_sha256_hash_t,
1007+
uj, hash, kSerdesSha256HashSerializedMaxSize));
10061008
TRY(dif_gpio_write(&gpio, kGpioPinSpiConsoleTxReady, false));
10071009
return OK_STATUS();
10081010
}

sw/host/provisioning/ft_lib/src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ use ot_certs::x509::parse_certificate;
3535
use ot_hal::dif::lc_ctrl::{DifLcCtrlState, LcCtrlReg};
3636
use perso_tlv_lib::perso_tlv_get_field;
3737
use perso_tlv_lib::{CertHeader, CertHeaderType, ObjHeader, ObjHeaderType, ObjType};
38-
use ujson_lib::UjsonPayloads;
3938
use ujson_lib::provisioning_data::{
4039
LcTokenHash, ManufCertgenInputs, ManufFtIndividualizeData, PersoBlob, SerdesSha256Hash,
4140
};
41+
use ujson_lib::*;
4242
use util_lib::hash_lc_token;
4343
use util_lib::response::*;
4444

@@ -219,7 +219,7 @@ fn send_rma_unlock_token_hash(
219219
)?;
220220
ujson_payloads.dut_in.insert(
221221
"FT_PERSO_RMA_TOKEN_HASH".to_string(),
222-
rma_token_hash.send_with_crc(spi_console)?,
222+
rma_token_hash.send_with_padding(spi_console, LC_TOKEN_HASH_SERIALIZED_MAX_SIZE)?,
223223
);
224224
Ok(())
225225
}
@@ -342,7 +342,8 @@ fn provision_certificates(
342342
let t0 = Instant::now();
343343
ujson_payloads.dut_in.insert(
344344
"FT_PERSO_CERTGEN_INPUTS".to_string(),
345-
perso_certgen_inputs.send(spi_console)?,
345+
perso_certgen_inputs
346+
.send_with_padding(spi_console, MANUF_CERTGEN_INPUTS_SERIALIZED_MAX_SIZE)?,
346347
);
347348
response.stats.log_elapsed_time("perso-certgen-inputs", t0);
348349

@@ -535,7 +536,7 @@ fn provision_certificates(
535536
let _ = UartConsole::wait_for(spi_console, r"Importing endorsed certificates ...", timeout)?;
536537
ujson_payloads.dut_in.insert(
537538
"FT_PERSO_DATA_IN".to_string(),
538-
manuf_perso_data_back.send(spi_console)?,
539+
manuf_perso_data_back.send_with_padding(spi_console, PERSO_BLOB_SERIALIZED_MAX_SIZE)?,
539540
);
540541
let _ = UartConsole::wait_for(spi_console, r"Finished importing certificates.", timeout)?;
541542
response.stats.log_elapsed_time("perso-import-certs", t0);

0 commit comments

Comments
 (0)