Adds support for building without SHA256
This commit is contained in:
parent
f82c788382
commit
5f8a942ad4
|
@ -248,7 +248,11 @@ void do_upload(char *filename){
|
||||||
CborEncoder root, map;
|
CborEncoder root, map;
|
||||||
uint8_t cbor_buf[BOOT_SERIAL_OUT_MAX*2];
|
uint8_t cbor_buf[BOOT_SERIAL_OUT_MAX*2];
|
||||||
cbor_encoder_init(&root, cbor_buf, BOOT_SERIAL_OUT_MAX*2, 0);
|
cbor_encoder_init(&root, cbor_buf, BOOT_SERIAL_OUT_MAX*2, 0);
|
||||||
|
#ifdef DO_UPLOAD_SHA
|
||||||
cbor_encoder_create_map(&root, &map, pos == 0 ? 4 : 2);
|
cbor_encoder_create_map(&root, &map, pos == 0 ? 4 : 2);
|
||||||
|
#else
|
||||||
|
cbor_encoder_create_map(&root, &map, pos == 0 ? 3 : 2);
|
||||||
|
#endif
|
||||||
|
|
||||||
cbor_encode_text_stringz(&map, "data");
|
cbor_encode_text_stringz(&map, "data");
|
||||||
uint8_t data[data_chunk_len];
|
uint8_t data[data_chunk_len];
|
||||||
|
@ -269,6 +273,7 @@ void do_upload(char *filename){
|
||||||
cbor_encode_text_stringz(&map, "off");
|
cbor_encode_text_stringz(&map, "off");
|
||||||
cbor_encode_uint(&map, pos);
|
cbor_encode_uint(&map, pos);
|
||||||
|
|
||||||
|
#ifdef DO_UPLOAD_SHA
|
||||||
if (pos == 0) {
|
if (pos == 0) {
|
||||||
cbor_encode_text_stringz(&map, "sha");
|
cbor_encode_text_stringz(&map, "sha");
|
||||||
int f = open(filename, O_RDONLY);
|
int f = open(filename, O_RDONLY);
|
||||||
|
@ -292,6 +297,7 @@ void do_upload(char *filename){
|
||||||
sha256_final(&sha_ctx, (BYTE *)&sha);
|
sha256_final(&sha_ctx, (BYTE *)&sha);
|
||||||
cbor_encode_byte_string(&map, sha, 32);
|
cbor_encode_byte_string(&map, sha, 32);
|
||||||
}
|
}
|
||||||
|
#endif /* DO_UPLOAD_SHA */
|
||||||
|
|
||||||
cbor_encoder_close_container(&root, &map);
|
cbor_encoder_close_container(&root, &map);
|
||||||
size_t cbor_size = cbor_encoder_get_buffer_size(&root, cbor_buf);
|
size_t cbor_size = cbor_encoder_get_buffer_size(&root, cbor_buf);
|
||||||
|
|
Loading…
Reference in New Issue