C2SP / wycheproof

Project Wycheproof tests crypto libraries against known attacks.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Acceptable" inputs are difficult to assert on (missing flags?)

davidben opened this issue · comments

Wycheproof defines a tri-state result value, with "acceptable" alongside "valid" and "invalid". It would be nice to programmatically dispatch on these so implementations can test that they accept or reject them as they expect.

It looks like the flags field could be used here, if that was not already the intent. I started looking at using them in BoringSSL, and it's almost what we'd need, but some tests are under-annotated. The model I'm thinking is that our GetWycheproofResult function would take a list of flags we consider acceptable. If any (all?) of a test case's flags fall in that set, we'd map "acceptable" to "valid", otherwise "invalid".

Is this close to what you all had in mind? In that case, these are the "acceptable" inputs that lack flags:

  • aes_eax_test.json - The "small IV size" and "IV size == 0" tests
  • aes_gcm_test.json - The "small IV sizes" tests
  • kw_test.json - All "acceptable" tests
  • kwp_test.json - Ditto
  • x25519_test.json - Most tests do indeed have flags now, but the "public key >= p" and "private key == 1 (mod order) on twist" tests are missing flags. Additionally, while most "public key with low order" tests have the "Small public key" annotation, some are flags-less. ("Small public key" is also a different style from the other flag names. "SmallPublicKey", perhaps?)

Would you accept a PR to x25519_test.json which marked any of the ones described as "public key with low order" as "Small public key"? Does the PR just get sent directly to that file?

For BoringSSL, I think we're interested in:

  • Excluding curves we don't support; the split up files are great, thanks!
  • X25519 should compute the right answer in all cases, but there is a return value that corresponds to the all zero output. We're fine with the other "acceptable" inputs. (Per the formulation in RFC7748.)
  • We don't allow explicit curve encodings in public keys. These are forbidden by RFC 5480.
  • Our ASN.1 parsers are generally strict.
  • We supported compressed coordinates.
  • We are strict in the DigestInfo encoding in RSASSA-PKCS1-v1_5.
  • We accept all specified IV lengths of AES-GCM and leave RSA key size limits for the caller to enforce. (The joys of being a low-level library with existing users... 😢)

Having weak parameters, at least for things like RSA keys, filtered out by either looking at the value or just splitting into files makes sense. I agree that weak things count more as "acceptable" than "valid", but I expect different libraries to have different cutoffs and whatnot for this, based on their needs, and so it may not be useful as a programmatically-checked status code on the test. Though it makes sense as something that could programmatically go either way; the main reason I'm interested in programmatically forcing the other "acceptable" inputs one way or another is the other cases, like bad ASN.1, are quite interesting to assert on.

Others do however. So it is necessary to test with such encodings.

Oh, certainly! Sorry, that was probably unclear. I was just listing the things I would like to be able to differentiate via flags or checking parameters or some other mechanism.

Chiming in late to this issue, but if I can selfishly add my own wish it would be to have a way to distinguish between test cases (for signatures) that are needed to achieve strong unforgeability vs those needed for existential unforgeability.

I am seeing some test failures for lax parsing of ASN.1 DER for RSA signatures in Java (in particular allowing a constructed/concatenated OctetString in the DigestInfo structure). While it would be good for the cryptography provider to fix this, from our point of view we don't need canonical/unique signatures so I don't think this presents an exploitable issue in our scenario. For example, we also support ECDSA signatures that are malleable anyway. (Please correct me if I am misunderstanding this issue!)