opnsense-src/crypto/encode_decode/encoder_local.h
Enji Cooper e4520c8bd1 openssl: Vendor import of OpenSSL-3.0.8
Summary:

Release notes can be found at
https://www.openssl.org/news/openssl-3.0-notes.html .

Obtained from:  https://www.openssl.org/source/openssl-3.0.8.tar.gz
Differential Revision:	https://reviews.freebsd.org/D38835

Test Plan:
```
$ git status
On branch vendor/openssl-3.0
nothing to commit, working tree clean
$ (cd ..; fetch http://www.openssl.org/source/openssl-${OSSLVER}.tar.gz http://www.openssl.org/source/openssl-${OSSLVER}.tar.gz.asc)
openssl-3.0.8.tar.gz                                    14 MB 4507 kBps    04s
openssl-3.0.8.tar.gz.asc                               833  B   10 MBps    00s
$ set | egrep '(XLIST|OSSLVER)='
OSSLVER=3.0.8
XLIST=FREEBSD-Xlist
$ gpg --list-keys
/home/ngie/.gnupg/pubring.kbx
-----------------------------
pub   rsa4096 2014-10-04 [SC]
      7953AC1FBC3DC8B3B292393ED5E9E43F7DF9EE8C
uid           [ unknown] Richard Levitte <richard@levitte.org>
uid           [ unknown] Richard Levitte <levitte@lp.se>
uid           [ unknown] Richard Levitte <levitte@openssl.org>
sub   rsa4096 2014-10-04 [E]

$ gpg --verify openssl-${OSSLVER}.tar.gz.asc openssl-${OSSLVER}.tar.gz
gpg: Signature made Tue Feb  7 05:43:55 2023 PST
gpg:                using RSA key 7953AC1FBC3DC8B3B292393ED5E9E43F7DF9EE8C
gpg: Good signature from "Richard Levitte <richard@levitte.org>" [unknown]
gpg:                 aka "Richard Levitte <levitte@lp.se>" [unknown]
gpg:                 aka "Richard Levitte <levitte@openssl.org>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 7953 AC1F BC3D C8B3 B292  393E D5E9 E43F 7DF9 EE8C
$ (cd vendor.checkout/; git status; find . -type f -or -type l | cut -c 3- | sort > ../old)
On branch vendor/openssl-3.0
nothing to commit, working tree clean
$ tar -x -X $XLIST -f ../openssl-${OSSLVER}.tar.gz -C ..
$ rsync --exclude FREEBSD.* --delete -avzz ../openssl-${OSSLVER}/* .
$ cat .git
gitdir: /home/ngie/git/freebsd-src/.git/worktrees/vendor.checkout
$ diff -arq ../openssl-3.0.8  .
Only in .: .git
Only in .: FREEBSD-Xlist
Only in .: FREEBSD-upgrade
$ git status FREEBSD*
On branch vendor/openssl-3.0
nothing to commit, working tree clean
$
```

Reviewers: emaste, jkim

Subscribers: imp, andrew, dab

Differential Revision: https://reviews.freebsd.org/D38835
2023-03-06 12:41:29 -08:00

164 lines
5.6 KiB
C

/*
* Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
#include <openssl/core_dispatch.h>
#include <openssl/types.h>
#include <openssl/safestack.h>
#include <openssl/encoder.h>
#include <openssl/decoder.h>
#include "internal/cryptlib.h"
#include "internal/passphrase.h"
#include "internal/property.h"
#include "internal/refcount.h"
struct ossl_endecode_base_st {
OSSL_PROVIDER *prov;
int id;
char *name;
const OSSL_ALGORITHM *algodef;
OSSL_PROPERTY_LIST *parsed_propdef;
CRYPTO_REF_COUNT refcnt;
CRYPTO_RWLOCK *lock;
};
struct ossl_encoder_st {
struct ossl_endecode_base_st base;
OSSL_FUNC_encoder_newctx_fn *newctx;
OSSL_FUNC_encoder_freectx_fn *freectx;
OSSL_FUNC_encoder_get_params_fn *get_params;
OSSL_FUNC_encoder_gettable_params_fn *gettable_params;
OSSL_FUNC_encoder_set_ctx_params_fn *set_ctx_params;
OSSL_FUNC_encoder_settable_ctx_params_fn *settable_ctx_params;
OSSL_FUNC_encoder_does_selection_fn *does_selection;
OSSL_FUNC_encoder_encode_fn *encode;
OSSL_FUNC_encoder_import_object_fn *import_object;
OSSL_FUNC_encoder_free_object_fn *free_object;
};
struct ossl_decoder_st {
struct ossl_endecode_base_st base;
OSSL_FUNC_decoder_newctx_fn *newctx;
OSSL_FUNC_decoder_freectx_fn *freectx;
OSSL_FUNC_decoder_get_params_fn *get_params;
OSSL_FUNC_decoder_gettable_params_fn *gettable_params;
OSSL_FUNC_decoder_set_ctx_params_fn *set_ctx_params;
OSSL_FUNC_decoder_settable_ctx_params_fn *settable_ctx_params;
OSSL_FUNC_decoder_does_selection_fn *does_selection;
OSSL_FUNC_decoder_decode_fn *decode;
OSSL_FUNC_decoder_export_object_fn *export_object;
};
struct ossl_encoder_instance_st {
OSSL_ENCODER *encoder; /* Never NULL */
void *encoderctx; /* Never NULL */
const char *output_type; /* Never NULL */
const char *output_structure; /* May be NULL */
};
DEFINE_STACK_OF(OSSL_ENCODER_INSTANCE)
void ossl_encoder_instance_free(OSSL_ENCODER_INSTANCE *encoder_inst);
struct ossl_encoder_ctx_st {
/*
* Select what parts of an object will be encoded. This selection is
* bit encoded, and the bits correspond to selection bits available with
* the provider side operation. For example, when encoding an EVP_PKEY,
* the OSSL_KEYMGMT_SELECT_ macros are used for this.
*/
int selection;
/*
* The desired output type. The encoder implementation must have a
* gettable "output-type" parameter that this will match against.
*/
const char *output_type;
/*
* The desired output structure, if that's relevant for the type of
* object being encoded. It may be used for selection of the starting
* encoder implementations in a chain.
*/
const char *output_structure;
/*
* Decoders that are components of any current decoding path.
*/
STACK_OF(OSSL_ENCODER_INSTANCE) *encoder_insts;
/*
* The constructor and destructor of an object to pass to the first
* encoder in a chain.
*/
OSSL_ENCODER_CONSTRUCT *construct;
OSSL_ENCODER_CLEANUP *cleanup;
void *construct_data;
/* For any function that needs a passphrase reader */
struct ossl_passphrase_data_st pwdata;
};
struct ossl_decoder_instance_st {
OSSL_DECODER *decoder; /* Never NULL */
void *decoderctx; /* Never NULL */
const char *input_type; /* Never NULL */
const char *input_structure; /* May be NULL */
unsigned int flag_input_structure_was_set : 1;
};
DEFINE_STACK_OF(OSSL_DECODER_INSTANCE)
struct ossl_decoder_ctx_st {
/*
* The caller may know the input type of the data they pass. If not,
* this will remain NULL and the decoding functionality will start
* with trying to decode with any desencoder in |decoder_insts|,
* regardless of their respective input type.
*/
const char *start_input_type;
/*
* The desired input structure, if that's relevant for the type of
* object being encoded. It may be used for selection of the ending
* decoder implementations in a chain, i.e. those chosen using the
* expected output data type.
*/
const char *input_structure;
/*
* Select what parts of an object are expected. This may affect what
* decoder implementations are selected, because there are structures
* that look different depending on this selection; for example, EVP_PKEY
* objects often have different encoding structures for private keys,
* public keys and key parameters.
* This selection is bit encoded, and the bits correspond to selection
* bits available with the provider side operation. For example, when
* encoding an EVP_PKEY, the OSSL_KEYMGMT_SELECT_ macros are used for
* this.
*/
int selection;
/*
* Decoders that are components of any current decoding path.
*/
STACK_OF(OSSL_DECODER_INSTANCE) *decoder_insts;
/*
* The constructors of a decoding, and its caller argument.
*/
OSSL_DECODER_CONSTRUCT *construct;
OSSL_DECODER_CLEANUP *cleanup;
void *construct_data;
/* For any function that needs a passphrase reader */
struct ossl_passphrase_data_st pwdata;
};
const OSSL_PROPERTY_LIST *
ossl_decoder_parsed_properties(const OSSL_DECODER *decoder);
const OSSL_PROPERTY_LIST *
ossl_encoder_parsed_properties(const OSSL_ENCODER *encoder);