tls: code shrink

function                                             old     new   delta
tls_handshake                                       1643    1619     -24

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2018-11-05 00:18:18 +01:00
parent 5df3b12241
commit 084bac472b

View File

@ -1115,8 +1115,6 @@ static void find_key_in_der_cert(tls_state_t *tls, uint8_t *der, int len)
* We need Certificate.tbsCertificate.subjectPublicKeyInfo.publicKey * We need Certificate.tbsCertificate.subjectPublicKeyInfo.publicKey
*/ */
uint8_t *end = der + len; uint8_t *end = der + len;
uint8_t tag_class, pc, tag_number;
int version_present;
/* enter "Certificate" item: [der, end) will be only Cert */ /* enter "Certificate" item: [der, end) will be only Cert */
der = enter_der_item(der, &end); der = enter_der_item(der, &end);
@ -1133,13 +1131,11 @@ static void find_key_in_der_cert(tls_state_t *tls, uint8_t *der, int len)
* (constructed), and a tag number of 0 (see ITU-T X.690 sections 8.1.2 * (constructed), and a tag number of 0 (see ITU-T X.690 sections 8.1.2
* and 8.14). * and 8.14).
*/ */
tag_class = der[0] >> 6; /* bits 8-7 */ /* bits 7-6: 10 */
pc = (der[0] & 32) >> 5; /* bit 6 */ /* bit 5: 1 */
tag_number = der[0] & 31; /* bits 5-1 */ /* bits 4-0: 00000 */
version_present = tag_class == 2 && pc == 1 && tag_number == 0; if (der[0] == 0xa0)
if (version_present) {
der = skip_der_item(der, end); /* version */ der = skip_der_item(der, end); /* version */
}
/* skip up to subjectPublicKeyInfo */ /* skip up to subjectPublicKeyInfo */
der = skip_der_item(der, end); /* serialNumber */ der = skip_der_item(der, end); /* serialNumber */