summaryrefslogtreecommitdiffstats
path: root/ssl
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2017-02-06 16:52:38 +0000
committerMatt Caswell <matt@openssl.org>2017-02-14 13:14:25 +0000
commit0dd7ba24e835fc66afc4997b376bc2a5e1f03992 (patch)
tree515c90aa3361e697221e13e33d47fe458b174257 /ssl
parent2248dbebeeedd77f08d67e3dcd9031f6c1f0894f (diff)
Add a bytestogroup macro
For converting the 2 byte group id into an unsigned int. Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2341)
Diffstat (limited to 'ssl')
-rw-r--r--ssl/ssl_locl.h3
-rw-r--r--ssl/statem/extensions.c2
-rw-r--r--ssl/statem/extensions_clnt.c4
3 files changed, 6 insertions, 3 deletions
diff --git a/ssl/ssl_locl.h b/ssl/ssl_locl.h
index 099f8ccadc..df6be646e1 100644
--- a/ssl/ssl_locl.h
+++ b/ssl/ssl_locl.h
@@ -2194,6 +2194,9 @@ SSL_COMP *ssl3_comp_find(STACK_OF(SSL_COMP) *sk, int n);
# define TLS_CURVE_PRIME 0x0
# define TLS_CURVE_CHAR2 0x1
# define TLS_CURVE_CUSTOM 0x2
+
+#define bytestogroup(bytes) ((unsigned int)(bytes[0] << 8 | bytes[1]))
+
__owur int tls1_ec_curve_id2nid(int curve_id, unsigned int *pflags);
__owur int tls1_ec_nid2curve_id(int nid);
__owur int tls1_check_curve(SSL *s, const unsigned char *p, size_t len);
diff --git a/ssl/statem/extensions.c b/ssl/statem/extensions.c
index 8d08b0cf4c..99326b2b55 100644
--- a/ssl/statem/extensions.c
+++ b/ssl/statem/extensions.c
@@ -1039,7 +1039,7 @@ static int final_key_share(SSL *s, unsigned int context, int sent, int *al)
/* Find the first group we allow that is also in client's list */
for (i = 0, pcurvestmp = pcurves; i < num_curves;
i++, pcurvestmp += 2) {
- group_id = pcurvestmp[0] << 8 | pcurvestmp[1];
+ group_id = bytestogroup(pcurvestmp);
if (check_in_list(s, group_id, clntcurves, clnt_num_curves, 1))
break;
diff --git a/ssl/statem/extensions_clnt.c b/ssl/statem/extensions_clnt.c
index 01a80a0755..ea379199e0 100644
--- a/ssl/statem/extensions_clnt.c
+++ b/ssl/statem/extensions_clnt.c
@@ -614,7 +614,7 @@ int tls_construct_ctos_key_share(SSL *s, WPACKET *pkt, unsigned int context,
if (!tls_curve_allowed(s, pcurves, SSL_SECOP_CURVE_SUPPORTED))
continue;
- curve_id = (pcurves[0] << 8) | pcurves[1];
+ curve_id = bytestogroup(pcurves);
break;
}
}
@@ -1235,7 +1235,7 @@ int tls_parse_stoc_key_share(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
return 0;
}
for (i = 0; i < num_curves; i++, pcurves += 2) {
- if (group_id == (unsigned int)((pcurves[0] << 8) | pcurves[1]))
+ if (group_id == bytestogroup(pcurves))
break;
}
if (i >= num_curves