Lines Matching refs:cipher

57 #include <openssl/cipher.h>
96 int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
98 if (cipher) {
101 return EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, enc);
105 if (c->cipher != NULL && c->cipher->cleanup && !c->cipher->cleanup(c)) {
110 OPENSSL_cleanse(c->cipher_data, c->cipher->ctx_size);
126 if (in == NULL || in->cipher == NULL) {
134 if (in->cipher_data && in->cipher->ctx_size) {
135 out->cipher_data = OPENSSL_malloc(in->cipher->ctx_size);
140 memcpy(out->cipher_data, in->cipher_data, in->cipher->ctx_size);
143 if (in->cipher->flags & EVP_CIPH_CUSTOM_COPY) {
144 return in->cipher->ctrl((EVP_CIPHER_CTX *)in, EVP_CTRL_COPY, 0, out);
150 int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
162 if (cipher) {
166 if (ctx->cipher) {
172 ctx->cipher = cipher;
173 if (ctx->cipher->ctx_size) {
174 ctx->cipher_data = OPENSSL_malloc(ctx->cipher->ctx_size);
183 ctx->key_len = cipher->key_len;
186 if (ctx->cipher->flags & EVP_CIPH_CTRL_INIT) {
192 } else if (!ctx->cipher) {
198 assert(ctx->cipher->block_size == 1 || ctx->cipher->block_size == 8 ||
199 ctx->cipher->block_size == 16);
233 if (key || (ctx->cipher->flags & EVP_CIPH_ALWAYS_CALL_INIT)) {
234 if (!ctx->cipher->init(ctx, key, iv, enc)) {
241 ctx->block_mask = ctx->cipher->block_size - 1;
245 int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
247 return EVP_CipherInit_ex(ctx, cipher, impl, key, iv, 1);
250 int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
252 return EVP_CipherInit_ex(ctx, cipher, impl, key, iv, 0);
259 if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {
260 i = ctx->cipher->cipher(ctx, out, in, in_len);
275 if (ctx->cipher->cipher(ctx, out, in, in_len)) {
285 bl = ctx->cipher->block_size;
296 if (!ctx->cipher->cipher(ctx, out, ctx->buf, bl)) {
311 if (!ctx->cipher->cipher(ctx, out, in, in_len)) {
328 if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {
329 ret = ctx->cipher->cipher(ctx, out, NULL, 0);
338 b = ctx->cipher->block_size;
360 ret = ctx->cipher->cipher(ctx, out, ctx->buf, b);
374 if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {
375 int r = ctx->cipher->cipher(ctx, out, in, in_len);
394 b = ctx->cipher->block_size;
431 if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {
432 i = ctx->cipher->cipher(ctx, out, NULL, 0);
441 b = ctx->cipher->block_size;
475 n = ctx->cipher->block_size - n;
489 return ctx->cipher->cipher(ctx, out, in, in_len);
510 return ctx->cipher;
514 return ctx->cipher->nid;
518 return ctx->cipher->block_size;
526 return ctx->cipher->iv_len;
538 return ctx->cipher->flags & ~EVP_CIPH_MODE_MASK;
542 return ctx->cipher->flags & EVP_CIPH_MODE_MASK;
547 if (!ctx->cipher) {
552 if (!ctx->cipher->ctrl) {
557 ret = ctx->cipher->ctrl(ctx, command, arg, ptr);
581 if (key_len == 0 || !(c->cipher->flags & EVP_CIPH_VARIABLE_LENGTH)) {
591 int EVP_CIPHER_nid(const EVP_CIPHER *cipher) { return cipher->nid; }
593 const char *EVP_CIPHER_name(const EVP_CIPHER *cipher) {
594 return OBJ_nid2sn(cipher->nid);
597 unsigned EVP_CIPHER_block_size(const EVP_CIPHER *cipher) {
598 return cipher->block_size;
601 unsigned EVP_CIPHER_key_length(const EVP_CIPHER *cipher) {
602 return cipher->key_len;
605 unsigned EVP_CIPHER_iv_length(const EVP_CIPHER *cipher) {
606 return cipher->iv_len;
609 uint32_t EVP_CIPHER_flags(const EVP_CIPHER *cipher) {
610 return cipher->flags & ~EVP_CIPH_MODE_MASK;
613 uint32_t EVP_CIPHER_mode(const EVP_CIPHER *cipher) {
614 return cipher->flags & EVP_CIPH_MODE_MASK;