Add Serializers for EC
authorShane Lontis <shane.lontis@oracle.com>
Sun, 16 Feb 2020 09:54:08 +0000 (19:54 +1000)
committerShane Lontis <shane.lontis@oracle.com>
Tue, 3 Mar 2020 21:48:45 +0000 (07:48 +1000)
commitf552d900459cbacd82433b688b237cd6870663cd
tree8fca1cf5a0274525e750cf74e890a3ac7f7eb671
parent4a98ad086a6db9a8646244bd6e6517f9fff11762
Add Serializers for EC

Provide EC serializers for text, pem and der.

EC parameters use ANS1 'CHOICE' - which means they are more embedded than other parameters used by
other KEY types (which normally have a SEQUENCE at the top level).
For this reason the ANS1_STRING type that was being passed around has been changed to a void so that the
code can still be shared with EC.

The EC serializer only supports named curves currently.

NOTE the serializer code assumes PKCS8 format - if the older encode methods are needed they will need to be
added in another PR. (Probably when deserialization is considered).

EVP_PKEY_key_fromdata_init was changed from using a keypair selection to all bits of a key. A side effect of this was
that the very restrictive checks in the ecx code needed to be relaxed as it was assuming all selection flags were non
optional. As this is not the case for any other key the code has been modified.

Fixed a bug in legacy_ctrl_str_to_params() - "ecdh_cofactor_mode" was being incorrectly converted to the wrong keyname.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/11107)
26 files changed:
crypto/evp/pmeth_gn.c
crypto/evp/pmeth_lib.c
doc/man7/provider-keymgmt.pod
providers/defltprov.c
providers/implementations/include/prov/implementations.h
providers/implementations/keymgmt/ec_kmgmt.c
providers/implementations/keymgmt/ecx_kmgmt.c
providers/implementations/serializers/build.info
providers/implementations/serializers/serializer_common.c
providers/implementations/serializers/serializer_dh.c
providers/implementations/serializers/serializer_dsa.c
providers/implementations/serializers/serializer_ec.c [new file with mode: 0644]
providers/implementations/serializers/serializer_ec_param.c [new file with mode: 0644]
providers/implementations/serializers/serializer_ec_priv.c [new file with mode: 0644]
providers/implementations/serializers/serializer_ec_pub.c [new file with mode: 0644]
providers/implementations/serializers/serializer_local.h
providers/implementations/serializers/serializer_rsa_priv.c
test/build.info
test/evp_pkey_provided_test.c
test/recipes/30-test_evp_pkey_provided.t
test/recipes/30-test_evp_pkey_provided/EC.priv.der [new file with mode: 0644]
test/recipes/30-test_evp_pkey_provided/EC.priv.pem [new file with mode: 0644]
test/recipes/30-test_evp_pkey_provided/EC.priv.txt [new file with mode: 0644]
test/recipes/30-test_evp_pkey_provided/EC.pub.der [new file with mode: 0644]
test/recipes/30-test_evp_pkey_provided/EC.pub.pem [new file with mode: 0644]
test/recipes/30-test_evp_pkey_provided/EC.pub.txt [new file with mode: 0644]