Go to the documentation of this file.
68 #include "../../internal.h"
84 if (
c->cipher != NULL &&
c->cipher->cleanup) {
85 c->cipher->cleanup(
c);
101 if (
in == NULL ||
in->cipher == NULL) {
109 if (
in->cipher_data &&
in->cipher->ctx_size) {
111 if (!
out->cipher_data) {
157 ctx->cipher = cipher;
158 if (
ctx->cipher->ctx_size) {
160 if (!
ctx->cipher_data) {
166 ctx->cipher_data = NULL;
179 }
else if (!
ctx->cipher) {
185 assert(
ctx->cipher->block_size == 1 ||
ctx->cipher->block_size == 8 ||
186 ctx->cipher->block_size == 16);
221 if (!
ctx->cipher->init(
ctx,
key, iv, enc)) {
245 assert(
ctx->cipher->block_size != 0);
246 assert((
ctx->cipher->block_size & (
ctx->cipher->block_size - 1)) == 0);
247 return len & (
ctx->cipher->block_size - 1);
254 int bl =
ctx->cipher->block_size;
255 if (bl > 1 && in_len > INT_MAX - bl) {
285 int i =
ctx->buf_len;
286 assert(bl <= (
int)
sizeof(
ctx->buf));
288 if (bl -
i > in_len) {
290 ctx->buf_len += in_len;
326 unsigned int i,
b, bl;
338 b =
ctx->cipher->block_size;
339 assert(
b <=
sizeof(
ctx->buf));
356 for (
i = bl;
i <
b;
i++) {
372 unsigned int b =
ctx->cipher->block_size;
373 if (
b > 1 && in_len > INT_MAX - (
int)
b) {
398 assert(
b <=
sizeof(
ctx->final));
400 if (
ctx->final_used) {
412 if (
b > 1 && !
ctx->buf_len) {
442 b =
ctx->cipher->block_size;
453 if (
ctx->buf_len || !
ctx->final_used) {
457 assert(
b <=
sizeof(
ctx->final));
461 n =
ctx->final[
b - 1];
462 if (
n == 0 ||
n > (
int)
b) {
467 for (
i = 0;
i <
n;
i++) {
468 if (
ctx->final[--
b] !=
n) {
474 n =
ctx->cipher->block_size -
n;
475 for (
i = 0;
i <
n;
i++) {
513 return ctx->cipher->nid;
521 return ctx->cipher->block_size;
529 return ctx->cipher->iv_len;
533 return ctx->app_data;
555 if (!
ctx->cipher->ctrl) {
579 if (
c->key_len == key_len) {
588 c->key_len = key_len;
unsigned EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx)
int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in)
unsigned EVP_CIPHER_iv_length(const EVP_CIPHER *cipher)
#define EVP_CIPH_VARIABLE_LENGTH
int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, const uint8_t *key, const uint8_t *iv)
int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, const uint8_t *key, const uint8_t *iv)
int EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx)
int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, uint8_t *out, int *out_len, const uint8_t *in, int in_len)
EVP_CIPHER_CTX * EVP_CIPHER_CTX_new(void)
void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx)
#define OPENSSL_PUT_ERROR(library, reason)
int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, uint8_t *out, int *out_len)
int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *engine, const uint8_t *key, const uint8_t *iv, int enc)
int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int command, int arg, void *ptr)
#define CIPHER_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH
int EVP_CIPHER_nid(const EVP_CIPHER *cipher)
#define CIPHER_R_CTRL_NOT_IMPLEMENTED
static struct test_ctx ctx
uint32_t EVP_CIPHER_CTX_mode(const EVP_CIPHER_CTX *ctx)
static int block_remainder(const EVP_CIPHER_CTX *ctx, int len)
int EVP_CIPHER_CTX_encrypting(const EVP_CIPHER_CTX *ctx)
static void * OPENSSL_memset(void *dst, int c, size_t n)
const EVP_CIPHER * EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx)
void * EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx)
uint32_t EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx)
#define EVP_CIPH_CTRL_INIT
unsigned EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx)
#define CIPHER_R_INPUT_NOT_INITIALIZED
int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *ctx)
#define EVP_CIPH_STREAM_CIPHER
int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, uint8_t *out, int *out_len)
void EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data)
int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *ctx, int pad)
static void * OPENSSL_memcpy(void *dst, const void *src, size_t n)
unsigned EVP_CIPHER_block_size(const EVP_CIPHER *cipher)
#define EVP_CIPH_MODE_MASK
#define EVP_CIPH_CUSTOM_COPY
#define CIPHER_R_CTRL_OPERATION_NOT_IMPLEMENTED
int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, const uint8_t *key, const uint8_t *iv)
uint32_t EVP_CIPHER_mode(const EVP_CIPHER *cipher)
#define EVP_CIPH_CBC_MODE
int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, uint8_t *out, int *out_len)
int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *c, unsigned key_len)
#define EVP_CIPH_NO_PADDING
#define EVP_CIPH_CFB_MODE
#define CIPHER_R_INVALID_KEY_LENGTH
void EVP_CIPHER_CTX_set_flags(const EVP_CIPHER_CTX *ctx, uint32_t flags)
#define CIPHER_R_NO_CIPHER_SET
int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, const uint8_t *key, const uint8_t *iv)
#define EVP_CIPH_FLAG_CUSTOM_CIPHER
#define EVP_CIPH_CTR_MODE
UniquePtr< SSL_SESSION > ret
int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *out_len)
unsigned EVP_CIPHER_key_length(const EVP_CIPHER *cipher)
#define EVP_CIPH_OFB_MODE
void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx)
int EVP_Cipher(EVP_CIPHER_CTX *ctx, uint8_t *out, const uint8_t *in, size_t in_len)
int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, const uint8_t *key, const uint8_t *iv, int enc)
int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, uint8_t *out, int *out_len, const uint8_t *in, int in_len)
unsigned EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx)
#define EVP_CIPH_ALWAYS_CALL_INIT
int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c)
#define CIPHER_R_WRONG_FINAL_BLOCK_LENGTH
uint32_t EVP_CIPHER_flags(const EVP_CIPHER *cipher)
#define OPENSSL_FALLTHROUGH
int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, uint8_t *out, int *out_len, const uint8_t *in, int in_len)
int EVP_add_cipher_alias(const char *a, const char *b)
#define ERR_R_MALLOC_FAILURE
#define EVP_CIPH_CUSTOM_IV
int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, uint8_t *out, int *out_len)
#define CIPHER_R_BAD_DECRYPT
int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, uint8_t *out, int *out_len)
#define CIPHER_R_INITIALIZATION_ERROR
#define EVP_CIPH_ECB_MODE
grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:58:45