• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/ap/gpl/openssl/crypto/evp/

Lines Matching refs:ctx

70 void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx)
72 memset(ctx,0,sizeof(EVP_CIPHER_CTX));
73 /* ctx->cipher=NULL; */
77 int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
81 EVP_CIPHER_CTX_init(ctx);
82 return EVP_CipherInit_ex(ctx,cipher,NULL,key,iv,enc);
91 int bad_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,
95 int bad_do_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
101 int bad_set_asn1(EVP_CIPHER_CTX *ctx, ASN1_TYPE *typ)
103 int bad_get_asn1(EVP_CIPHER_CTX *ctx, ASN1_TYPE *typ)
105 int bad_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
127 int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl,
131 enc = ctx->encrypt;
136 ctx->encrypt = enc;
143 if (ctx->engine && ctx->cipher && (!cipher ||
144 (cipher && (cipher->nid == ctx->cipher->nid))))
152 EVP_CIPHER_CTX_cleanup(ctx);
155 ctx->encrypt = enc;
186 ctx->engine = impl;
189 ctx->engine = NULL;
191 ctx->cipher=cipher;
192 if (ctx->cipher->ctx_size)
194 ctx->cipher_data=OPENSSL_malloc(ctx->cipher->ctx_size);
195 if (!ctx->cipher_data)
203 ctx->cipher_data = NULL;
205 ctx->key_len = cipher->key_len;
206 ctx->flags = 0;
207 if(ctx->cipher->flags & EVP_CIPH_CTRL_INIT)
209 if(!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_INIT, 0, NULL))
216 else if(!ctx->cipher)
225 OPENSSL_assert(ctx->cipher->block_size == 1
226 || ctx->cipher->block_size == 8
227 || ctx->cipher->block_size == 16);
229 if(!(EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_CUSTOM_IV)) {
230 switch(EVP_CIPHER_CTX_mode(ctx)) {
239 ctx->num = 0;
243 OPENSSL_assert(EVP_CIPHER_CTX_iv_length(ctx) <= sizeof ctx->iv);
244 if(iv) memcpy(ctx->oiv, iv, EVP_CIPHER_CTX_iv_length(ctx));
245 memcpy(ctx->iv, ctx->oiv, EVP_CIPHER_CTX_iv_length(ctx));
260 if (!(ctx->cipher->flags & EVP_CIPH_FLAG_FIPS)
261 & !(ctx->flags & EVP_CIPH_FLAG_NON_FIPS_ALLOW))
265 EVP_CIPHER_name(ctx->cipher));
266 ctx->cipher = &bad_cipher;
272 if(key || (ctx->cipher->flags & EVP_CIPH_ALWAYS_CALL_INIT)) {
273 if(!ctx->cipher->init(ctx,key,iv,enc)) return 0;
275 ctx->buf_len=0;
276 ctx->final_used=0;
277 ctx->block_mask=ctx->cipher->block_size-1;
281 int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
284 if (ctx->encrypt)
285 return EVP_EncryptUpdate(ctx,out,outl,in,inl);
286 else return EVP_DecryptUpdate(ctx,out,outl,in,inl);
289 int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
291 if (ctx->encrypt)
292 return EVP_EncryptFinal_ex(ctx,out,outl);
293 else return EVP_DecryptFinal_ex(ctx,out,outl);
296 int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
298 if (ctx->encrypt)
299 return EVP_EncryptFinal(ctx,out,outl);
300 else return EVP_DecryptFinal(ctx,out,outl);
303 int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
306 return EVP_CipherInit(ctx, cipher, key, iv, 1);
309 int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl,
312 return EVP_CipherInit_ex(ctx, cipher, impl, key, iv, 1);
315 int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
318 return EVP_CipherInit(ctx, cipher, key, iv, 0);
321 int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl,
324 return EVP_CipherInit_ex(ctx, cipher, impl, key, iv, 0);
327 int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
333 if(ctx->buf_len == 0 && (inl&(ctx->block_mask)) == 0)
335 if(ctx->cipher->do_cipher(ctx,out,in,inl))
346 i=ctx->buf_len;
347 bl=ctx->cipher->block_size;
348 OPENSSL_assert(bl <= sizeof ctx->buf);
353 memcpy(&(ctx->buf[i]),in,inl);
354 ctx->buf_len+=inl;
361 memcpy(&(ctx->buf[i]),in,j);
362 if(!ctx->cipher->do_cipher(ctx,out,ctx->buf,bl)) return 0;
375 if(!ctx->cipher->do_cipher(ctx,out,in,inl)) return 0;
380 memcpy(ctx->buf,&(in[inl]),i);
381 ctx->buf_len=i;
385 int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
388 ret = EVP_EncryptFinal_ex(ctx, out, outl);
392 int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
396 b=ctx->cipher->block_size;
397 OPENSSL_assert(b <= sizeof ctx->buf);
403 bl=ctx->buf_len;
404 if (ctx->flags & EVP_CIPH_NO_PADDING)
417 ctx->buf[i]=n;
418 ret=ctx->cipher->do_cipher(ctx,out,ctx->buf,b);
427 int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
438 if (ctx->flags & EVP_CIPH_NO_PADDING)
439 return EVP_EncryptUpdate(ctx, out, outl, in, inl);
441 b=ctx->cipher->block_size;
442 OPENSSL_assert(b <= sizeof ctx->final);
444 if(ctx->final_used)
446 memcpy(out,ctx->final,b);
454 if(!EVP_EncryptUpdate(ctx,out,outl,in,inl))
459 if (b > 1 && !ctx->buf_len)
462 ctx->final_used=1;
463 memcpy(ctx->final,&out[*outl],b);
466 ctx->final_used = 0;
474 int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
477 ret = EVP_DecryptFinal_ex(ctx, out, outl);
481 int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
487 b=ctx->cipher->block_size;
488 if (ctx->flags & EVP_CIPH_NO_PADDING)
490 if(ctx->buf_len)
500 if (ctx->buf_len || !ctx->final_used)
505 OPENSSL_assert(b <= sizeof ctx->final);
506 n=ctx->final[b-1];
514 if (ctx->final[--b] != n)
520 n=ctx->cipher->block_size-n;
522 out[i]=ctx->final[i];
566 int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *ctx, int pad)
568 if (pad) ctx->flags &= ~EVP_CIPH_NO_PADDING;
569 else ctx->flags |= EVP_CIPH_NO_PADDING;
573 int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
576 if(!ctx->cipher) {
581 if(!ctx->cipher->ctrl) {
586 ret = ctx->cipher->ctrl(ctx, type, arg, ptr);