mirror of
https://github.com/QuasarApp/openssl.git
synced 2025-05-19 21:09:41 +00:00
The following public functions is added: - OSSL_SERIALIZER_CTX_new_by_EVP_PKEY() - OSSL_SERIALIZER_CTX_set_cipher() - OSSL_SERIALIZER_CTX_set_passphrase() - OSSL_SERIALIZER_CTX_set_passphrase_cb() - OSSL_SERIALIZER_CTX_set_passphrase_ui() OSSL_SERIALIZER_CTX_new_by_EVP_PKEY() selects a suitable serializer for the given EVP_PKEY, and sets up the OSSL_SERIALIZER_CTX to function together with OSSL_SERIALIZER_to_bio() and OSSL_SERIALIZER_to_fp(). OSSL_SERIALIZER_CTX_set_cipher() indicates what cipher should be used to produce an encrypted serialization of the EVP_PKEY. This is passed directly to the provider using OSSL_SERIALIZER_CTX_set_params(). OSSL_SERIALIZER_CTX_set_passphrase() can be used to set a pass phrase to be used for the encryption. This is passed directly to the provider using OSSL_SERIALIZER_CTX_set_params(). OSSL_SERIALIZER_CTX_set_passphrase_cb() and OSSL_SERIALIZER_CTX_set_passphrase_ui() sets up a callback to be used to prompt for a passphrase. This is stored in the context, and is called via an internal intermediary at the time of serialization. Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/10394)
51 lines
1.5 KiB
C
51 lines
1.5 KiB
C
/*
|
|
* Copyright 2019 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_numbers.h>
|
|
#include <openssl/types.h>
|
|
#include "internal/cryptlib.h"
|
|
#include "internal/refcount.h"
|
|
|
|
struct ossl_serializer_st {
|
|
OSSL_PROVIDER *prov;
|
|
int id;
|
|
const char *propdef;
|
|
|
|
CRYPTO_REF_COUNT refcnt;
|
|
CRYPTO_RWLOCK *lock;
|
|
|
|
OSSL_OP_serializer_newctx_fn *newctx;
|
|
OSSL_OP_serializer_freectx_fn *freectx;
|
|
OSSL_OP_serializer_set_ctx_params_fn *set_ctx_params;
|
|
OSSL_OP_serializer_settable_ctx_params_fn *settable_ctx_params;
|
|
OSSL_OP_serializer_serialize_data_fn *serialize_data;
|
|
OSSL_OP_serializer_serialize_object_fn *serialize_object;
|
|
};
|
|
|
|
struct ossl_serializer_ctx_st {
|
|
OSSL_SERIALIZER *ser;
|
|
void *serctx;
|
|
|
|
/*
|
|
* |object| is the libcrypto object to handle.
|
|
* |do_output| must have intimate knowledge of this object.
|
|
*/
|
|
const void *object;
|
|
int (*do_output)(OSSL_SERIALIZER_CTX *ctx, BIO *out);
|
|
|
|
/* For any function that needs a passphrase reader */
|
|
const UI_METHOD *ui_method;
|
|
void *ui_data;
|
|
/*
|
|
* if caller used OSSL_SERIALIZER_CTX_set_passphrase_cb(), we need
|
|
* intermediary storage.
|
|
*/
|
|
UI_METHOD *allocated_ui_method;
|
|
};
|