EC_KEY_GET_ENC_FLAGS(3ossl)
π EC_KEY_GET_ENC_FLAGS(3ossl) β the girlies' guide to encoding flags
okay so real talk, this page lives in the OpenSSL manual, section 3ossl, and it's about exactly two little functions: EC_KEY_get_enc_flags and EC_KEY_set_enc_flags. their whole job? getting and setting the flags for encoding EC_KEY structures. that's it. that's the vibe. π
β¨ SYNOPSIS β¨
like all things OpenSSL, you gotta invite it in first:
#include <openssl/ec.h>
unsigned int EC_KEY_get_enc_flags(const EC_KEY *key);
void EC_KEY_set_enc_flags(EC_KEY *eckey, unsigned int flags);
πΈ DESCRIPTION πΈ
okay so picture this: the external representation of the public key β the version that i2d_ECPrivateKey() actually writes out β has a format. and one of the things describing that format is whether it's stored in a compressed form or not. that whole situation is described by point_conversion_form, and bestie, EC_GROUP_copy(3) has the full tea on point_conversion_form if you wanna go deeper. π«Ά
now, reading keys back in? two very different situations, ngl:
- if you're reading a private key that was encoded without an associated public key (say, because
EC_PKEY_NO_PUBKEYwas used β more on that below), thend2i_ECPrivateKey()just generates the missing public key automatically. bestie behavior honestly. it's giving self-sufficient. β¨ - but if a private key was encoded without parameters (say, because
EC_PKEY_NO_PARAMETERSwas used β again, below π), it cannot be loaded usingd2i_ECPrivateKey(). periodt. no workaround mentioned here, so don't come for me.
so EC_KEY_get_enc_flags() and EC_KEY_set_enc_flags() do exactly what their names say: get and set the value of the encoding flags for the key. there are two encoding flags currently defined:
EC_PKEY_NO_PARAMETERSEC_PKEY_NO_PUBKEY
these two icons define the behaviour of how the key gets converted into ASN1 when you call i2d_ECPrivateKey(). and here's the lowkey important part:
- if
EC_PKEY_NO_PARAMETERSis set, the public parameters for the curve do not get encoded along with the private key. bye parameters π - if
EC_PKEY_NO_PUBKEYis set, the public key does not get encoded along with the private key. bye public key π
β οΈ friendly heads up, no cap: a key written without parameters is not loadable by d2i_ECPrivateKey(). remember that before you go flag-flipping, iykyk.
π RETURN VALUES π
EC_KEY_get_enc_flags() returns the value of the current encoding flags for the EC_KEY. that's the whole return section. slay for a short one. π
(and EC_KEY_set_enc_flags()? void. it returns nothing. it just does the thing. main character energy. π
)
π¦ SEE ALSO π¦
go read these next, bestie, they're all linked in the same little ecosystem:
crypto(7)EC_GROUP_new(3)EC_GROUP_copy(3)EC_POINT_new(3)EC_POINT_add(3)EC_GFp_simple_method(3)d2i_ECPKParameters(3)d2i_ECPrivateKey(3)
π COPYRIGHT π
Copyright 2015-2017 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>. π«Ά
and that's the page!! π this little beauty is from OpenSSL 3.5.6, dated 2026-04-07, and you can find it filed under EC_KEY_GET_ENC_FLAGS(3ossl) β go forth and encode responsibly, bestie ππ
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms