Lines Matching refs:cctx
360 struct sb_cmd_ctx *cctx) in sb_encrypt_tag() argument
363 struct sb_command *cmd = &cctx->payload; in sb_encrypt_tag()
366 (uint8_t *)&cctx->c_payload, sizeof(*cmd)); in sb_encrypt_tag()
367 EVP_DigestUpdate(md_ctx, &cctx->c_payload, sizeof(*cmd)); in sb_encrypt_tag()
396 struct sb_cmd_ctx *cctx; in sb_encrypt_image() local
401 cctx = sctx->cmd_head; in sb_encrypt_image()
405 while (cctx) { in sb_encrypt_image()
406 ccmd = &cctx->payload; in sb_encrypt_image()
408 sb_encrypt_tag(ictx, cctx); in sb_encrypt_image()
413 sb_aes_crypt(ictx, cctx->data, cctx->data, in sb_encrypt_image()
414 cctx->length); in sb_encrypt_image()
415 EVP_DigestUpdate(ictx->md_ctx, cctx->data, in sb_encrypt_image()
416 cctx->length); in sb_encrypt_image()
419 cctx = cctx->cmd; in sb_encrypt_image()
440 static int sb_load_file(struct sb_cmd_ctx *cctx, char *filename) in sb_load_file() argument
478 cctx->data = data; in sb_load_file()
479 cctx->length = roundup_size; in sb_load_file()
789 struct sb_cmd_ctx *cctx; in sb_build_command_nop() local
792 cctx = calloc(1, sizeof(*cctx)); in sb_build_command_nop()
793 if (!cctx) in sb_build_command_nop()
796 ccmd = &cctx->payload; in sb_build_command_nop()
804 cctx->size = sizeof(*ccmd); in sb_build_command_nop()
810 sctx->cmd_head = cctx; in sb_build_command_nop()
811 sctx->cmd_tail = cctx; in sb_build_command_nop()
813 sctx->cmd_tail->cmd = cctx; in sb_build_command_nop()
814 sctx->cmd_tail = cctx; in sb_build_command_nop()
824 struct sb_cmd_ctx *cctx; in sb_build_command_tag() local
828 cctx = calloc(1, sizeof(*cctx)); in sb_build_command_tag()
829 if (!cctx) in sb_build_command_tag()
832 ccmd = &cctx->payload; in sb_build_command_tag()
848 cctx->size = sizeof(*ccmd); in sb_build_command_tag()
854 sctx->cmd_head = cctx; in sb_build_command_tag()
855 sctx->cmd_tail = cctx; in sb_build_command_tag()
857 sctx->cmd_tail->cmd = cctx; in sb_build_command_tag()
858 sctx->cmd_tail = cctx; in sb_build_command_tag()
868 struct sb_cmd_ctx *cctx; in sb_build_command_load() local
874 cctx = calloc(1, sizeof(*cctx)); in sb_build_command_load()
875 if (!cctx) in sb_build_command_load()
878 ccmd = &cctx->payload; in sb_build_command_load()
947 cctx->data = (uint8_t *)ivt; in sb_build_command_load()
948 cctx->length = sizeof(*ivt); in sb_build_command_load()
984 cctx->data = payload; in sb_build_command_load()
985 cctx->length = asize; in sb_build_command_load()
991 ret = sb_load_file(cctx, tok); in sb_build_command_load()
999 if (cctx->length & (SB_BLOCK_SIZE - 1)) { in sb_build_command_load()
1012 ccmd->load.count = cctx->length; in sb_build_command_load()
1014 (const char *)cctx->data, in sb_build_command_load()
1015 cctx->length); in sb_build_command_load()
1017 cctx->size = sizeof(*ccmd) + cctx->length; in sb_build_command_load()
1023 sctx->cmd_head = cctx; in sb_build_command_load()
1024 sctx->cmd_tail = cctx; in sb_build_command_load()
1026 sctx->cmd_tail->cmd = cctx; in sb_build_command_load()
1027 sctx->cmd_tail = cctx; in sb_build_command_load()
1033 free(cctx); in sb_build_command_load()
1041 struct sb_cmd_ctx *cctx; in sb_build_command_fill() local
1047 cctx = calloc(1, sizeof(*cctx)); in sb_build_command_fill()
1048 if (!cctx) in sb_build_command_fill()
1051 ccmd = &cctx->payload; in sb_build_command_fill()
1114 cctx->size = sizeof(*ccmd); in sb_build_command_fill()
1120 sctx->cmd_head = cctx; in sb_build_command_fill()
1121 sctx->cmd_tail = cctx; in sb_build_command_fill()
1123 sctx->cmd_tail->cmd = cctx; in sb_build_command_fill()
1124 sctx->cmd_tail = cctx; in sb_build_command_fill()
1130 free(cctx); in sb_build_command_fill()
1139 struct sb_cmd_ctx *cctx; in sb_build_command_jump_call() local
1147 cctx = calloc(1, sizeof(*cctx)); in sb_build_command_jump_call()
1148 if (!cctx) in sb_build_command_jump_call()
1151 ccmd = &cctx->payload; in sb_build_command_jump_call()
1205 cctx->size = sizeof(*ccmd); in sb_build_command_jump_call()
1211 sctx->cmd_head = cctx; in sb_build_command_jump_call()
1212 sctx->cmd_tail = cctx; in sb_build_command_jump_call()
1214 sctx->cmd_tail->cmd = cctx; in sb_build_command_jump_call()
1215 sctx->cmd_tail = cctx; in sb_build_command_jump_call()
1221 free(cctx); in sb_build_command_jump_call()
1241 struct sb_cmd_ctx *cctx; in sb_build_command_mode() local
1248 cctx = calloc(1, sizeof(*cctx)); in sb_build_command_mode()
1249 if (!cctx) in sb_build_command_mode()
1252 ccmd = &cctx->payload; in sb_build_command_mode()
1295 cctx->size = sizeof(*ccmd); in sb_build_command_mode()
1301 sctx->cmd_head = cctx; in sb_build_command_mode()
1302 sctx->cmd_tail = cctx; in sb_build_command_mode()
1304 sctx->cmd_tail->cmd = cctx; in sb_build_command_mode()
1305 sctx->cmd_tail = cctx; in sb_build_command_mode()
1311 free(cctx); in sb_build_command_mode()
1414 struct sb_cmd_ctx *cctx; in sb_fixup_sections_and_tags() local
1429 cctx = sctx->cmd_head; in sb_fixup_sections_and_tags()
1430 while (cctx) { in sb_fixup_sections_and_tags()
1431 ccmd = &cctx->payload; in sb_fixup_sections_and_tags()
1441 cctx = cctx->cmd; in sb_fixup_sections_and_tags()
1798 struct sb_cmd_ctx *cctx) in sb_decrypt_tag() argument
1801 struct sb_command *cmd = &cctx->payload; in sb_decrypt_tag()
1803 sb_aes_crypt(ictx, (uint8_t *)&cctx->c_payload, in sb_decrypt_tag()
1804 (uint8_t *)&cctx->payload, sizeof(*cmd)); in sb_decrypt_tag()
1805 EVP_DigestUpdate(md_ctx, &cctx->c_payload, sizeof(*cmd)); in sb_decrypt_tag()
1809 struct sb_cmd_ctx *cctx, FILE *fp, in sb_verify_command() argument
1812 struct sb_command *ccmd = &cctx->payload; in sb_verify_command()
1842 cctx->length = ccmd->load.count; in sb_verify_command()
1843 asize = roundup(cctx->length, SB_BLOCK_SIZE); in sb_verify_command()
1844 cctx->data = malloc(asize); in sb_verify_command()
1845 if (!cctx->data) in sb_verify_command()
1848 size = fread(cctx->data, 1, asize, fp); in sb_verify_command()
1857 EVP_DigestUpdate(ictx->md_ctx, cctx->data, asize); in sb_verify_command()
1858 sb_aes_crypt(ictx, cctx->data, cctx->data, asize); in sb_verify_command()
1861 (const char *)cctx->data, in sb_verify_command()
1907 struct sb_cmd_ctx *cctx; in sb_verify_commands() local
1913 cctx = calloc(1, sizeof(*cctx)); in sb_verify_commands()
1914 if (!cctx) in sb_verify_commands()
1917 sctx->cmd_head = cctx; in sb_verify_commands()
1918 sctx->cmd_tail = cctx; in sb_verify_commands()
1920 sctx->cmd_tail->cmd = cctx; in sb_verify_commands()
1921 sctx->cmd_tail = cctx; in sb_verify_commands()
1924 size = fread(&cctx->c_payload, 1, sizeof(cctx->c_payload), fp); in sb_verify_commands()
1925 if (size != sizeof(cctx->c_payload)) { in sb_verify_commands()
1932 sb_decrypt_tag(ictx, cctx); in sb_verify_commands()
1934 ret = sb_verify_command(ictx, cctx, fp, &tsize); in sb_verify_commands()
2140 struct sb_cmd_ctx *cctx, *c_head; in sb_free_image() local
2147 cctx = c_head; in sb_free_image()
2149 if (cctx->data) in sb_free_image()
2150 free(cctx->data); in sb_free_image()
2151 free(cctx); in sb_free_image()
2256 struct sb_cmd_ctx *cctx; in sb_build_image() local
2293 cctx = sctx->cmd_head; in sb_build_image()
2294 while (cctx) { in sb_build_image()
2295 ccmd = &cctx->payload; in sb_build_image()
2297 memcpy(iptr, &cctx->c_payload, sizeof(cctx->payload)); in sb_build_image()
2298 iptr += sizeof(cctx->payload); in sb_build_image()
2301 memcpy(iptr, cctx->data, cctx->length); in sb_build_image()
2302 iptr += cctx->length; in sb_build_image()
2305 cctx = cctx->cmd; in sb_build_image()