Lines Matching refs:ctx

133     BIO_OK_CTX *ctx;  in ok_new()  local
135 if ((ctx = OPENSSL_zalloc(sizeof(*ctx))) == NULL) in ok_new()
138 ctx->cont = 1; in ok_new()
139 ctx->sigio = 1; in ok_new()
140 ctx->md = EVP_MD_CTX_new(); in ok_new()
141 if (ctx->md == NULL) { in ok_new()
142 OPENSSL_free(ctx); in ok_new()
146 BIO_set_data(bi, ctx); in ok_new()
153 BIO_OK_CTX *ctx; in ok_free() local
158 ctx = BIO_get_data(a); in ok_free()
160 EVP_MD_CTX_free(ctx->md); in ok_free()
161 OPENSSL_clear_free(ctx, sizeof(BIO_OK_CTX)); in ok_free()
171 BIO_OK_CTX *ctx; in ok_read() local
177 ctx = BIO_get_data(b); in ok_read()
180 if ((ctx == NULL) || (next == NULL) || (BIO_get_init(b) == 0)) in ok_read()
186 if (ctx->blockout) { in ok_read()
187 i = ctx->buf_len - ctx->buf_off; in ok_read()
190 memcpy(out, &(ctx->buf[ctx->buf_off]), i); in ok_read()
194 ctx->buf_off += i; in ok_read()
197 if (ctx->buf_len == ctx->buf_off) { in ok_read()
198 ctx->buf_off = 0; in ok_read()
203 if (ctx->buf_len_save > ctx->buf_off_save) { in ok_read()
204 ctx->buf_len = ctx->buf_len_save - ctx->buf_off_save; in ok_read()
205 memmove(ctx->buf, &(ctx->buf[ctx->buf_off_save]), in ok_read()
206 ctx->buf_len); in ok_read()
208 ctx->buf_len = 0; in ok_read()
210 ctx->blockout = 0; in ok_read()
219 n = IOBS - ctx->buf_len; in ok_read()
220 i = BIO_read(next, &(ctx->buf[ctx->buf_len]), n); in ok_read()
225 ctx->buf_len += i; in ok_read()
228 if (ctx->sigio == 1) { in ok_read()
236 if (ctx->sigio == 0) { in ok_read()
244 if (ctx->cont <= 0) in ok_read()
257 BIO_OK_CTX *ctx; in ok_write() local
263 ctx = BIO_get_data(b); in ok_write()
267 if ((ctx == NULL) || (next == NULL) || (BIO_get_init(b) == 0)) in ok_write()
270 if (ctx->sigio && !sig_out(b)) in ok_write()
275 n = ctx->buf_len - ctx->buf_off; in ok_write()
276 while (ctx->blockout && n > 0) { in ok_write()
277 i = BIO_write(next, &(ctx->buf[ctx->buf_off]), n); in ok_write()
281 ctx->cont = 0; in ok_write()
284 ctx->buf_off += i; in ok_write()
289 ctx->blockout = 0; in ok_write()
290 if (ctx->buf_len == ctx->buf_off) { in ok_write()
291 ctx->buf_len = OK_BLOCK_BLOCK; in ok_write()
292 ctx->buf_off = 0; in ok_write()
298 n = (inl + ctx->buf_len > OK_BLOCK_SIZE + OK_BLOCK_BLOCK) ? in ok_write()
299 (int)(OK_BLOCK_SIZE + OK_BLOCK_BLOCK - ctx->buf_len) : inl; in ok_write()
301 memcpy(&ctx->buf[ctx->buf_len], in, n); in ok_write()
302 ctx->buf_len += n; in ok_write()
306 if (ctx->buf_len >= OK_BLOCK_SIZE + OK_BLOCK_BLOCK) { in ok_write()
321 BIO_OK_CTX *ctx; in ok_ctrl() local
328 ctx = BIO_get_data(b); in ok_ctrl()
333 ctx->buf_len = 0; in ok_ctrl()
334 ctx->buf_off = 0; in ok_ctrl()
335 ctx->buf_len_save = 0; in ok_ctrl()
336 ctx->buf_off_save = 0; in ok_ctrl()
337 ctx->cont = 1; in ok_ctrl()
338 ctx->finished = 0; in ok_ctrl()
339 ctx->blockout = 0; in ok_ctrl()
340 ctx->sigio = 1; in ok_ctrl()
344 if (ctx->cont <= 0) in ok_ctrl()
351 ret = ctx->blockout ? ctx->buf_len - ctx->buf_off : 0; in ok_ctrl()
357 if (ctx->blockout == 0) in ok_ctrl()
361 while (ctx->blockout) { in ok_ctrl()
369 ctx->finished = 1; in ok_ctrl()
370 ctx->buf_off = ctx->buf_len = 0; in ok_ctrl()
371 ctx->cont = (int)ret; in ok_ctrl()
383 ret = (long)ctx->cont; in ok_ctrl()
387 if (!EVP_DigestInit_ex(ctx->md, md, NULL)) in ok_ctrl()
394 *ppmd = EVP_MD_CTX_get0_md(ctx->md); in ok_ctrl()
434 BIO_OK_CTX *ctx; in sig_out() local
440 ctx = BIO_get_data(b); in sig_out()
441 md = ctx->md; in sig_out()
448 if (ctx->buf_len + 2 * md_size > OK_BLOCK_SIZE) in sig_out()
459 memcpy(&(ctx->buf[ctx->buf_len]), md_data, md_size); in sig_out()
460 longswap(&(ctx->buf[ctx->buf_len]), md_size); in sig_out()
461 ctx->buf_len += md_size; in sig_out()
465 if (!EVP_DigestFinal_ex(md, &(ctx->buf[ctx->buf_len]), NULL)) in sig_out()
467 ctx->buf_len += md_size; in sig_out()
468 ctx->blockout = 1; in sig_out()
469 ctx->sigio = 0; in sig_out()
478 BIO_OK_CTX *ctx; in sig_in() local
486 ctx = BIO_get_data(b); in sig_in()
487 if ((md = ctx->md) == NULL) in sig_in()
494 if ((int)(ctx->buf_len - ctx->buf_off) < 2 * md_size) in sig_in()
499 memcpy(md_data, &(ctx->buf[ctx->buf_off]), md_size); in sig_in()
501 ctx->buf_off += md_size; in sig_in()
507 ret = memcmp(&(ctx->buf[ctx->buf_off]), tmp, md_size) == 0; in sig_in()
508 ctx->buf_off += md_size; in sig_in()
510 ctx->sigio = 0; in sig_in()
511 if (ctx->buf_len != ctx->buf_off) { in sig_in()
512 memmove(ctx->buf, &(ctx->buf[ctx->buf_off]), in sig_in()
513 ctx->buf_len - ctx->buf_off); in sig_in()
515 ctx->buf_len -= ctx->buf_off; in sig_in()
516 ctx->buf_off = 0; in sig_in()
518 ctx->cont = 0; in sig_in()
528 BIO_OK_CTX *ctx; in block_out() local
534 ctx = BIO_get_data(b); in block_out()
535 md = ctx->md; in block_out()
541 tl = ctx->buf_len - OK_BLOCK_BLOCK; in block_out()
542 ctx->buf[0] = (unsigned char)(tl >> 24); in block_out()
543 ctx->buf[1] = (unsigned char)(tl >> 16); in block_out()
544 ctx->buf[2] = (unsigned char)(tl >> 8); in block_out()
545 ctx->buf[3] = (unsigned char)(tl); in block_out()
547 (unsigned char *)&(ctx->buf[OK_BLOCK_BLOCK]), tl)) in block_out()
549 if (!EVP_DigestFinal_ex(md, &(ctx->buf[ctx->buf_len]), NULL)) in block_out()
551 ctx->buf_len += md_size; in block_out()
552 ctx->blockout = 1; in block_out()
561 BIO_OK_CTX *ctx; in block_in() local
567 ctx = BIO_get_data(b); in block_in()
568 md = ctx->md; in block_in()
574 tl = ctx->buf[0]; in block_in()
576 tl |= ctx->buf[1]; in block_in()
578 tl |= ctx->buf[2]; in block_in()
580 tl |= ctx->buf[3]; in block_in()
582 if (ctx->buf_len < tl + OK_BLOCK_BLOCK + md_size) in block_in()
586 (unsigned char *)&(ctx->buf[OK_BLOCK_BLOCK]), tl)) in block_in()
590 if (memcmp(&(ctx->buf[tl + OK_BLOCK_BLOCK]), tmp, md_size) == 0) { in block_in()
592 ctx->buf_off_save = tl + OK_BLOCK_BLOCK + md_size; in block_in()
593 ctx->buf_len_save = ctx->buf_len; in block_in()
594 ctx->buf_off = OK_BLOCK_BLOCK; in block_in()
595 ctx->buf_len = tl + OK_BLOCK_BLOCK; in block_in()
596 ctx->blockout = 1; in block_in()
598 ctx->cont = 0; in block_in()