EC_KEY_GET_ENC_FLAGS(3ossl)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’… 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_PUBKEY was used β€” more on that below), then d2i_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_PARAMETERS was used β€” again, below πŸ‘‡), it cannot be loaded using d2i_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_PARAMETERS
  • EC_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_PARAMETERS is set, the public parameters for the curve do not get encoded along with the private key. bye parameters πŸ‘‹
  • if EC_PKEY_NO_PUBKEY is 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:


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