EC_KEY_GET_ENC_FLAGS(3SSL)

πŸ’– EC_KEY_get_enc_flags β€” bestie edition πŸ’–

okay so this is the OpenSSL manual page for EC_KEY_get_enc_flags and EC_KEY_set_enc_flags, and we're gonna get and set the encoding flags on them EC_KEY structures. no cap, it's giving very niche but very important. πŸŽ€

✨ NAME ✨

EC_KEY_get_enc_flags, EC_KEY_set_enc_flags β€” literally just get and set flags for encoding EC_KEY structures πŸ’…

🌸 SYNOPSIS 🌸

#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);

look at them. two little functions. iconic behavior. 😌

πŸ¦‹ DESCRIPTION πŸ¦‹

so when i2d_ECPrivateKey() writes out the external representation of the public key β€” like whether it's stored in a compressed form or not β€” the format of that whole situation is described by the point_conversion_form. if you want the full tea on point_conversion_form, go read EC_GROUP_copy(3). it's right there. 🫢

now here's the part where you gotta pay attention bestie: when you're reading a private key that was encoded without an associated public key (like, say, if EC_PKEY_NO_PUBKEY was used β€” that's one of the flags, keep reading 🫣), then d2i_ECPrivateKey() will generate the missing public key for you automatically. it just does. main character energy fr. ✨

but 🚨 and this is the loud part 🚨 β€” private keys encoded without parameters (like if EC_PKEY_NO_PARAMETERS was used, again, see below) cannot be loaded using d2i_ECPrivateKey(). cannot. can not. nope. it's giving blocked. πŸ’€

so EC_KEY_get_enc_flags() and EC_KEY_set_enc_flags() 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 flags define the behaviour of how the key gets converted into ASN1 in a call to i2d_ECPrivateKey(). and here's what each one does:

  • if EC_PKEY_NO_PARAMETERS is set β†’ the public parameters for the curve are not encoded along with the private key πŸ™ˆ
  • if EC_PKEY_NO_PUBKEY is set β†’ the public key is not encoded along with the private key πŸ™ˆ

that's it. that's the whole vibe. small page, big consequences. πŸ’œ

⭐ RETURN VALUES ⭐

EC_KEY_get_enc_flags() returns the value of the current encoding flags for the EC_KEY. that's the whole return values section, bestie β€” the setter doesn't get one, so don't go looking. πŸ‘‘

🌈 SEE ALSO 🌈

go read them, they're all part of the same little ecosystem okurrr πŸ’–

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 was OpenSSL 4.0.3, dated 2026-09-29, and it slayed every single day. mwah. stay encoded, stay unproblematic, and don't forget your params πŸŒΈπŸ’…πŸ¦‹βœ¨

πŸ“¦ where this page comes from