Lines Matching refs:ctx
110 BIO_ENC_CTX *ctx; in enc_new() local
112 ctx=(BIO_ENC_CTX *)OPENSSL_malloc(sizeof(BIO_ENC_CTX)); in enc_new()
113 if (ctx == NULL) return(0); in enc_new()
114 EVP_CIPHER_CTX_init(&ctx->cipher); in enc_new()
116 ctx->buf_len=0; in enc_new()
117 ctx->buf_off=0; in enc_new()
118 ctx->cont=1; in enc_new()
119 ctx->finished=0; in enc_new()
120 ctx->ok=1; in enc_new()
123 bi->ptr=(char *)ctx; in enc_new()
146 BIO_ENC_CTX *ctx; in enc_read() local
149 ctx=(BIO_ENC_CTX *)b->ptr; in enc_read()
151 if ((ctx == NULL) || (b->next_bio == NULL)) return(0); in enc_read()
154 if (ctx->buf_len > 0) in enc_read()
156 i=ctx->buf_len-ctx->buf_off; in enc_read()
158 memcpy(out,&(ctx->buf[ctx->buf_off]),i); in enc_read()
162 ctx->buf_off+=i; in enc_read()
163 if (ctx->buf_len == ctx->buf_off) in enc_read()
165 ctx->buf_len=0; in enc_read()
166 ctx->buf_off=0; in enc_read()
175 if (ctx->cont <= 0) break; in enc_read()
179 i=BIO_read(b->next_bio,&(ctx->buf[BUF_OFFSET]),ENC_BLOCK_SIZE); in enc_read()
186 ctx->cont=i; in enc_read()
187 i=EVP_CipherFinal_ex(&(ctx->cipher), in enc_read()
188 (unsigned char *)ctx->buf, in enc_read()
189 &(ctx->buf_len)); in enc_read()
190 ctx->ok=i; in enc_read()
191 ctx->buf_off=0; in enc_read()
201 EVP_CipherUpdate(&(ctx->cipher), in enc_read()
202 (unsigned char *)ctx->buf,&ctx->buf_len, in enc_read()
203 (unsigned char *)&(ctx->buf[BUF_OFFSET]),i); in enc_read()
204 ctx->cont=1; in enc_read()
211 if(ctx->buf_len == 0) continue; in enc_read()
214 if (ctx->buf_len <= outl) in enc_read()
215 i=ctx->buf_len; in enc_read()
219 memcpy(out,ctx->buf,i); in enc_read()
221 ctx->buf_off=i; in enc_read()
228 return((ret == 0)?ctx->cont:ret); in enc_read()
234 BIO_ENC_CTX *ctx; in enc_write() local
236 ctx=(BIO_ENC_CTX *)b->ptr; in enc_write()
240 n=ctx->buf_len-ctx->buf_off; in enc_write()
243 i=BIO_write(b->next_bio,&(ctx->buf[ctx->buf_off]),n); in enc_write()
249 ctx->buf_off+=i; in enc_write()
256 ctx->buf_off=0; in enc_write()
260 EVP_CipherUpdate(&(ctx->cipher), in enc_write()
261 (unsigned char *)ctx->buf,&ctx->buf_len, in enc_write()
266 ctx->buf_off=0; in enc_write()
267 n=ctx->buf_len; in enc_write()
270 i=BIO_write(b->next_bio,&(ctx->buf[ctx->buf_off]),n); in enc_write()
277 ctx->buf_off+=i; in enc_write()
279 ctx->buf_len=0; in enc_write()
280 ctx->buf_off=0; in enc_write()
289 BIO_ENC_CTX *ctx,*dctx; in enc_ctrl() local
294 ctx=(BIO_ENC_CTX *)b->ptr; in enc_ctrl()
299 ctx->ok=1; in enc_ctrl()
300 ctx->finished=0; in enc_ctrl()
301 EVP_CipherInit_ex(&(ctx->cipher),NULL,NULL,NULL,NULL, in enc_ctrl()
302 ctx->cipher.encrypt); in enc_ctrl()
306 if (ctx->cont <= 0) in enc_ctrl()
312 ret=ctx->buf_len-ctx->buf_off; in enc_ctrl()
317 ret=ctx->buf_len-ctx->buf_off; in enc_ctrl()
324 while (ctx->buf_len != ctx->buf_off) in enc_ctrl()
331 if (!ctx->finished) in enc_ctrl()
333 ctx->finished=1; in enc_ctrl()
334 ctx->buf_off=0; in enc_ctrl()
335 ret=EVP_CipherFinal_ex(&(ctx->cipher), in enc_ctrl()
336 (unsigned char *)ctx->buf, in enc_ctrl()
337 &(ctx->buf_len)); in enc_ctrl()
338 ctx->ok=(int)ret; in enc_ctrl()
349 ret=(long)ctx->ok; in enc_ctrl()
358 (*c_ctx)= &(ctx->cipher); in enc_ctrl()
364 memcpy(&(dctx->cipher),&(ctx->cipher),sizeof(ctx->cipher)); in enc_ctrl()
411 BIO_ENC_CTX *ctx; in BIO_set_cipher() local
420 ctx=(BIO_ENC_CTX *)b->ptr; in BIO_set_cipher()
421 EVP_CipherInit_ex(&(ctx->cipher),c,NULL, k,i,e); in BIO_set_cipher()