summaryrefslogtreecommitdiffstats
path: root/ssl/t1_lib.c
diff options
context:
space:
mode:
authorEmilia Kasper <emilia@openssl.org>2014-12-04 15:00:11 +0100
committerEmilia Kasper <emilia@openssl.org>2014-12-05 18:31:57 +0100
commitbd34823e554706e822ae8990afa9454d94e4ce68 (patch)
tree39d6788fc806b049de8b9aff53ce8fc64d6f6408 /ssl/t1_lib.c
parent533814c6b52b9beabe572dd428afc53732e4ce3f (diff)
Clarify the return values for SSL_get_shared_curve.
Reviewed-by: Matt Caswell <matt@openssl.org> (cherry picked from commit 376e2ca3e3525290619602dc6013c97c9653c037)
Diffstat (limited to 'ssl/t1_lib.c')
-rw-r--r--ssl/t1_lib.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/ssl/t1_lib.c b/ssl/t1_lib.c
index 4162ca0e34..2dea51852e 100644
--- a/ssl/t1_lib.c
+++ b/ssl/t1_lib.c
@@ -540,11 +540,12 @@ int tls1_check_curve(SSL *s, const unsigned char *p, size_t len)
return 0;
}
-/* Return nth shared curve. If nmatch == -1 return number of
- * matches. For nmatch == -2 return the NID of the curve to use for
- * an EC tmp key.
+/*
+ * Return |nmatch|th shared curve or NID_undef if there is no match.
+ * For nmatch == -1, return number of matches
+ * For nmatch == -2, return the NID of the curve to use for
+ * an EC tmp key, or NID_undef if there is no match.
*/
-
int tls1_shared_curve(SSL *s, int nmatch)
{
const unsigned char *pref, *supp;
@@ -578,10 +579,11 @@ int tls1_shared_curve(SSL *s, int nmatch)
*/
if (!tls1_get_curvelist(s, (s->options & SSL_OP_CIPHER_SERVER_PREFERENCE) != 0,
&supp, &num_supp))
- return 0;
+ /* In practice, NID_undef == 0 but let's be precise. */
+ return nmatch == -1 ? 0 : NID_undef;
if(!tls1_get_curvelist(s, !(s->options & SSL_OP_CIPHER_SERVER_PREFERENCE),
&pref, &num_pref))
- return 0;
+ return nmatch == -1 ? 0 : NID_undef;
k = 0;
for (i = 0; i < num_pref; i++, pref+=2)
{
@@ -601,7 +603,8 @@ int tls1_shared_curve(SSL *s, int nmatch)
}
if (nmatch == -1)
return k;
- return 0;
+ /* Out of range (nmatch > k). */
+ return NID_undef;
}
int tls1_set_curves(unsigned char **pext, size_t *pextlen,