sync with OpenBSD -current
This commit is contained in:
parent
77cffac7ea
commit
46994dfb53
76 changed files with 1061 additions and 927 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: e_aes_cbc_hmac_sha1.c,v 1.19 2023/07/07 19:37:53 beck Exp $ */
|
||||
/* $OpenBSD: e_aes_cbc_hmac_sha1.c,v 1.20 2024/01/08 09:31:09 tb Exp $ */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2011-2013 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
|
@ -541,7 +541,7 @@ aesni_cbc_hmac_sha1_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
|
|||
}
|
||||
}
|
||||
|
||||
static EVP_CIPHER aesni_128_cbc_hmac_sha1_cipher = {
|
||||
static const EVP_CIPHER aesni_128_cbc_hmac_sha1_cipher = {
|
||||
#ifdef NID_aes_128_cbc_hmac_sha1
|
||||
.nid = NID_aes_128_cbc_hmac_sha1,
|
||||
#else
|
||||
|
@ -558,7 +558,7 @@ static EVP_CIPHER aesni_128_cbc_hmac_sha1_cipher = {
|
|||
.ctrl = aesni_cbc_hmac_sha1_ctrl
|
||||
};
|
||||
|
||||
static EVP_CIPHER aesni_256_cbc_hmac_sha1_cipher = {
|
||||
static const EVP_CIPHER aesni_256_cbc_hmac_sha1_cipher = {
|
||||
#ifdef NID_aes_256_cbc_hmac_sha1
|
||||
.nid = NID_aes_256_cbc_hmac_sha1,
|
||||
#else
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: e_null.c,v 1.19 2024/01/04 17:38:36 tb Exp $ */
|
||||
/* $OpenBSD: e_null.c,v 1.20 2024/01/07 15:42:57 tb Exp $ */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@ -70,16 +70,18 @@ static int null_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
|||
const unsigned char *in, size_t inl);
|
||||
|
||||
static const EVP_CIPHER n_cipher = {
|
||||
NID_undef,
|
||||
1, 0, 0,
|
||||
0,
|
||||
null_init_key,
|
||||
null_cipher,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
.nid = NID_undef,
|
||||
.block_size = 1,
|
||||
.key_len = 0,
|
||||
.iv_len = 0,
|
||||
.flags = 0,
|
||||
.init = null_init_key,
|
||||
.do_cipher = null_cipher,
|
||||
.cleanup = NULL,
|
||||
.ctx_size = 0,
|
||||
.set_asn1_parameters = NULL,
|
||||
.get_asn1_parameters = NULL,
|
||||
.ctrl = NULL,
|
||||
};
|
||||
|
||||
const EVP_CIPHER *
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: e_rc2.c,v 1.26 2024/01/04 17:38:36 tb Exp $ */
|
||||
/* $OpenBSD: e_rc2.c,v 1.27 2024/01/07 15:42:57 tb Exp $ */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@ -248,29 +248,33 @@ EVP_rc2_ecb(void)
|
|||
#define RC2_128_MAGIC 0x3a
|
||||
|
||||
static const EVP_CIPHER r2_64_cbc_cipher = {
|
||||
NID_rc2_64_cbc,
|
||||
8, 8 /* 64 bit */, 8,
|
||||
EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT,
|
||||
rc2_init_key,
|
||||
rc2_cbc_cipher,
|
||||
NULL,
|
||||
sizeof(EVP_RC2_KEY),
|
||||
rc2_set_asn1_type_and_iv,
|
||||
rc2_get_asn1_type_and_iv,
|
||||
rc2_ctrl,
|
||||
.nid = NID_rc2_64_cbc,
|
||||
.block_size = 8,
|
||||
.key_len = 8,
|
||||
.iv_len = 8,
|
||||
.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT,
|
||||
.init = rc2_init_key,
|
||||
.do_cipher = rc2_cbc_cipher,
|
||||
.cleanup = NULL,
|
||||
.ctx_size = sizeof(EVP_RC2_KEY),
|
||||
.set_asn1_parameters = rc2_set_asn1_type_and_iv,
|
||||
.get_asn1_parameters = rc2_get_asn1_type_and_iv,
|
||||
.ctrl = rc2_ctrl,
|
||||
};
|
||||
|
||||
static const EVP_CIPHER r2_40_cbc_cipher = {
|
||||
NID_rc2_40_cbc,
|
||||
8, 5 /* 40 bit */, 8,
|
||||
EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT,
|
||||
rc2_init_key,
|
||||
rc2_cbc_cipher,
|
||||
NULL,
|
||||
sizeof(EVP_RC2_KEY),
|
||||
rc2_set_asn1_type_and_iv,
|
||||
rc2_get_asn1_type_and_iv,
|
||||
rc2_ctrl,
|
||||
.nid = NID_rc2_40_cbc,
|
||||
.block_size = 8,
|
||||
.key_len = 5,
|
||||
.iv_len = 8,
|
||||
.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT,
|
||||
.init = rc2_init_key,
|
||||
.do_cipher = rc2_cbc_cipher,
|
||||
.cleanup = NULL,
|
||||
.ctx_size = sizeof(EVP_RC2_KEY),
|
||||
.set_asn1_parameters = rc2_set_asn1_type_and_iv,
|
||||
.get_asn1_parameters = rc2_get_asn1_type_and_iv,
|
||||
.ctrl = rc2_ctrl,
|
||||
};
|
||||
|
||||
const EVP_CIPHER *
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: e_rc4.c,v 1.18 2024/01/04 17:38:36 tb Exp $ */
|
||||
/* $OpenBSD: e_rc4.c,v 1.19 2024/01/07 15:42:57 tb Exp $ */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@ -83,29 +83,33 @@ static int rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
|||
const unsigned char *in, size_t inl);
|
||||
|
||||
static const EVP_CIPHER r4_cipher = {
|
||||
NID_rc4,
|
||||
1, EVP_RC4_KEY_SIZE, 0,
|
||||
EVP_CIPH_VARIABLE_LENGTH,
|
||||
rc4_init_key,
|
||||
rc4_cipher,
|
||||
NULL,
|
||||
sizeof(EVP_RC4_KEY),
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
.nid = NID_rc4,
|
||||
.block_size = 1,
|
||||
.key_len = EVP_RC4_KEY_SIZE,
|
||||
.iv_len = 0,
|
||||
.flags = EVP_CIPH_VARIABLE_LENGTH,
|
||||
.init = rc4_init_key,
|
||||
.do_cipher = rc4_cipher,
|
||||
.cleanup = NULL,
|
||||
.ctx_size = sizeof(EVP_RC4_KEY),
|
||||
.set_asn1_parameters = NULL,
|
||||
.get_asn1_parameters = NULL,
|
||||
.ctrl = NULL,
|
||||
};
|
||||
|
||||
static const EVP_CIPHER r4_40_cipher = {
|
||||
NID_rc4_40,
|
||||
1, 5 /* 40 bit */, 0,
|
||||
EVP_CIPH_VARIABLE_LENGTH,
|
||||
rc4_init_key,
|
||||
rc4_cipher,
|
||||
NULL,
|
||||
sizeof(EVP_RC4_KEY),
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
.nid = NID_rc4_40,
|
||||
.block_size = 1,
|
||||
.key_len = 5,
|
||||
.iv_len = 0,
|
||||
.flags = EVP_CIPH_VARIABLE_LENGTH,
|
||||
.init = rc4_init_key,
|
||||
.do_cipher = rc4_cipher,
|
||||
.cleanup = NULL,
|
||||
.ctx_size = sizeof(EVP_RC4_KEY),
|
||||
.set_asn1_parameters = NULL,
|
||||
.get_asn1_parameters = NULL,
|
||||
.ctrl = NULL,
|
||||
};
|
||||
|
||||
const EVP_CIPHER *
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: e_rc4_hmac_md5.c,v 1.13 2024/01/04 17:38:36 tb Exp $ */
|
||||
/* $OpenBSD: e_rc4_hmac_md5.c,v 1.15 2024/01/07 16:18:18 tb Exp $ */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2011 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
|
@ -281,21 +281,23 @@ rc4_hmac_md5_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
|
|||
}
|
||||
}
|
||||
|
||||
static EVP_CIPHER r4_hmac_md5_cipher = {
|
||||
static const EVP_CIPHER r4_hmac_md5_cipher = {
|
||||
#ifdef NID_rc4_hmac_md5
|
||||
NID_rc4_hmac_md5,
|
||||
.nid = NID_rc4_hmac_md5,
|
||||
#else
|
||||
NID_undef,
|
||||
.nid = NID_undef,
|
||||
#endif
|
||||
1, EVP_RC4_KEY_SIZE, 0,
|
||||
EVP_CIPH_STREAM_CIPHER|EVP_CIPH_VARIABLE_LENGTH|EVP_CIPH_FLAG_AEAD_CIPHER,
|
||||
rc4_hmac_md5_init_key,
|
||||
rc4_hmac_md5_cipher,
|
||||
NULL,
|
||||
sizeof(EVP_RC4_HMAC_MD5),
|
||||
NULL,
|
||||
NULL,
|
||||
rc4_hmac_md5_ctrl,
|
||||
.block_size = 1,
|
||||
.key_len = EVP_RC4_KEY_SIZE,
|
||||
.iv_len = 0,
|
||||
.flags = EVP_CIPH_STREAM_CIPHER|EVP_CIPH_VARIABLE_LENGTH|EVP_CIPH_FLAG_AEAD_CIPHER,
|
||||
.init = rc4_hmac_md5_init_key,
|
||||
.do_cipher = rc4_hmac_md5_cipher,
|
||||
.cleanup = NULL,
|
||||
.ctx_size = sizeof(EVP_RC4_HMAC_MD5),
|
||||
.set_asn1_parameters = NULL,
|
||||
.get_asn1_parameters = NULL,
|
||||
.ctrl = rc4_hmac_md5_ctrl,
|
||||
};
|
||||
|
||||
const EVP_CIPHER *
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: e_xcbc_d.c,v 1.16 2024/01/04 17:38:36 tb Exp $ */
|
||||
/* $OpenBSD: e_xcbc_d.c,v 1.17 2024/01/07 15:42:57 tb Exp $ */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@ -84,16 +84,18 @@ typedef struct {
|
|||
#define data(ctx) ((DESX_CBC_KEY *)(ctx)->cipher_data)
|
||||
|
||||
static const EVP_CIPHER d_xcbc_cipher = {
|
||||
NID_desx_cbc,
|
||||
8, 24, 8,
|
||||
EVP_CIPH_CBC_MODE,
|
||||
desx_cbc_init_key,
|
||||
desx_cbc_cipher,
|
||||
NULL,
|
||||
sizeof(DESX_CBC_KEY),
|
||||
EVP_CIPHER_set_asn1_iv,
|
||||
EVP_CIPHER_get_asn1_iv,
|
||||
NULL,
|
||||
.nid = NID_desx_cbc,
|
||||
.block_size = 8,
|
||||
.key_len = 24,
|
||||
.iv_len = 8,
|
||||
.flags = EVP_CIPH_CBC_MODE,
|
||||
.init = desx_cbc_init_key,
|
||||
.do_cipher = desx_cbc_cipher,
|
||||
.cleanup = NULL,
|
||||
.ctx_size = sizeof(DESX_CBC_KEY),
|
||||
.set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
|
||||
.get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
|
||||
.ctrl = NULL,
|
||||
};
|
||||
|
||||
const EVP_CIPHER *
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $OpenBSD: evp_cipher.c,v 1.15 2024/01/04 09:47:54 tb Exp $ */
|
||||
/* $OpenBSD: evp_cipher.c,v 1.16 2024/01/07 15:21:04 tb Exp $ */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@ -902,22 +902,23 @@ EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx)
|
|||
int
|
||||
EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type)
|
||||
{
|
||||
int i = 0;
|
||||
int l;
|
||||
int iv_len;
|
||||
|
||||
if (type != NULL) {
|
||||
l = EVP_CIPHER_CTX_iv_length(ctx);
|
||||
if (l < 0 || l > sizeof(ctx->oiv) || l > sizeof(ctx->iv)) {
|
||||
EVPerror(EVP_R_IV_TOO_LARGE);
|
||||
return 0;
|
||||
}
|
||||
i = ASN1_TYPE_get_octetstring(type, ctx->oiv, l);
|
||||
if (i != l)
|
||||
return (-1);
|
||||
else if (i > 0)
|
||||
memcpy(ctx->iv, ctx->oiv, l);
|
||||
if (type == NULL)
|
||||
return 0;
|
||||
|
||||
iv_len = EVP_CIPHER_CTX_iv_length(ctx);
|
||||
if (iv_len < 0 || iv_len > sizeof(ctx->oiv) || iv_len > sizeof(ctx->iv)) {
|
||||
EVPerror(EVP_R_IV_TOO_LARGE);
|
||||
return 0; /* XXX */
|
||||
}
|
||||
return (i);
|
||||
if (ASN1_TYPE_get_octetstring(type, ctx->oiv, iv_len) != iv_len)
|
||||
return -1;
|
||||
|
||||
if (iv_len > 0)
|
||||
memcpy(ctx->iv, ctx->oiv, iv_len);
|
||||
|
||||
return iv_len;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -935,18 +936,18 @@ EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type)
|
|||
int
|
||||
EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type)
|
||||
{
|
||||
int i = 0;
|
||||
int j;
|
||||
int iv_len;
|
||||
|
||||
if (type != NULL) {
|
||||
j = EVP_CIPHER_CTX_iv_length(ctx);
|
||||
if (j < 0 || j > sizeof(ctx->oiv)) {
|
||||
EVPerror(EVP_R_IV_TOO_LARGE);
|
||||
return 0;
|
||||
}
|
||||
i = ASN1_TYPE_set_octetstring(type, ctx->oiv, j);
|
||||
if (type == NULL)
|
||||
return 0;
|
||||
|
||||
iv_len = EVP_CIPHER_CTX_iv_length(ctx);
|
||||
if (iv_len < 0 || iv_len > sizeof(ctx->oiv)) {
|
||||
EVPerror(EVP_R_IV_TOO_LARGE);
|
||||
return 0;
|
||||
}
|
||||
return (i);
|
||||
|
||||
return ASN1_TYPE_set_octetstring(type, ctx->oiv, iv_len);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue