Lines Matching refs:bufUsed
56 static int handleEncrypt(uint8_t **pbuf, uint32_t bufUsed, FILE *out, uint64_t keyId, uint32_t *key) in handleEncrypt() argument
82 if (bufUsed <= sizeof(*image)) { in handleEncrypt()
87 encr.dataLen = bufUsed; in handleEncrypt()
89 if (((bufUsed - sizeof(*image)) % AES_BLOCK_SIZE) != 0) in handleEncrypt()
90 padLen = AES_BLOCK_SIZE - ((bufUsed - sizeof(*image)) % AES_BLOCK_SIZE); in handleEncrypt()
93 reallocOrDie(buf, bufUsed + padLen); in handleEncrypt()
94 rand_bytes(buf + bufUsed, padLen); in handleEncrypt()
95 bufUsed += padLen; in handleEncrypt()
96 fprintf(stderr, "Padded to %" PRIu32 " bytes\n", bufUsed); in handleEncrypt()
102 if (bufUsed >= sizeof(*image) && image->aosp.magic == NANOAPP_AOSP_MAGIC && in handleEncrypt()
123 bufUsed -= sizeof(*image); in handleEncrypt()
131 for (i = 0; i < bufUsed/sizeof(uint32_t); i += AES_BLOCK_WORDS) { in handleEncrypt()
153 static int handleDecrypt(uint8_t **pbuf, uint32_t bufUsed, FILE *out, uint32_t *key) in handleDecrypt() argument
168 if (bufUsed >= (sizeof(*image) + sizeof(*encr)) && in handleDecrypt()
180 bufUsed -= sizeof(*image) + sizeof(*encr); in handleDecrypt()
186 if (encr->dataLen > bufUsed) { in handleDecrypt()
191 encr->dataLen, bufUsed - encr->dataLen); in handleDecrypt()
204 for (i = 0; i < bufUsed / sizeof(uint32_t); i += AES_BLOCK_WORDS) { in handleDecrypt()
253 uint32_t bufUsed = 0; in main() local
332 buf = loadFile(posArg[0], &bufUsed); in main()
333 fprintf(stderr, "Read %" PRIu32 " bytes\n", bufUsed); in main()
343 ret = handleEncrypt(&buf, bufUsed, out, keyId, key); in main()
345 ret = handleDecrypt(&buf, bufUsed, out, key); in main()