SERIALIZER: New API for serialization of objects through providers
authorRichard Levitte <levitte@openssl.org>
Mon, 18 Nov 2019 00:29:06 +0000 (01:29 +0100)
committerRichard Levitte <levitte@openssl.org>
Fri, 29 Nov 2019 19:54:48 +0000 (20:54 +0100)
commit0d003c52d3dcf4b076bb01a6767cdd5ace2d79f6
treec04a81334735f506d3c94a3591e224683feb78ad
parent36fa4d8a0df9dc168047fadd0365966c7116b31d
SERIALIZER: New API for serialization of objects through providers

Serialization is needed to be able to take a provider object (such as
the provider side key data) and output it in PEM form, DER form, text
form (for display), and possibly other future forms (XML? JSON? JWK?)

The idea is that a serializer should be able to handle objects it has
intimate knowledge of, as well as object data in OSSL_PARAM form.  The
latter will allow libcrypto to serialize some object with a different
provider than the one holding the data, if exporting of that data is
allowed and there is a serializer that can handle it.

We will provide serializers for the types of objects we know about,
which should be useful together with any other provider that provides
implementations of the same type of object.

Serializers are selected by method name and a couple of additional
properties:

- format        used to tell what format the output should be in.
                Possibilities could include "format=text",
                "format=pem", "format=der", "format=pem-pkcs1"
                (traditional), "format=der-pkcs1" (traditional)
- type          used to tell exactly what type of data should be
                output, for example "type=public" (the public part of
                a key), "type=private" (the private part of a key),
                "type=domainparams" (domain parameters).

This also adds a passphrase callback function type,
OSSL_PASSPHRASE_CALLBACK, which is a bit like OSSL_CALLBACK, but it
takes a few extra arguments to place the result in.

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/10394)
22 files changed:
crypto/build.info
crypto/err/err.c
crypto/err/openssl.ec
crypto/property/property_parse.c
crypto/serializer/build.info [new file with mode: 0644]
crypto/serializer/serializer_local.h [new file with mode: 0644]
crypto/serializer/serializer_meth.c [new file with mode: 0644]
doc/man3/OSSL_SERIALIZER.pod [new file with mode: 0644]
doc/man3/OSSL_SERIALIZER_CTX.pod [new file with mode: 0644]
doc/man7/openssl-core.h.pod
doc/man7/provider-serializer.pod [new file with mode: 0644]
doc/man7/provider.pod
include/crypto/serializer.h [new file with mode: 0644]
include/internal/cryptlib.h
include/openssl/core.h
include/openssl/core_numbers.h
include/openssl/err.h
include/openssl/pem.h
include/openssl/serializer.h [new file with mode: 0644]
include/openssl/types.h
util/libcrypto.num
util/other.syms