Lines Matching refs:cipher
57 #include <openssl/cipher.h>
103 if (c->cipher != NULL) {
104 if (c->cipher->cleanup) {
105 c->cipher->cleanup(c);
107 OPENSSL_cleanse(c->cipher_data, c->cipher->ctx_size);
123 if (in == NULL || in->cipher == NULL) {
131 if (in->cipher_data && in->cipher->ctx_size) {
132 out->cipher_data = OPENSSL_malloc(in->cipher->ctx_size);
137 memcpy(out->cipher_data, in->cipher_data, in->cipher->ctx_size);
140 if (in->cipher->flags & EVP_CIPH_CUSTOM_COPY) {
141 return in->cipher->ctrl((EVP_CIPHER_CTX *)in, EVP_CTRL_COPY, 0, out);
147 int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
159 if (cipher) {
163 if (ctx->cipher) {
169 ctx->cipher = cipher;
170 if (ctx->cipher->ctx_size) {
171 ctx->cipher_data = OPENSSL_malloc(ctx->cipher->ctx_size);
173 ctx->cipher = NULL;
181 ctx->key_len = cipher->key_len;
184 if (ctx->cipher->flags & EVP_CIPH_CTRL_INIT) {
186 ctx->cipher = NULL;
191 } else if (!ctx->cipher) {
197 assert(ctx->cipher->block_size == 1 || ctx->cipher->block_size == 8 ||
198 ctx->cipher->block_size == 16);
232 if (key || (ctx->cipher->flags & EVP_CIPH_ALWAYS_CALL_INIT)) {
233 if (!ctx->cipher->init(ctx, key, iv, enc)) {
240 ctx->block_mask = ctx->cipher->block_size - 1;
244 int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
246 return EVP_CipherInit_ex(ctx, cipher, impl, key, iv, 1);
249 int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
251 return EVP_CipherInit_ex(ctx, cipher, impl, key, iv, 0);
258 if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {
259 i = ctx->cipher->cipher(ctx, out, in, in_len);
274 if (ctx->cipher->cipher(ctx, out, in, in_len)) {
284 bl = ctx->cipher->block_size;
295 if (!ctx->cipher->cipher(ctx, out, ctx->buf, bl)) {
310 if (!ctx->cipher->cipher(ctx, out, in, in_len)) {
327 if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {
328 ret = ctx->cipher->cipher(ctx, out, NULL, 0);
337 b = ctx->cipher->block_size;
358 ret = ctx->cipher->cipher(ctx, out, ctx->buf, b);
372 if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {
373 int r = ctx->cipher->cipher(ctx, out, in, in_len);
392 b = ctx->cipher->block_size;
429 if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {
430 i = ctx->cipher->cipher(ctx, out, NULL, 0);
439 b = ctx->cipher->block_size;
471 n = ctx->cipher->block_size - n;
485 return ctx->cipher->cipher(ctx, out, in, in_len);
506 return ctx->cipher;
510 return ctx->cipher->nid;
514 return ctx->cipher->block_size;
522 return ctx->cipher->iv_len;
534 return ctx->cipher->flags & ~EVP_CIPH_MODE_MASK;
538 return ctx->cipher->flags & EVP_CIPH_MODE_MASK;
543 if (!ctx->cipher) {
548 if (!ctx->cipher->ctrl) {
553 ret = ctx->cipher->ctrl(ctx, command, arg, ptr);
576 if (key_len == 0 || !(c->cipher->flags & EVP_CIPH_VARIABLE_LENGTH)) {
585 int EVP_CIPHER_nid(const EVP_CIPHER *cipher) { return cipher->nid; }
587 unsigned EVP_CIPHER_block_size(const EVP_CIPHER *cipher) {
588 return cipher->block_size;
591 unsigned EVP_CIPHER_key_length(const EVP_CIPHER *cipher) {
592 return cipher->key_len;
595 unsigned EVP_CIPHER_iv_length(const EVP_CIPHER *cipher) {
596 return cipher->iv_len;
599 uint32_t EVP_CIPHER_flags(const EVP_CIPHER *cipher) {
600 return cipher->flags & ~EVP_CIPH_MODE_MASK;
603 uint32_t EVP_CIPHER_mode(const EVP_CIPHER *cipher) {
604 return cipher->flags & EVP_CIPH_MODE_MASK;
607 int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
609 if (cipher) {
612 return EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, enc);
615 int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
617 return EVP_CipherInit(ctx, cipher, key, iv, 1);
620 int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
622 return EVP_CipherInit(ctx, cipher, key, iv, 0);