OSSL_ENCODER(3ossl)
π OSSL_ENCODER π
okay so bestie, welcome to OSSL_ENCODER β that's the manual page name right there, in section 3ossl of the OpenSSL docs. this is genuinely one of my favorite little corner of the OpenSSL API and i'm gonna walk you through it, no gatekeeping π«Ά
β¨ NAME β¨
OSSL_ENCODER, OSSL_ENCODER_fetch, OSSL_ENCODER_up_ref, OSSL_ENCODER_free, OSSL_ENCODER_get0_provider, OSSL_ENCODER_get0_properties, OSSL_ENCODER_is_a, OSSL_ENCODER_get0_name, OSSL_ENCODER_get0_description, OSSL_ENCODER_do_all_provided, OSSL_ENCODER_names_do_all, OSSL_ENCODER_gettable_params, OSSL_ENCODER_get_params β these are the encoder method routines π
like, the whole girl squad. one function per line, all of them iconic, all of them here.
πΈ SYNOPSIS πΈ
#include <openssl/encoder.h>
typedef struct ossl_encoder_st OSSL_ENCODER;
OSSL_ENCODER *OSSL_ENCODER_fetch(OSSL_LIB_CTX *ctx, const char *name,
const char *properties);
int OSSL_ENCODER_up_ref(OSSL_ENCODER *encoder);
void OSSL_ENCODER_free(OSSL_ENCODER *encoder);
const OSSL_PROVIDER *OSSL_ENCODER_get0_provider(const OSSL_ENCODER *encoder);
const char *OSSL_ENCODER_get0_properties(const OSSL_ENCODER *encoder);
int OSSL_ENCODER_is_a(const OSSL_ENCODER *encoder, const char *name);
const char *OSSL_ENCODER_get0_name(const OSSL_ENCODER *encoder);
const char *OSSL_ENCODER_get0_description(const OSSL_ENCODER *encoder);
void OSSL_ENCODER_do_all_provided(OSSL_LIB_CTX *libctx,
void (*fn)(OSSL_ENCODER *encoder, void *arg),
void *arg);
int OSSL_ENCODER_names_do_all(const OSSL_ENCODER *encoder,
void (*fn)(const char *name, void *data),
void *data);
const OSSL_PARAM *OSSL_ENCODER_gettable_params(OSSL_ENCODER *encoder);
int OSSL_ENCODER_get_params(OSSL_ENCODER_CTX *ctx, const OSSL_PARAM params[]);
copy that verbatim, don't be cute with it, it compiles exactly like that π
π¦ DESCRIPTION π¦
so like, OSSL_ENCODER is a method for encoders. and what do encoders do? they know how to encode an object of some kind into an encoded form β think PEM, DER, or even human readable text. that's their whole personality. main character behavior honestly π₯
OSSL_ENCODER_fetch()β looks for an algorithm inside the provider that's been loaded into theOSSL_LIB_CTXyou passed as ctx, with the name you gave as name and the properties you gave as properties. the name decides what type of object the fetched encoder method is supposed to be able to encode, and the properties are what determines the expected output type. wanna know the known properties and the values they can have? go peek at "Names and properties" inprovider-encoder(7). iykyk πOSSL_ENCODER_up_ref()β bumps the reference count on the given encoder up by one. very "i'm keeping you around" of you.OSSL_ENCODER_free()β decrements the reference count on the given encoder, and when the count hits zero, it frees it. and if the argument isNULL? nothing happens. it just. does nothing. respect honestly πOSSL_ENCODER_get0_provider()β hands you the provider of the given encoder.OSSL_ENCODER_get0_properties()β hands you the property definition that's associated with the given encoder.OSSL_ENCODER_is_a()β vibe checks whether encoder is an implementation of an algorithm that's identifiable with name πOSSL_ENCODER_get0_name()β returns the name that was used to fetch the given encoder.OSSL_ENCODER_get0_description()β returns a description of the loader, meant for display and human consumption. and noted: the description is entirely at the discretion of the loader implementation. so like, whatever the loader feels like saying, bestie.OSSL_ENCODER_names_do_all()β walks every name for the given encoder, and calls fn with each name and data as arguments.OSSL_ENCODER_do_all_provided()β walks all encoder implementations across all activated providers in the library context libctx, and for each of those implementations, calls fn with the implementation method and arg as arguments.OSSL_ENCODER_gettable_params()β returns anOSSL_PARAM(3)array of parameter descriptors.OSSL_ENCODER_get_params()β tries to get parameters specified with anOSSL_PARAM(3)array params. any parameters the implementation doesn't recognise should just be ignored. not me being unbothered β¨
β RETURN VALUES β
this is the part where we find out what we actually get back, so pay attention bestie π
OSSL_ENCODER_fetch()returns a pointer to the key management implementation represented by anOSSL_ENCODERobject, orNULLon error. (yes, it really says key management in there, i don't make the rules, i just report them π)OSSL_ENCODER_up_ref()returns1on success, or0on error.OSSL_ENCODER_free()doesn't return any value. it's giving "i don't owe you a response".OSSL_ENCODER_get0_provider()returns a pointer to a provider object, orNULLon error.OSSL_ENCODER_get0_properties()returns a pointer to a property definition string, orNULLon error.OSSL_ENCODER_is_a()returns1if the encoder was identifiable, otherwise0.OSSL_ENCODER_get0_name()returns the algorithm name from the provided implementation for the given encoder. heads up though: the encoder may have multiple synonyms associated with it, and in that case the first name from the algorithm definition is what gets returned. ownership of the returned string stays with the encoder object, so the caller should not free it. do not touch, do not free, it's not yours, periodt πOSSL_ENCODER_get0_description()returns a pointer to a description, orNULLif there isn't one.OSSL_ENCODER_names_do_all()returns1if the callback was called for all names. a return value of0means the callback was not called for any names. that's the whole scale,1or0, no in-between π
π SEE ALSO π
go read these next, they're the friends of this page and they all slay:
provider(7)OSSL_ENCODER_CTX(3)OSSL_ENCODER_to_bio(3)OSSL_ENCODER_CTX_new_for_pkey(3)OSSL_LIB_CTX(3)
π§ HISTORY π§
the functions described here were added in OpenSSL 3.0. so like, they've been around, they're not new new, they're established π
π COPYRIGHT π
Copyright 2019-2024 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>.
okay that's the whole page, you made it, i'm so proud of you π₯Ήπ this was OSSL_ENCODER(3ossl) from the OpenSSL 3.5.0 docs, dated 2026-09-25 β go encode something cute, mwah ππ«Ά
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms