Lines Matching refs:ctx

42 cbc_encrypt_contiguous_blocks(cbc_ctx_t *ctx, char *data, size_t length,  in cbc_encrypt_contiguous_blocks()  argument
59 if (length + ctx->cbc_remainder_len < block_size) { in cbc_encrypt_contiguous_blocks()
62 (uint8_t *)ctx->cbc_remainder + ctx->cbc_remainder_len, in cbc_encrypt_contiguous_blocks()
64 ctx->cbc_remainder_len += length; in cbc_encrypt_contiguous_blocks()
65 ctx->cbc_copy_to = datap; in cbc_encrypt_contiguous_blocks()
69 lastp = (uint8_t *)ctx->cbc_iv; in cbc_encrypt_contiguous_blocks()
75 if (ctx->cbc_remainder_len > 0) { in cbc_encrypt_contiguous_blocks()
76 need = block_size - ctx->cbc_remainder_len; in cbc_encrypt_contiguous_blocks()
81 bcopy(datap, &((uint8_t *)ctx->cbc_remainder) in cbc_encrypt_contiguous_blocks()
82 [ctx->cbc_remainder_len], need); in cbc_encrypt_contiguous_blocks()
84 blockp = (uint8_t *)ctx->cbc_remainder; in cbc_encrypt_contiguous_blocks()
95 encrypt(ctx->cbc_keysched, blockp, blockp); in cbc_encrypt_contiguous_blocks()
97 ctx->cbc_lastp = blockp; in cbc_encrypt_contiguous_blocks()
100 if (ctx->cbc_remainder_len > 0) { in cbc_encrypt_contiguous_blocks()
101 bcopy(blockp, ctx->cbc_copy_to, in cbc_encrypt_contiguous_blocks()
102 ctx->cbc_remainder_len); in cbc_encrypt_contiguous_blocks()
103 bcopy(blockp + ctx->cbc_remainder_len, datap, in cbc_encrypt_contiguous_blocks()
112 encrypt(ctx->cbc_keysched, lastp, lastp); in cbc_encrypt_contiguous_blocks()
132 if (ctx->cbc_remainder_len != 0) { in cbc_encrypt_contiguous_blocks()
134 ctx->cbc_remainder_len = 0; in cbc_encrypt_contiguous_blocks()
143 bcopy(datap, ctx->cbc_remainder, remainder); in cbc_encrypt_contiguous_blocks()
144 ctx->cbc_remainder_len = remainder; in cbc_encrypt_contiguous_blocks()
145 ctx->cbc_copy_to = datap; in cbc_encrypt_contiguous_blocks()
148 ctx->cbc_copy_to = NULL; in cbc_encrypt_contiguous_blocks()
156 if (ctx->cbc_lastp != NULL) { in cbc_encrypt_contiguous_blocks()
157 copy_block((uint8_t *)ctx->cbc_lastp, (uint8_t *)ctx->cbc_iv); in cbc_encrypt_contiguous_blocks()
158 ctx->cbc_lastp = (uint8_t *)ctx->cbc_iv; in cbc_encrypt_contiguous_blocks()
164 #define OTHER(a, ctx) \ argument
165 (((a) == (ctx)->cbc_lastblock) ? (ctx)->cbc_iv : (ctx)->cbc_lastblock)
169 cbc_decrypt_contiguous_blocks(cbc_ctx_t *ctx, char *data, size_t length, in cbc_decrypt_contiguous_blocks() argument
186 if (length + ctx->cbc_remainder_len < block_size) { in cbc_decrypt_contiguous_blocks()
189 (uint8_t *)ctx->cbc_remainder + ctx->cbc_remainder_len, in cbc_decrypt_contiguous_blocks()
191 ctx->cbc_remainder_len += length; in cbc_decrypt_contiguous_blocks()
192 ctx->cbc_copy_to = datap; in cbc_decrypt_contiguous_blocks()
196 lastp = ctx->cbc_lastp; in cbc_decrypt_contiguous_blocks()
202 if (ctx->cbc_remainder_len > 0) { in cbc_decrypt_contiguous_blocks()
203 need = block_size - ctx->cbc_remainder_len; in cbc_decrypt_contiguous_blocks()
208 bcopy(datap, &((uint8_t *)ctx->cbc_remainder) in cbc_decrypt_contiguous_blocks()
209 [ctx->cbc_remainder_len], need); in cbc_decrypt_contiguous_blocks()
211 blockp = (uint8_t *)ctx->cbc_remainder; in cbc_decrypt_contiguous_blocks()
217 copy_block(blockp, (uint8_t *)OTHER((uint64_t *)lastp, ctx)); in cbc_decrypt_contiguous_blocks()
220 decrypt(ctx->cbc_keysched, blockp, in cbc_decrypt_contiguous_blocks()
221 (uint8_t *)ctx->cbc_remainder); in cbc_decrypt_contiguous_blocks()
222 blockp = (uint8_t *)ctx->cbc_remainder; in cbc_decrypt_contiguous_blocks()
224 decrypt(ctx->cbc_keysched, blockp, blockp); in cbc_decrypt_contiguous_blocks()
234 lastp = (uint8_t *)OTHER((uint64_t *)lastp, ctx); in cbc_decrypt_contiguous_blocks()
249 } else if (ctx->cbc_remainder_len > 0) { in cbc_decrypt_contiguous_blocks()
251 bcopy(blockp, ctx->cbc_copy_to, ctx->cbc_remainder_len); in cbc_decrypt_contiguous_blocks()
252 bcopy(blockp + ctx->cbc_remainder_len, datap, need); in cbc_decrypt_contiguous_blocks()
256 if (ctx->cbc_remainder_len != 0) { in cbc_decrypt_contiguous_blocks()
258 ctx->cbc_remainder_len = 0; in cbc_decrypt_contiguous_blocks()
267 bcopy(datap, ctx->cbc_remainder, remainder); in cbc_decrypt_contiguous_blocks()
268 ctx->cbc_remainder_len = remainder; in cbc_decrypt_contiguous_blocks()
269 ctx->cbc_lastp = lastp; in cbc_decrypt_contiguous_blocks()
270 ctx->cbc_copy_to = datap; in cbc_decrypt_contiguous_blocks()
273 ctx->cbc_copy_to = NULL; in cbc_decrypt_contiguous_blocks()
277 ctx->cbc_lastp = lastp; in cbc_decrypt_contiguous_blocks()