-/* $OpenBSD: e_bf.c,v 1.11 2022/09/04 13:55:39 jsing Exp $ */
+/* $OpenBSD: e_bf.c,v 1.12 2022/09/04 15:45:25 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* [including the GNU Public Licence.]
*/
+#include <limits.h>
#include <stdio.h>
#include <openssl/opensslconf.h>
static int
bf_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl)
{
+ if (inl > LONG_MAX)
+ return 0;
+
while (inl >= EVP_MAXCHUNK) {
BF_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &((EVP_BF_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt);
inl -= EVP_MAXCHUNK;
{
size_t chunk = EVP_MAXCHUNK;
+ if (inl > LONG_MAX)
+ return 0;
+
if (inl < chunk)
chunk = inl;
{
size_t i, bl;
+ if (inl > LONG_MAX)
+ return 0;
+
bl = ctx->cipher->block_size;
if (inl < bl)
static int
bf_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl)
{
+ if (inl > LONG_MAX)
+ return 0;
+
while (inl >= EVP_MAXCHUNK) {
BF_ofb64_encrypt(in, out, (long)EVP_MAXCHUNK, &((EVP_BF_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num);
inl -= EVP_MAXCHUNK;
-/* $OpenBSD: e_cast.c,v 1.10 2022/09/04 13:55:39 jsing Exp $ */
+/* $OpenBSD: e_cast.c,v 1.11 2022/09/04 15:45:25 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* [including the GNU Public Licence.]
*/
+#include <limits.h>
#include <stdio.h>
#include <openssl/opensslconf.h>
static int
cast5_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl)
{
+ if (inl > LONG_MAX)
+ return 0;
+
while (inl >= EVP_MAXCHUNK) {
CAST_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &((EVP_CAST_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt);
inl -= EVP_MAXCHUNK;
{
size_t chunk = EVP_MAXCHUNK;
+ if (inl > LONG_MAX)
+ return 0;
+
if (inl < chunk)
chunk = inl;
{
size_t i, bl;
+ if (inl > LONG_MAX)
+ return 0;
+
bl = ctx->cipher->block_size;
if (inl < bl)
static int
cast5_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl)
{
+ if (inl > LONG_MAX)
+ return 0;
+
while (inl >= EVP_MAXCHUNK) {
CAST_ofb64_encrypt(in, out, (long)EVP_MAXCHUNK, &((EVP_CAST_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num);
inl -= EVP_MAXCHUNK;
-/* $OpenBSD: e_des.c,v 1.17 2022/09/04 13:17:18 jsing Exp $ */
+/* $OpenBSD: e_des.c,v 1.18 2022/09/04 15:45:25 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* [including the GNU Public Licence.]
*/
+#include <limits.h>
#include <stdio.h>
#include <openssl/opensslconf.h>
{
size_t i, bl;
+ if (inl > LONG_MAX)
+ return 0;
+
bl = ctx->cipher->block_size;
if (inl < bl)
for (i = 0; i <= inl; i += bl)
DES_ecb_encrypt((DES_cblock *)(in + i), (DES_cblock *)(out + i),
ctx->cipher_data, ctx->encrypt);
+
return 1;
}
des_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, size_t inl)
{
+ if (inl > LONG_MAX)
+ return 0;
+
while (inl >= EVP_MAXCHUNK) {
DES_ofb64_encrypt(in, out, (long)EVP_MAXCHUNK, ctx->cipher_data,
(DES_cblock *)ctx->iv, &ctx->num);
des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, size_t inl)
{
+ if (inl > LONG_MAX)
+ return 0;
+
while (inl >= EVP_MAXCHUNK) {
DES_ncbc_encrypt(in, out, (long)EVP_MAXCHUNK, ctx->cipher_data,
(DES_cblock *)ctx->iv, ctx->encrypt);
des_cfb64_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, size_t inl)
{
+ if (inl > LONG_MAX)
+ return 0;
+
while (inl >= EVP_MAXCHUNK) {
DES_cfb64_encrypt(in, out, (long)EVP_MAXCHUNK, ctx->cipher_data,
(DES_cblock *)ctx->iv, &ctx->num, ctx->encrypt);
size_t n, chunk = EVP_MAXCHUNK/8;
unsigned char c[1], d[1];
+ if (inl > LONG_MAX)
+ return 0;
+
if (inl < chunk)
chunk = inl;
des_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, size_t inl)
{
+ if (inl > LONG_MAX)
+ return 0;
+
while (inl >= EVP_MAXCHUNK) {
DES_cfb_encrypt(in, out, 8, (long)EVP_MAXCHUNK,
ctx->cipher_data, (DES_cblock *)ctx->iv, ctx->encrypt);
-/* $OpenBSD: e_des3.c,v 1.23 2022/09/04 13:17:18 jsing Exp $ */
+/* $OpenBSD: e_des3.c,v 1.24 2022/09/04 15:45:25 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* [including the GNU Public Licence.]
*/
+#include <limits.h>
#include <stdio.h>
#include <string.h>
{
size_t i, bl;
+ if (inl > LONG_MAX)
+ return 0;
+
bl = ctx->cipher->block_size;
if (inl < bl)
des_ede_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, size_t inl)
{
+ if (inl > LONG_MAX)
+ return 0;
+
while (inl >= EVP_MAXCHUNK) {
DES_ede3_ofb64_encrypt(in, out, (long)EVP_MAXCHUNK,
&data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3,
des_ede_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, size_t inl)
{
+ if (inl > LONG_MAX)
+ return 0;
+
while (inl >= EVP_MAXCHUNK) {
DES_ede3_cbc_encrypt(in, out, (long)EVP_MAXCHUNK,
&data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3,
des_ede_cfb64_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, size_t inl)
{
+ if (inl > LONG_MAX)
+ return 0;
+
while (inl >= EVP_MAXCHUNK) {
DES_ede3_cfb64_encrypt(in, out, (long)EVP_MAXCHUNK,
&data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3,
{
size_t n;
unsigned char c[1], d[1];
+
+ if (inl > LONG_MAX)
+ return 0;
+
if (!(ctx->flags & EVP_CIPH_FLAG_LENGTH_BITS))
inl *= 8;
des_ede3_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, size_t inl)
{
+ if (inl > LONG_MAX)
+ return 0;
+
while (inl >= EVP_MAXCHUNK) {
DES_ede3_cfb_encrypt(in, out, 8, (long)EVP_MAXCHUNK,
&data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3,
-/* $OpenBSD: e_idea.c,v 1.14 2022/09/04 13:55:39 jsing Exp $ */
+/* $OpenBSD: e_idea.c,v 1.15 2022/09/04 15:45:25 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* [including the GNU Public Licence.]
*/
+#include <limits.h>
#include <stdio.h>
#include <string.h>
{
size_t i, bl;
+ if (inl > LONG_MAX)
+ return 0;
+
bl = ctx->cipher->block_size;
if (inl < bl)
static int
idea_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl)
{
+ if (inl > LONG_MAX)
+ return 0;
+
while (inl >= EVP_MAXCHUNK) {
idea_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &((EVP_IDEA_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt);
inl -= EVP_MAXCHUNK;
static int
idea_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl)
{
+ if (inl > LONG_MAX)
+ return 0;
+
while (inl >= EVP_MAXCHUNK) {
idea_ofb64_encrypt(in, out, (long)EVP_MAXCHUNK, &((EVP_IDEA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num);
inl -= EVP_MAXCHUNK;
{
size_t chunk = EVP_MAXCHUNK;
+ if (inl > LONG_MAX)
+ return 0;
+
if (inl < chunk)
chunk = inl;
return 1;
}
-
static const EVP_CIPHER idea_cbc = {
.nid = NID_idea_cbc,
.block_size = 8,
-/* $OpenBSD: e_rc2.c,v 1.16 2022/09/04 13:55:39 jsing Exp $ */
+/* $OpenBSD: e_rc2.c,v 1.17 2022/09/04 15:45:25 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* [including the GNU Public Licence.]
*/
+#include <limits.h>
#include <stdio.h>
#include <openssl/opensslconf.h>
static int
rc2_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl)
{
+ if (inl > LONG_MAX)
+ return 0;
+
while (inl >= EVP_MAXCHUNK) {
RC2_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &((EVP_RC2_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt);
inl -= EVP_MAXCHUNK;
{
size_t chunk = EVP_MAXCHUNK;
+ if (inl > LONG_MAX)
+ return 0;
+
if (inl < chunk)
chunk = inl;
{
size_t i, bl;
+ if (inl > LONG_MAX)
+ return 0;
+
bl = ctx->cipher->block_size;
if (inl < bl)
static int
rc2_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl)
{
+ if (inl > LONG_MAX)
+ return 0;
+
while (inl >= EVP_MAXCHUNK) {
RC2_ofb64_encrypt(in, out, (long)EVP_MAXCHUNK, &((EVP_RC2_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num);
inl -= EVP_MAXCHUNK;