Lines Matching refs:ctx

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