Lines Matching defs:ctx
37 struct chachapoly_ctx *ctx;
41 if ((ctx = calloc(1, sizeof(*ctx))) == NULL)
43 if ((ctx->main_evp = EVP_CIPHER_CTX_new()) == NULL ||
44 (ctx->header_evp = EVP_CIPHER_CTX_new()) == NULL)
46 if (!EVP_CipherInit(ctx->main_evp, EVP_chacha20(), key, NULL, 1))
48 if (!EVP_CipherInit(ctx->header_evp, EVP_chacha20(), key + 32, NULL, 1))
50 if (EVP_CIPHER_CTX_iv_length(ctx->header_evp) != 16)
52 return ctx;
54 chachapoly_free(ctx);
78 chachapoly_crypt(struct chachapoly_ctx *ctx, u_int seqnr, u_char *dest,
92 if (!EVP_CipherInit(ctx->main_evp, NULL, NULL, seqbuf, 1) ||
93 EVP_Cipher(ctx->main_evp, poly_key,
112 if (!EVP_CipherInit(ctx->header_evp, NULL, NULL, seqbuf, 1) ||
113 EVP_Cipher(ctx->header_evp, dest, src, aadlen) < 0) {
121 if (!EVP_CipherInit(ctx->main_evp, NULL, NULL, seqbuf, 1) ||
122 EVP_Cipher(ctx->main_evp, dest + aadlen, src + aadlen, len) < 0) {
142 chachapoly_get_length(struct chachapoly_ctx *ctx,
151 if (!EVP_CipherInit(ctx->header_evp, NULL, NULL, seqbuf, 0))
153 if (EVP_Cipher(ctx->header_evp, buf, (u_char *)cp, sizeof(buf)) < 0)