Home | History | Annotate | Download | only in crypto

Lines Matching refs:ctx

122 void aes_encrypt(void *ctx, const u8 *plain, u8 *crypt)
124 gcry_cipher_hd_t hd = ctx;
129 void aes_encrypt_deinit(void *ctx)
131 gcry_cipher_hd_t hd = ctx;
152 void aes_decrypt(void *ctx, const u8 *crypt, u8 *plain)
154 gcry_cipher_hd_t hd = ctx;
159 void aes_decrypt_deinit(void *ctx)
161 gcry_cipher_hd_t hd = ctx;
211 struct crypto_cipher *ctx;
216 ctx = os_zalloc(sizeof(*ctx));
217 if (ctx == NULL)
223 res = gcry_cipher_open(&ctx->enc, a, GCRY_CIPHER_MODE_STREAM,
225 gcry_cipher_open(&ctx->dec, a, GCRY_CIPHER_MODE_STREAM, 0);
234 res = gcry_cipher_open(&ctx->enc, a, GCRY_CIPHER_MODE_CBC, 0);
235 gcry_cipher_open(&ctx->dec, a, GCRY_CIPHER_MODE_CBC, 0);
239 res = gcry_cipher_open(&ctx->enc, a, GCRY_CIPHER_MODE_CBC, 0);
240 gcry_cipher_open(&ctx->dec, a, GCRY_CIPHER_MODE_CBC, 0);
244 res = gcry_cipher_open(&ctx->enc, a, GCRY_CIPHER_MODE_CBC, 0);
245 gcry_cipher_open(&ctx->dec, a, GCRY_CIPHER_MODE_CBC, 0);
252 res = gcry_cipher_open(&ctx->enc, a, GCRY_CIPHER_MODE_CBC, 0);
253 gcry_cipher_open(&ctx->dec, a, GCRY_CIPHER_MODE_CBC, 0);
256 os_free(ctx);
261 os_free(ctx);
265 if (gcry_cipher_setkey(ctx->enc, key, key_len) != GPG_ERR_NO_ERROR ||
266 gcry_cipher_setkey(ctx->dec, key, key_len) != GPG_ERR_NO_ERROR) {
267 gcry_cipher_close(ctx->enc);
268 gcry_cipher_close(ctx->dec);
269 os_free(ctx);
274 if (gcry_cipher_setiv(ctx->enc, iv, ivlen) != GPG_ERR_NO_ERROR ||
275 gcry_cipher_setiv(ctx->dec, iv, ivlen) != GPG_ERR_NO_ERROR) {
276 gcry_cipher_close(ctx->enc);
277 gcry_cipher_close(ctx->dec);
278 os_free(ctx);
282 return ctx;
286 int crypto_cipher_encrypt(struct crypto_cipher *ctx, const u8 *plain,
289 if (gcry_cipher_encrypt(ctx->enc, crypt, len, plain, len) !=
296 int crypto_cipher_decrypt(struct crypto_cipher *ctx, const u8 *crypt,
299 if (gcry_cipher_decrypt(ctx->dec, plain, len, crypt, len) !=
306 void crypto_cipher_deinit(struct crypto_cipher *ctx)
308 gcry_cipher_close(ctx->enc);
309 gcry_cipher_close(ctx->dec);
310 os_free(ctx);