@@ -1270,7 +1270,7 @@ static int32_t parse_cert_rdata(
1270
1270
return code ;
1271
1271
if ((code = take_contiguous (parser , type , & fields [2 ], token )) < 0 )
1272
1272
return code ;
1273
- if ((code = parse_algorithm_type (parser , type , & fields [2 ], rdata , token )) < 0 )
1273
+ if ((code = parse_algorithm (parser , type , & fields [2 ], rdata , token )) < 0 )
1274
1274
return code ;
1275
1275
take (parser , token );
1276
1276
if ((code = parse_base64_sequence (parser , type , & fields [3 ], rdata , token )) < 0 )
@@ -1346,7 +1346,7 @@ static int32_t parse_ds_rdata(
1346
1346
return code ;
1347
1347
if ((code = take_contiguous (parser , type , & fields [1 ], token )) < 0 )
1348
1348
return code ;
1349
- if ((code = parse_algorithm_type (parser , type , & fields [1 ], rdata , token )) < 0 )
1349
+ if ((code = parse_algorithm (parser , type , & fields [1 ], rdata , token )) < 0 )
1350
1350
return code ;
1351
1351
if ((code = take_contiguous (parser , type , & fields [2 ], token )) < 0 )
1352
1352
return code ;
@@ -1375,7 +1375,7 @@ static int32_t check_sshfp_rr(
1375
1375
1376
1376
// https://www.iana.org/assignments/dns-sshfp-rr-parameters
1377
1377
1378
- if (c > = n )
1378
+ if (c = = n )
1379
1379
SYNTAX_ERROR (parser , "Missing %s in %s" , NAME ((& f [0 ])), NAME (type ));
1380
1380
else if (o [1 ] == 1 && (n - c ) != 20 )
1381
1381
SEMANTIC_ERROR (parser , "Wrong fingerprint size for type %s in %s" ,
@@ -1398,15 +1398,28 @@ static int32_t parse_sshfp_rdata(
1398
1398
return code ;
1399
1399
if ((code = parse_int8 (parser , type , & fields [0 ], rdata , token )) < 0 )
1400
1400
return code ;
1401
+
1402
+ const uint8_t * fingerprint_type = rdata -> octets ;
1401
1403
if ((code = take_contiguous (parser , type , & fields [1 ], token )) < 0 )
1402
1404
return code ;
1403
1405
if ((code = parse_int8 (parser , type , & fields [1 ], rdata , token )) < 0 )
1404
1406
return code ;
1407
+
1408
+ const uint8_t * fingerprint = rdata -> octets ;
1405
1409
take (parser , token );
1406
1410
if ((code = parse_base16_sequence (parser , type , & fields [2 ], rdata , token )) < 0 )
1407
1411
return code ;
1408
1412
1409
- return check_sshfp_rr (parser , type , rdata );
1413
+ // https://www.iana.org/assignments/dns-sshfp-rr-parameters
1414
+ size_t fingerprint_size = (uintptr_t )rdata -> octets - (uintptr_t )fingerprint ;
1415
+ if (unlikely (* fingerprint_type == 1 && fingerprint_size != 20 ))
1416
+ SEMANTIC_ERROR (parser , "Wrong fingerprint size for type %s in %s" ,
1417
+ "SHA1" , NAME (type ));
1418
+ if (unlikely (* fingerprint_type == 2 && fingerprint_size != 32 ))
1419
+ SEMANTIC_ERROR (parser , "Wrong fingerprint size for type %s in %s" ,
1420
+ "SHA256" , NAME (type ));
1421
+
1422
+ return accept_rr (parser , type , rdata );
1410
1423
}
1411
1424
1412
1425
nonnull_all
@@ -1603,7 +1616,7 @@ static int32_t parse_rrsig_rdata(
1603
1616
return code ;
1604
1617
if ((code = take_contiguous (parser , type , & fields [1 ], token )) < 0 )
1605
1618
return code ;
1606
- if ((code = parse_algorithm_type (parser , type , & fields [1 ], rdata , token )) < 0 )
1619
+ if ((code = parse_algorithm (parser , type , & fields [1 ], rdata , token )) < 0 )
1607
1620
return code ;
1608
1621
if ((code = take_contiguous (parser , type , & fields [2 ], token )) < 0 )
1609
1622
return code ;
@@ -1710,7 +1723,7 @@ static int32_t parse_dnskey_rdata(
1710
1723
return code ;
1711
1724
if ((code = take_contiguous (parser , type , & fields [2 ], token )) < 0 )
1712
1725
return code ;
1713
- if ((code = parse_algorithm_type (parser , type , & fields [2 ], rdata , token )) < 0 )
1726
+ if ((code = parse_algorithm (parser , type , & fields [2 ], rdata , token )) < 0 )
1714
1727
return code ;
1715
1728
take (parser , token );
1716
1729
if ((code = parse_base64_sequence (parser , type , & fields [3 ], rdata , token )) < 0 )
0 commit comments