Make sure the digestAlgorithm.parameters field is empty, which it has to be for the hashes we support. Otherwise, the field can encode "garbage" that might be used to make the signature be a perfect cube, similar (but not identical) to Bleichenbacher's Crypto 06 rump session attack. Index: verify.c =================================================================== RCS file: /cvs/gnutls/gnutls/lib/x509/verify.c,v retrieving revision 1.52 retrieving revision 1.55 diff -u -p -r1.52 -r1.55 --- gnutls/lib/x509/verify.c 7 Nov 2005 23:28:02 -0000 1.52 +++ gnutls/lib/x509/verify.c 12 Sep 2006 13:11:23 -0000 1.55 @@ -505,6 +505,19 @@ decode_ber_digest_info (const gnutls_dat return GNUTLS_E_UNKNOWN_HASH_ALGORITHM; } + len = sizeof (str) - 1; + result = asn1_read_value (dinfo, "digestAlgorithm.parameters", str, &len); + /* To avoid permitting garbage in the parameters field, either the + parameters field is not present, or it contains 0x05 0x00. */ + if (!(result == ASN1_ELEMENT_NOT_FOUND || + (result == ASN1_SUCCESS && len == 2 && + str[0] == 0x05 && str[1] == 0x00))) + { + gnutls_assert (); + asn1_delete_structure (&dinfo); + return GNUTLS_E_ASN1_GENERIC_ERROR; + } + result = asn1_read_value (dinfo, "digest", digest, digest_size); if (result != ASN1_SUCCESS) {