Lines Matching refs:cctx
359 struct sb_cmd_ctx *cctx) in sb_encrypt_tag() argument
362 struct sb_command *cmd = &cctx->payload; in sb_encrypt_tag()
365 (uint8_t *)&cctx->c_payload, sizeof(*cmd)); in sb_encrypt_tag()
366 EVP_DigestUpdate(md_ctx, &cctx->c_payload, sizeof(*cmd)); in sb_encrypt_tag()
395 struct sb_cmd_ctx *cctx; in sb_encrypt_image() local
400 cctx = sctx->cmd_head; in sb_encrypt_image()
404 while (cctx) { in sb_encrypt_image()
405 ccmd = &cctx->payload; in sb_encrypt_image()
407 sb_encrypt_tag(ictx, cctx); in sb_encrypt_image()
412 sb_aes_crypt(ictx, cctx->data, cctx->data, in sb_encrypt_image()
413 cctx->length); in sb_encrypt_image()
414 EVP_DigestUpdate(ictx->md_ctx, cctx->data, in sb_encrypt_image()
415 cctx->length); in sb_encrypt_image()
418 cctx = cctx->cmd; in sb_encrypt_image()
439 static int sb_load_file(struct sb_cmd_ctx *cctx, char *filename) in sb_load_file() argument
477 cctx->data = data; in sb_load_file()
478 cctx->length = roundup_size; in sb_load_file()
788 struct sb_cmd_ctx *cctx; in sb_build_command_nop() local
791 cctx = calloc(1, sizeof(*cctx)); in sb_build_command_nop()
792 if (!cctx) in sb_build_command_nop()
795 ccmd = &cctx->payload; in sb_build_command_nop()
803 cctx->size = sizeof(*ccmd); in sb_build_command_nop()
809 sctx->cmd_head = cctx; in sb_build_command_nop()
810 sctx->cmd_tail = cctx; in sb_build_command_nop()
812 sctx->cmd_tail->cmd = cctx; in sb_build_command_nop()
813 sctx->cmd_tail = cctx; in sb_build_command_nop()
823 struct sb_cmd_ctx *cctx; in sb_build_command_tag() local
827 cctx = calloc(1, sizeof(*cctx)); in sb_build_command_tag()
828 if (!cctx) in sb_build_command_tag()
831 ccmd = &cctx->payload; in sb_build_command_tag()
847 cctx->size = sizeof(*ccmd); in sb_build_command_tag()
853 sctx->cmd_head = cctx; in sb_build_command_tag()
854 sctx->cmd_tail = cctx; in sb_build_command_tag()
856 sctx->cmd_tail->cmd = cctx; in sb_build_command_tag()
857 sctx->cmd_tail = cctx; in sb_build_command_tag()
867 struct sb_cmd_ctx *cctx; in sb_build_command_load() local
873 cctx = calloc(1, sizeof(*cctx)); in sb_build_command_load()
874 if (!cctx) in sb_build_command_load()
877 ccmd = &cctx->payload; in sb_build_command_load()
946 cctx->data = (uint8_t *)ivt; in sb_build_command_load()
947 cctx->length = sizeof(*ivt); in sb_build_command_load()
983 cctx->data = payload; in sb_build_command_load()
984 cctx->length = asize; in sb_build_command_load()
990 ret = sb_load_file(cctx, tok); in sb_build_command_load()
998 if (cctx->length & (SB_BLOCK_SIZE - 1)) { in sb_build_command_load()
1011 ccmd->load.count = cctx->length; in sb_build_command_load()
1013 (const char *)cctx->data, in sb_build_command_load()
1014 cctx->length); in sb_build_command_load()
1016 cctx->size = sizeof(*ccmd) + cctx->length; in sb_build_command_load()
1022 sctx->cmd_head = cctx; in sb_build_command_load()
1023 sctx->cmd_tail = cctx; in sb_build_command_load()
1025 sctx->cmd_tail->cmd = cctx; in sb_build_command_load()
1026 sctx->cmd_tail = cctx; in sb_build_command_load()
1032 free(cctx); in sb_build_command_load()
1040 struct sb_cmd_ctx *cctx; in sb_build_command_fill() local
1046 cctx = calloc(1, sizeof(*cctx)); in sb_build_command_fill()
1047 if (!cctx) in sb_build_command_fill()
1050 ccmd = &cctx->payload; in sb_build_command_fill()
1113 cctx->size = sizeof(*ccmd); in sb_build_command_fill()
1119 sctx->cmd_head = cctx; in sb_build_command_fill()
1120 sctx->cmd_tail = cctx; in sb_build_command_fill()
1122 sctx->cmd_tail->cmd = cctx; in sb_build_command_fill()
1123 sctx->cmd_tail = cctx; in sb_build_command_fill()
1129 free(cctx); in sb_build_command_fill()
1138 struct sb_cmd_ctx *cctx; in sb_build_command_jump_call() local
1146 cctx = calloc(1, sizeof(*cctx)); in sb_build_command_jump_call()
1147 if (!cctx) in sb_build_command_jump_call()
1150 ccmd = &cctx->payload; in sb_build_command_jump_call()
1204 cctx->size = sizeof(*ccmd); in sb_build_command_jump_call()
1210 sctx->cmd_head = cctx; in sb_build_command_jump_call()
1211 sctx->cmd_tail = cctx; in sb_build_command_jump_call()
1213 sctx->cmd_tail->cmd = cctx; in sb_build_command_jump_call()
1214 sctx->cmd_tail = cctx; in sb_build_command_jump_call()
1220 free(cctx); in sb_build_command_jump_call()
1240 struct sb_cmd_ctx *cctx; in sb_build_command_mode() local
1247 cctx = calloc(1, sizeof(*cctx)); in sb_build_command_mode()
1248 if (!cctx) in sb_build_command_mode()
1251 ccmd = &cctx->payload; in sb_build_command_mode()
1294 cctx->size = sizeof(*ccmd); in sb_build_command_mode()
1300 sctx->cmd_head = cctx; in sb_build_command_mode()
1301 sctx->cmd_tail = cctx; in sb_build_command_mode()
1303 sctx->cmd_tail->cmd = cctx; in sb_build_command_mode()
1304 sctx->cmd_tail = cctx; in sb_build_command_mode()
1310 free(cctx); in sb_build_command_mode()
1413 struct sb_cmd_ctx *cctx; in sb_fixup_sections_and_tags() local
1428 cctx = sctx->cmd_head; in sb_fixup_sections_and_tags()
1429 while (cctx) { in sb_fixup_sections_and_tags()
1430 ccmd = &cctx->payload; in sb_fixup_sections_and_tags()
1440 cctx = cctx->cmd; in sb_fixup_sections_and_tags()
1797 struct sb_cmd_ctx *cctx) in sb_decrypt_tag() argument
1800 struct sb_command *cmd = &cctx->payload; in sb_decrypt_tag()
1802 sb_aes_crypt(ictx, (uint8_t *)&cctx->c_payload, in sb_decrypt_tag()
1803 (uint8_t *)&cctx->payload, sizeof(*cmd)); in sb_decrypt_tag()
1804 EVP_DigestUpdate(md_ctx, &cctx->c_payload, sizeof(*cmd)); in sb_decrypt_tag()
1808 struct sb_cmd_ctx *cctx, FILE *fp, in sb_verify_command() argument
1811 struct sb_command *ccmd = &cctx->payload; in sb_verify_command()
1841 cctx->length = ccmd->load.count; in sb_verify_command()
1842 asize = roundup(cctx->length, SB_BLOCK_SIZE); in sb_verify_command()
1843 cctx->data = malloc(asize); in sb_verify_command()
1844 if (!cctx->data) in sb_verify_command()
1847 size = fread(cctx->data, 1, asize, fp); in sb_verify_command()
1856 EVP_DigestUpdate(ictx->md_ctx, cctx->data, asize); in sb_verify_command()
1857 sb_aes_crypt(ictx, cctx->data, cctx->data, asize); in sb_verify_command()
1860 (const char *)cctx->data, in sb_verify_command()
1906 struct sb_cmd_ctx *cctx; in sb_verify_commands() local
1912 cctx = calloc(1, sizeof(*cctx)); in sb_verify_commands()
1913 if (!cctx) in sb_verify_commands()
1916 sctx->cmd_head = cctx; in sb_verify_commands()
1917 sctx->cmd_tail = cctx; in sb_verify_commands()
1919 sctx->cmd_tail->cmd = cctx; in sb_verify_commands()
1920 sctx->cmd_tail = cctx; in sb_verify_commands()
1923 size = fread(&cctx->c_payload, 1, sizeof(cctx->c_payload), fp); in sb_verify_commands()
1924 if (size != sizeof(cctx->c_payload)) { in sb_verify_commands()
1931 sb_decrypt_tag(ictx, cctx); in sb_verify_commands()
1933 ret = sb_verify_command(ictx, cctx, fp, &tsize); in sb_verify_commands()
2139 struct sb_cmd_ctx *cctx, *c_head; in sb_free_image() local
2146 cctx = c_head; in sb_free_image()
2148 if (cctx->data) in sb_free_image()
2149 free(cctx->data); in sb_free_image()
2150 free(cctx); in sb_free_image()
2255 struct sb_cmd_ctx *cctx; in sb_build_image() local
2292 cctx = sctx->cmd_head; in sb_build_image()
2293 while (cctx) { in sb_build_image()
2294 ccmd = &cctx->payload; in sb_build_image()
2296 memcpy(iptr, &cctx->c_payload, sizeof(cctx->payload)); in sb_build_image()
2297 iptr += sizeof(cctx->payload); in sb_build_image()
2300 memcpy(iptr, cctx->data, cctx->length); in sb_build_image()
2301 iptr += cctx->length; in sb_build_image()
2304 cctx = cctx->cmd; in sb_build_image()