[ec_asn1.c] Avoid injecting seed when built-in matches
authorNicola Tuveri <nic.tuv@gmail.com>
Thu, 10 Oct 2019 17:30:58 +0000 (20:30 +0300)
committerNicola Tuveri <nic.tuv@gmail.com>
Tue, 15 Oct 2019 12:19:38 +0000 (15:19 +0300)
commitac8881e160632a8de6ca123a9f85b2e6f8ae173b
tree77d4db4d810829b2b010255dd92e7b06d8cf1f6f
parentdf22cbb555430b7206a8d30cb41f4e28b9e28370
[ec_asn1.c] Avoid injecting seed when built-in matches

An unintended consequence of https://github.com/openssl/openssl/pull/9808
is that when an explicit parameters curve is matched against one of the
well-known builtin curves we automatically inherit also the associated
seed parameter, even if the input parameters excluded such
parameter.

This later affects the serialization of such parsed keys, causing their
input DER encoding and output DER encoding to differ due to the
additional optional field.

This does not cause problems internally but could affect external
applications, as reported in
https://github.com/openssl/openssl/pull/9811#issuecomment-536153288

This commit fixes the issue by conditionally clearing the seed field if
the original input parameters did not include it.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/10140)

(cherry picked from commit f97a8af2f3f3573f0759693117c9d33d2a63c27e)
crypto/ec/ec_asn1.c