Lines Matching refs:ctx
114 BIO_B64_CTX *ctx;
116 ctx=(BIO_B64_CTX *)OPENSSL_malloc(sizeof(BIO_B64_CTX));
117 if (ctx == NULL) return(0);
119 ctx->buf_len=0;
120 ctx->tmp_len=0;
121 ctx->tmp_nl=0;
122 ctx->buf_off=0;
123 ctx->cont=1;
124 ctx->start=1;
125 ctx->encode=0;
128 bi->ptr=(char *)ctx;
147 BIO_B64_CTX *ctx;
151 ctx=(BIO_B64_CTX *)b->ptr;
153 if ((ctx == NULL) || (b->next_bio == NULL)) return(0);
157 if (ctx->encode != B64_DECODE)
159 ctx->encode=B64_DECODE;
160 ctx->buf_len=0;
161 ctx->buf_off=0;
162 ctx->tmp_len=0;
163 EVP_DecodeInit(&(ctx->base64));
167 if (ctx->buf_len > 0)
169 OPENSSL_assert(ctx->buf_len >= ctx->buf_off);
170 i=ctx->buf_len-ctx->buf_off;
172 OPENSSL_assert(ctx->buf_off+i < (int)sizeof(ctx->buf));
173 memcpy(out,&(ctx->buf[ctx->buf_off]),i);
177 ctx->buf_off+=i;
178 if (ctx->buf_len == ctx->buf_off)
180 ctx->buf_len=0;
181 ctx->buf_off=0;
191 if (ctx->cont <= 0)
194 i=BIO_read(b->next_bio,&(ctx->tmp[ctx->tmp_len]),
195 B64_BLOCK_SIZE-ctx->tmp_len);
204 ctx->cont=i;
206 if(ctx->tmp_len == 0)
216 i+=ctx->tmp_len;
217 ctx->tmp_len = i;
221 if (ctx->start && (BIO_get_flags(b) & BIO_FLAGS_BASE64_NO_NL))
223 /* ctx->start=1; */
224 ctx->tmp_len=0;
226 else if (ctx->start)
228 q=p=(unsigned char *)ctx->tmp;
237 if (ctx->tmp_nl)
240 ctx->tmp_nl=0;
244 k=EVP_DecodeUpdate(&(ctx->base64),
245 (unsigned char *)ctx->buf,
247 if ((k <= 0) && (num == 0) && (ctx->start))
248 EVP_DecodeInit(&ctx->base64);
252 &(ctx->tmp[0]))
255 &(ctx->tmp[0]));
257 ctx->tmp[x]=p[x];
259 EVP_DecodeInit(&ctx->base64);
260 ctx->start=0;
271 if (p == (unsigned char *)&(ctx->tmp[0]))
276 ctx->tmp_nl=1;
277 ctx->tmp_len=0;
284 ctx->tmp[ii]=p[ii];
285 ctx->tmp_len=n;
292 ctx->tmp_len=0;
295 else if ((i < B64_BLOCK_SIZE) && (ctx->cont > 0))
312 z=EVP_DecodeBlock((unsigned char *)ctx->buf,
313 (unsigned char *)ctx->tmp,jj);
316 if (ctx->tmp[jj-1] == '=')
319 if (ctx->tmp[jj-2] == '=')
327 memmove(ctx->tmp, &ctx->tmp[jj], i-jj);
328 ctx->tmp_len=i-jj;
330 ctx->buf_len=0;
333 ctx->buf_len=z;
339 i=EVP_DecodeUpdate(&(ctx->base64),
340 (unsigned char *)ctx->buf,&ctx->buf_len,
341 (unsigned char *)ctx->tmp,i);
342 ctx->tmp_len = 0;
344 ctx->buf_off=0;
348 ctx->buf_len=0;
352 if (ctx->buf_len <= outl)
353 i=ctx->buf_len;
357 memcpy(out,ctx->buf,i);
359 ctx->buf_off=i;
360 if (ctx->buf_off == ctx->buf_len)
362 ctx->buf_len=0;
363 ctx->buf_off=0;
378 BIO_B64_CTX *ctx;
380 ctx=(BIO_B64_CTX *)b->ptr;
383 if (ctx->encode != B64_ENCODE)
385 ctx->encode=B64_ENCODE;
386 ctx->buf_len=0;
387 ctx->buf_off=0;
388 ctx->tmp_len=0;
389 EVP_EncodeInit(&(ctx->base64));
392 OPENSSL_assert(ctx->buf_off < (int)sizeof(ctx->buf));
393 OPENSSL_assert(ctx->buf_len <= (int)sizeof(ctx->buf));
394 OPENSSL_assert(ctx->buf_len >= ctx->buf_off);
395 n=ctx->buf_len-ctx->buf_off;
398 i=BIO_write(b->next_bio,&(ctx->buf[ctx->buf_off]),n);
405 ctx->buf_off+=i;
406 OPENSSL_assert(ctx->buf_off <= (int)sizeof(ctx->buf));
407 OPENSSL_assert(ctx->buf_len >= ctx->buf_off);
411 ctx->buf_off=0;
412 ctx->buf_len=0;
422 if (ctx->tmp_len > 0)
424 OPENSSL_assert(ctx->tmp_len <= 3);
425 n=3-ctx->tmp_len;
429 memcpy(&(ctx->tmp[ctx->tmp_len]),in,n);
430 ctx->tmp_len+=n;
432 if (ctx->tmp_len < 3)
434 ctx->buf_len=EVP_EncodeBlock((unsigned char *)ctx->buf,(unsigned char *)ctx->tmp,ctx->tmp_len);
435 OPENSSL_assert(ctx->buf_len <= (int)sizeof(ctx->buf));
436 OPENSSL_assert(ctx->buf_len >= ctx->buf_off);
439 ctx->tmp_len=0;
445 memcpy(ctx->tmp,in,n);
446 ctx->tmp_len=n;
451 ctx->buf_len=EVP_EncodeBlock((unsigned char *)ctx->buf,(const unsigned char *)in,n);
452 OPENSSL_assert(ctx->buf_len <= (int)sizeof(ctx->buf));
453 OPENSSL_assert(ctx->buf_len >= ctx->buf_off);
459 EVP_EncodeUpdate(&(ctx->base64),
460 (unsigned char *)ctx->buf,&ctx->buf_len,
462 OPENSSL_assert(ctx->buf_len <= (int)sizeof(ctx->buf));
463 OPENSSL_assert(ctx->buf_len >= ctx->buf_off);
469 ctx->buf_off=0;
470 n=ctx->buf_len;
473 i=BIO_write(b->next_bio,&(ctx->buf[ctx->buf_off]),n);
481 ctx->buf_off+=i;
482 OPENSSL_assert(ctx->buf_off <= (int)sizeof(ctx->buf));
483 OPENSSL_assert(ctx->buf_len >= ctx->buf_off);
485 ctx->buf_len=0;
486 ctx->buf_off=0;
493 BIO_B64_CTX *ctx;
497 ctx=(BIO_B64_CTX *)b->ptr;
502 ctx->cont=1;
503 ctx->start=1;
504 ctx->encode=B64_NONE;
508 if (ctx->cont <= 0)
514 OPENSSL_assert(ctx->buf_len >= ctx->buf_off);
515 ret=ctx->buf_len-ctx->buf_off;
516 if ((ret == 0) && (ctx->encode != B64_NONE)
517 && (ctx->base64.num != 0))
523 OPENSSL_assert(ctx->buf_len >= ctx->buf_off);
524 ret=ctx->buf_len-ctx->buf_off;
531 while (ctx->buf_len != ctx->buf_off)
539 if (ctx->tmp_len != 0)
541 ctx->buf_len=EVP_EncodeBlock(
542 (unsigned char *)ctx->buf,
543 (unsigned char *)ctx->tmp,
544 ctx->tmp_len);
545 ctx->buf_off=0;
546 ctx->tmp_len=0;
550 else if (ctx->encode != B64_NONE && ctx->base64.num != 0)
552 ctx->buf_off=0;
553 EVP_EncodeFinal(&(ctx->base64),
554 (unsigned char *)ctx->buf,
555 &(ctx->buf_len));