Update Patch

This commit is contained in:
2019-03-10 01:02:11 +09:00
parent 1f0a65b72a
commit 9f21151c15
5 changed files with 853 additions and 314 deletions
+48 -58
View File
@@ -11,10 +11,10 @@ index a97eaa1685..24112723f0 100644
#endif
}
diff --git a/crypto/evp/e_chacha20_poly1305.c b/crypto/evp/e_chacha20_poly1305.c
index e8a323f3be..9b1b36f832 100644
index 37902000a0..56832b63a0 100644
--- a/crypto/evp/e_chacha20_poly1305.c
+++ b/crypto/evp/e_chacha20_poly1305.c
@@ -154,6 +154,7 @@ typedef struct {
@@ -156,6 +156,7 @@ typedef struct {
struct { uint64_t aad, text; } len;
int aad, mac_inited, tag_len, nonce_len;
size_t tls_payload_length;
@@ -22,7 +22,7 @@ index e8a323f3be..9b1b36f832 100644
} EVP_CHACHA_AEAD_CTX;
# define NO_TLS_PAYLOAD_LENGTH ((size_t)-1)
@@ -174,6 +175,7 @@ static int chacha20_poly1305_init_key(EVP_CIPHER_CTX *ctx,
@@ -176,6 +177,7 @@ static int chacha20_poly1305_init_key(EVP_CIPHER_CTX *ctx,
actx->aad = 0;
actx->mac_inited = 0;
actx->tls_payload_length = NO_TLS_PAYLOAD_LENGTH;
@@ -30,7 +30,7 @@ index e8a323f3be..9b1b36f832 100644
if (iv != NULL) {
unsigned char temp[CHACHA_CTR_SIZE] = { 0 };
@@ -195,6 +197,27 @@ static int chacha20_poly1305_init_key(EVP_CIPHER_CTX *ctx,
@@ -197,6 +199,27 @@ static int chacha20_poly1305_init_key(EVP_CIPHER_CTX *ctx,
return 1;
}
@@ -58,7 +58,7 @@ index e8a323f3be..9b1b36f832 100644
# if !defined(OPENSSL_SMALL_FOOTPRINT)
# if defined(POLY1305_ASM) && (defined(__x86_64) || defined(__x86_64__) || \
@@ -365,10 +388,11 @@ static int chacha20_poly1305_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
@@ -367,10 +390,11 @@ static int chacha20_poly1305_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
{
EVP_CHACHA_AEAD_CTX *actx = aead_data(ctx);
size_t rem, plen = actx->tls_payload_length;
@@ -71,7 +71,7 @@ index e8a323f3be..9b1b36f832 100644
return chacha20_poly1305_tls_cipher(ctx, out, in, len);
# endif
actx->key.counter[0] = 0;
@@ -395,9 +419,14 @@ static int chacha20_poly1305_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
@@ -397,9 +421,14 @@ static int chacha20_poly1305_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
return len;
} else { /* plain- or ciphertext */
if (actx->aad) { /* wrap up aad */
@@ -89,7 +89,7 @@ index e8a323f3be..9b1b36f832 100644
actx->aad = 0;
}
@@ -430,40 +459,52 @@ static int chacha20_poly1305_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
@@ -432,40 +461,52 @@ static int chacha20_poly1305_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
} is_endian = { 1 };
unsigned char temp[POLY1305_BLOCK_SIZE];
@@ -171,12 +171,12 @@ index e8a323f3be..9b1b36f832 100644
}
Poly1305_Final(POLY1305_ctx(actx), ctx->encrypt ? actx->tag
: temp);
@@ -533,12 +574,14 @@ static int chacha20_poly1305_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg,
@@ -535,12 +576,14 @@ static int chacha20_poly1305_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg,
return 1;
case EVP_CTRL_AEAD_SET_IVLEN:
+ if (actx->draft) return -1;
if (arg <= 0 || arg > CHACHA_CTR_SIZE)
if (arg <= 0 || arg > CHACHA20_POLY1305_MAX_IVLEN)
return 0;
actx->nonce_len = arg;
return 1;
@@ -186,7 +186,7 @@ index e8a323f3be..9b1b36f832 100644
if (arg != 12)
return 0;
actx->nonce[0] = actx->key.counter[1]
@@ -622,9 +665,32 @@ static EVP_CIPHER chacha20_poly1305 = {
@@ -624,9 +667,32 @@ static EVP_CIPHER chacha20_poly1305 = {
NULL /* app_data */
};
@@ -220,66 +220,66 @@ index e8a323f3be..9b1b36f832 100644
# endif
#endif
diff --git a/crypto/objects/obj_dat.h b/crypto/objects/obj_dat.h
index 78a9e7acaf..134d7b8c70 100644
index e7c59d610d..7ba1ecdacf 100644
--- a/crypto/objects/obj_dat.h
+++ b/crypto/objects/obj_dat.h
@@ -1079,7 +1079,7 @@ static const unsigned char so[7767] = {
0x28,0xCC,0x45,0x03,0x04, /* [ 7761] OBJ_gmac */
};
-#define NUM_NID 1203
+#define NUM_NID 1204
-#define NUM_NID 1204
+#define NUM_NID 1205
static const ASN1_OBJECT nid_objs[NUM_NID] = {
{"UNDEF", "undefined", NID_undef},
{"rsadsi", "RSA Data Security, Inc.", NID_rsadsi, 6, &so[0]},
@@ -2284,9 +2284,10 @@ static const ASN1_OBJECT nid_objs[NUM_NID] = {
{"AES-256-SIV", "aes-256-siv", NID_aes_256_siv},
@@ -2285,9 +2285,10 @@ static const ASN1_OBJECT nid_objs[NUM_NID] = {
{"BLAKE2BMAC", "blake2bmac", NID_blake2bmac},
{"BLAKE2SMAC", "blake2smac", NID_blake2smac},
{"SSHKDF", "sshkdf", NID_sshkdf},
+ {"ChaCha20-Poly1305-D", "chacha20-poly1305-draft", NID_chacha20_poly1305_draft},
};
-#define NUM_SN 1194
+#define NUM_SN 1195
-#define NUM_SN 1195
+#define NUM_SN 1196
static const unsigned int sn_objs[NUM_SN] = {
364, /* "AD_DVCS" */
419, /* "AES-128-CBC" */
@@ -2409,6 +2410,7 @@ static const unsigned int sn_objs[NUM_SN] = {
@@ -2410,6 +2411,7 @@ static const unsigned int sn_objs[NUM_SN] = {
417, /* "CSPName" */
1019, /* "ChaCha20" */
1018, /* "ChaCha20-Poly1305" */
+ 1203, /* "ChaCha20-Poly1305-D" */
+ 1204, /* "ChaCha20-Poly1305-D" */
367, /* "CrlID" */
391, /* "DC" */
31, /* "DES-CBC" */
@@ -3484,7 +3486,7 @@ static const unsigned int sn_objs[NUM_SN] = {
@@ -3486,7 +3488,7 @@ static const unsigned int sn_objs[NUM_SN] = {
1093, /* "x509ExtAdmission" */
};
-#define NUM_LN 1194
+#define NUM_LN 1195
-#define NUM_LN 1195
+#define NUM_LN 1196
static const unsigned int ln_objs[NUM_LN] = {
363, /* "AD Time Stamping" */
405, /* "ANSI X9.62" */
@@ -3868,6 +3870,7 @@ static const unsigned int ln_objs[NUM_LN] = {
@@ -3870,6 +3872,7 @@ static const unsigned int ln_objs[NUM_LN] = {
883, /* "certificateRevocationList" */
1019, /* "chacha20" */
1018, /* "chacha20-poly1305" */
+ 1203, /* "chacha20-poly1305-draft" */
+ 1204, /* "chacha20-poly1305-draft" */
54, /* "challengePassword" */
407, /* "characteristic-two-field" */
395, /* "clearance" */
diff --git a/crypto/objects/obj_mac.num b/crypto/objects/obj_mac.num
index 87790200d4..94d033c158 100644
index 623e7e8623..0818547548 100644
--- a/crypto/objects/obj_mac.num
+++ b/crypto/objects/obj_mac.num
@@ -1200,3 +1200,4 @@ aes_192_siv 1199
aes_256_siv 1200
@@ -1201,3 +1201,4 @@ aes_256_siv 1200
blake2bmac 1201
blake2smac 1202
+chacha20_poly1305_draft 1203
sshkdf 1203
+chacha20_poly1305_draft 1204
diff --git a/crypto/objects/objects.txt b/crypto/objects/objects.txt
index 344b67b395..21653d9b87 100644
index cb0b99c47f..d480bd3800 100644
--- a/crypto/objects/objects.txt
+++ b/crypto/objects/objects.txt
@@ -1543,6 +1543,7 @@ sm-scheme 104 7 : SM4-CTR : sm4-ctr
@@ -291,10 +291,10 @@ index 344b67b395..21653d9b87 100644
ISO-US 10046 2 1 : dhpublicnumber : X9.42 DH
diff --git a/include/openssl/evp.h b/include/openssl/evp.h
index 23f07eaa05..c90c6435bd 100644
index 72060e7e96..125bc1c425 100644
--- a/include/openssl/evp.h
+++ b/include/openssl/evp.h
@@ -928,6 +928,7 @@ const EVP_CIPHER *EVP_camellia_256_ctr(void);
@@ -924,6 +924,7 @@ const EVP_CIPHER *EVP_camellia_256_ctr(void);
const EVP_CIPHER *EVP_chacha20(void);
# ifndef OPENSSL_NO_POLY1305
const EVP_CIPHER *EVP_chacha20_poly1305(void);
@@ -303,7 +303,7 @@ index 23f07eaa05..c90c6435bd 100644
# endif
diff --git a/include/openssl/obj_mac.h b/include/openssl/obj_mac.h
index 97b2204ba6..fc254cfa61 100644
index 80353ad4d7..e525a04b2c 100644
--- a/include/openssl/obj_mac.h
+++ b/include/openssl/obj_mac.h
@@ -4828,6 +4828,10 @@
@@ -312,13 +312,13 @@ index 97b2204ba6..fc254cfa61 100644
+#define SN_chacha20_poly1305_draft "ChaCha20-Poly1305-D"
+#define LN_chacha20_poly1305_draft "chacha20-poly1305-draft"
+#define NID_chacha20_poly1305_draft 1203
+#define NID_chacha20_poly1305_draft 1204
+
#define SN_chacha20 "ChaCha20"
#define LN_chacha20 "chacha20"
#define NID_chacha20 1019
diff --git a/include/openssl/ssl.h b/include/openssl/ssl.h
index 9d6e1c5024..5692cfab31 100644
index 1091b1c8b9..fcfc428cd1 100644
--- a/include/openssl/ssl.h
+++ b/include/openssl/ssl.h
@@ -125,6 +125,7 @@ extern "C" {
@@ -372,10 +372,10 @@ index 166f15ad5c..4fa1d8a32d 100644
# define TLS1_TXT_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 "ECDHE-ECDSA-CHACHA20-POLY1305"
# define TLS1_TXT_DHE_RSA_WITH_CHACHA20_POLY1305 "DHE-RSA-CHACHA20-POLY1305"
diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c
index a5b3dbbfd5..a5a7993065 100644
index a3639fd18c..c13137e1af 100644
--- a/ssl/s3_lib.c
+++ b/ssl/s3_lib.c
@@ -2082,6 +2082,54 @@ static SSL_CIPHER ssl3_ciphers[] = {
@@ -2083,6 +2083,54 @@ static SSL_CIPHER ssl3_ciphers[] = {
256,
256,
},
@@ -431,10 +431,10 @@ index a5b3dbbfd5..a5a7993065 100644
1,
TLS1_TXT_PSK_WITH_CHACHA20_POLY1305,
diff --git a/ssl/ssl_ciph.c b/ssl/ssl_ciph.c
index 461a9debab..84f90c1621 100644
index 5aa04dbd53..71094c195e 100644
--- a/ssl/ssl_ciph.c
+++ b/ssl/ssl_ciph.c
@@ -43,7 +43,8 @@
@@ -44,7 +44,8 @@
#define SSL_ENC_CHACHA_IDX 19
#define SSL_ENC_ARIA128GCM_IDX 20
#define SSL_ENC_ARIA256GCM_IDX 21
@@ -444,7 +444,7 @@ index 461a9debab..84f90c1621 100644
/* NB: make sure indices in these tables match values above */
@@ -76,6 +77,7 @@ static const ssl_cipher_table ssl_cipher_table_cipher[SSL_ENC_NUM_IDX] = {
@@ -77,6 +78,7 @@ static const ssl_cipher_table ssl_cipher_table_cipher[SSL_ENC_NUM_IDX] = {
{SSL_CHACHA20POLY1305, NID_chacha20_poly1305}, /* SSL_ENC_CHACHA_IDX 19 */
{SSL_ARIA128GCM, NID_aria_128_gcm}, /* SSL_ENC_ARIA128GCM_IDX 20 */
{SSL_ARIA256GCM, NID_aria_256_gcm}, /* SSL_ENC_ARIA256GCM_IDX 21 */
@@ -452,7 +452,7 @@ index 461a9debab..84f90c1621 100644
};
static const EVP_CIPHER *ssl_cipher_methods[SSL_ENC_NUM_IDX];
@@ -275,6 +277,7 @@ static const SSL_CIPHER cipher_aliases[] = {
@@ -276,6 +278,7 @@ static const SSL_CIPHER cipher_aliases[] = {
{0, SSL_TXT_CAMELLIA256, NULL, 0, 0, 0, SSL_CAMELLIA256},
{0, SSL_TXT_CAMELLIA, NULL, 0, 0, 0, SSL_CAMELLIA},
{0, SSL_TXT_CHACHA20, NULL, 0, 0, 0, SSL_CHACHA20},
@@ -460,17 +460,7 @@ index 461a9debab..84f90c1621 100644
{0, SSL_TXT_ARIA, NULL, 0, 0, 0, SSL_ARIA},
{0, SSL_TXT_ARIA_GCM, NULL, 0, 0, 0, SSL_ARIA128GCM | SSL_ARIA256GCM},
@@ -1791,6 +1794,9 @@ char *SSL_CIPHER_description(const SSL_CIPHER *cipher, char *buf, int len)
case SSL_CHACHA20POLY1305:
enc = "CHACHA20/POLY1305(256)";
break;
+ case SSL_CHACHA20POLY1305_D:
+ enc = "CHACHA20/POLY1305-Draft(256)";
+ break;
default:
enc = "unknown";
break;
@@ -2115,7 +2121,7 @@ int ssl_cipher_get_overhead(const SSL_CIPHER *c, size_t *mac_overhead,
@@ -2122,7 +2125,7 @@ int ssl_cipher_get_overhead(const SSL_CIPHER *c, size_t *mac_overhead,
out = EVP_CCM_TLS_EXPLICIT_IV_LEN + 16;
} else if (c->algorithm_enc & (SSL_AES128CCM8 | SSL_AES256CCM8)) {
out = EVP_CCM_TLS_EXPLICIT_IV_LEN + 8;
@@ -480,7 +470,7 @@ index 461a9debab..84f90c1621 100644
} else if (c->algorithm_mac & SSL_AEAD) {
/* We're supposed to have handled all the AEAD modes above */
diff --git a/ssl/ssl_locl.h b/ssl/ssl_locl.h
index ae6417b592..c783031ea2 100644
index 1d3397d880..d5ff8520b6 100644
--- a/ssl/ssl_locl.h
+++ b/ssl/ssl_locl.h
@@ -234,12 +234,13 @@
@@ -499,11 +489,11 @@ index ae6417b592..c783031ea2 100644
# define SSL_ARIA (SSL_ARIAGCM)
diff --git a/util/libcrypto.num b/util/libcrypto.num
index 9957cf80f6..21ea627067 100644
index cb0cb2279b..a5829966e7 100644
--- a/util/libcrypto.num
+++ b/util/libcrypto.num
@@ -4646,3 +4646,4 @@ OPENSSL_CTX_free 4601 3_0_0 EXIST::FUNCTION:
OPENSSL_LH_flush 4602 3_0_0 EXIST::FUNCTION:
BN_native2bn 4603 3_0_0 EXIST::FUNCTION:
BN_bn2nativepad 4604 3_0_0 EXIST::FUNCTION:
+EVP_chacha20_poly1305_draft 4605 3_0_0 EXIST::FUNCTION:CHACHA,POLY1305
@@ -4655,3 +4655,4 @@ OSSL_trace_set_callback 4610 3_0_0 EXIST::FUNCTION:
OSSL_trace_enabled 4611 3_0_0 EXIST::FUNCTION:
OSSL_trace_begin 4612 3_0_0 EXIST::FUNCTION:
OSSL_trace_end 4613 3_0_0 EXIST::FUNCTION:
+EVP_chacha20_poly1305_draft 4614 3_0_0 EXIST::FUNCTION:CHACHA,POLY1305