Port tls12_check_peer_sigalg to CBS.

This avoids having to do the CBS_skip dance and is better about returning the
right alert.

Change-Id: Id84eba307d7c67269ccbc07a38d9044b6f4f7c6c
Reviewed-on: https://boringssl-review.googlesource.com/1169
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/ssl/s3_srvr.c b/ssl/s3_srvr.c
index 56c426b..5e7470d 100644
--- a/ssl/s3_srvr.c
+++ b/ssl/s3_srvr.c
@@ -2680,31 +2680,11 @@
 	/* We now have a signature that we need to verify. */
 	/* TODO(davidben): This should share code with
 	 * ssl3_get_key_exchange. */
+
 	if (SSL_USE_SIGALGS(s))
 		{
-		int rv;
-		const uint8_t *sigalg;
-
-		/* The first two bytes are the signature and
-		 * algorithm. */
-		sigalg = CBS_data(&certificate_verify);
-		if (!CBS_skip(&certificate_verify, 2))
-			{
-			al = SSL_AD_DECODE_ERROR;
-			OPENSSL_PUT_ERROR(SSL, ssl3_get_key_exchange, SSL_R_DECODE_ERROR);
+		if (!tls12_check_peer_sigalg(&md, &al, s, &certificate_verify, pkey))
 			goto f_err;
-			}
-		rv = tls12_check_peer_sigalg(&md, s, sigalg, pkey);
-		if (rv == -1)
-			{
-			al = SSL_AD_INTERNAL_ERROR;
-			goto f_err;
-			}
-		else if (rv == 0)
-			{
-			al = SSL_AD_DECODE_ERROR;
-			goto f_err;
-			}
 		}
 
 	if (!CBS_get_u16_length_prefixed(&certificate_verify, &signature) ||