-/* $OpenBSD: evp_cipher.c,v 1.10 2024/01/02 20:48:40 tb Exp $ */
+/* $OpenBSD: evp_cipher.c,v 1.11 2024/01/02 21:12:25 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
return 1;
}
-int
-EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx)
-{
- return ctx->cipher->block_size;
-}
-
const EVP_CIPHER *
EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx)
{
return ctx->encrypt;
}
-unsigned long
-EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx)
-{
- return ctx->cipher->flags;
-}
-
void *
EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx)
{
return old_cipher_data;
}
-int
-EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx)
-{
- int iv_length = 0;
-
- if ((ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_IV_LENGTH) == 0)
- return ctx->cipher->iv_len;
-
- /*
- * XXX - sanity would suggest to pass the size of the pointer along,
- * but unfortunately we have to match the other crowd.
- */
- if (EVP_CIPHER_CTX_ctrl((EVP_CIPHER_CTX *)ctx, EVP_CTRL_GET_IVLEN, 0,
- &iv_length) != 1)
- return -1;
-
- return iv_length;
-}
-
unsigned char *
EVP_CIPHER_CTX_buf_noconst(EVP_CIPHER_CTX *ctx)
{
return ctx->key_len;
}
-int
-EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx)
-{
- return ctx->cipher->nid;
-}
-
int
EVP_CIPHER_CTX_get_iv(const EVP_CIPHER_CTX *ctx, unsigned char *iv, size_t len)
{
return (ctx->flags & flags);
}
+/*
+ * EVP_CIPHER_CTX getters that reach into the cipher attachted to the contex.
+ */
+
+int
+EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx)
+{
+ return ctx->cipher->nid;
+}
+
+int
+EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx)
+{
+ return ctx->cipher->block_size;
+}
+
+int
+EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx)
+{
+ int iv_length = 0;
+
+ if ((ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_IV_LENGTH) == 0)
+ return ctx->cipher->iv_len;
+
+ /*
+ * XXX - sanity would suggest to pass the size of the pointer along,
+ * but unfortunately we have to match the other crowd.
+ */
+ if (EVP_CIPHER_CTX_ctrl((EVP_CIPHER_CTX *)ctx, EVP_CTRL_GET_IVLEN, 0,
+ &iv_length) != 1)
+ return -1;
+
+ return iv_length;
+}
+
+unsigned long
+EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx)
+{
+ return ctx->cipher->flags;
+}
+
/*
* Used by CMS and its predecessors. Only GOST and RC2 have a custom method.
*/