Skip to content

Commit 5f6f278

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 d242062 commit 5f6f278

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
@@ -888,7 +888,8 @@ static status_t personalize_endorse_certificates(ujson_t *uj) {
888888
// DO NOT CHANGE THE BELOW STRING without modifying the host code in
889889
// sw/host/provisioning/ft_lib/src/lib.rs
890890
base_printf("Exporting TBS certificates ...\n");
891-
RESP_OK(ujson_serialize_perso_blob_t, uj, &perso_blob_to_host);
891+
RESP_OK_PADDED_NO_CRC(ujson_serialize_with_padding_perso_blob_t, uj,
892+
&perso_blob_to_host, kPersoBlobSerializedMaxSize);
892893

893894
// Import endorsed certificates from the provisioning appliance.
894895
// DO NOT CHANGE THE BELOW STRING without modifying the host code in
@@ -999,7 +1000,8 @@ static status_t personalize_endorse_certificates(ujson_t *uj) {
9991000

10001001
static status_t send_final_hash(ujson_t *uj, serdes_sha256_hash_t *hash) {
10011002
TRY(dif_gpio_write(&gpio, kGpioPinSpiConsoleTxReady, true));
1002-
TRY(RESP_OK(ujson_serialize_serdes_sha256_hash_t, uj, hash));
1003+
TRY(RESP_OK_PADDED_NO_CRC(ujson_serialize_with_padding_serdes_sha256_hash_t,
1004+
uj, hash, kSerdesSha256HashSerializedMaxSize));
10031005
TRY(dif_gpio_write(&gpio, kGpioPinSpiConsoleTxReady, false));
10041006
return OK_STATUS();
10051007
}

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

@@ -524,7 +525,7 @@ fn provision_certificates(
524525
let _ = UartConsole::wait_for(spi_console, r"Importing endorsed certificates ...", timeout)?;
525526
ujson_payloads.dut_in.insert(
526527
"FT_PERSO_DATA_IN".to_string(),
527-
manuf_perso_data_back.send(spi_console)?,
528+
manuf_perso_data_back.send_with_padding(spi_console, PERSO_BLOB_SERIALIZED_MAX_SIZE)?,
528529
);
529530
let _ = UartConsole::wait_for(spi_console, r"Finished importing certificates.", timeout)?;
530531
response.stats.log_elapsed_time("perso-import-certs", t0);

0 commit comments

Comments
 (0)