OSSL_CRMF_PBMP_NEW(3SSL)

πŸ’– NAME πŸ’–

OSSL_CRMF_pbm_new, OSSL_CRMF_pbmp_new β€” bestie, these are the functions for producing a Password-Based MAC (PBM) ✨

(Yes this is the OpenSSL CRMF page, slay, we're in the crmf chapter and it's lowkey iconic.)


🌸 SYNOPSIS 🌸

#include <openssl/crmf.h>

int OSSL_CRMF_pbm_new(OSSL_LIB_CTX *libctx, const char *propq,
                      const OSSL_CRMF_PBMPARAMETER *pbmp,
                      const unsigned char *msg, size_t msglen,
                      const unsigned char *sec, size_t seclen,
                      unsigned char **mac, size_t *maclen);

OSSL_CRMF_PBMPARAMETER *OSSL_CRMF_pbmp_new(OSSL_LIB_CTX *libctx, size_t saltlen,
                                           int owfnid, size_t itercnt,
                                           int macnid);

✨ DESCRIPTION ✨

OK so OSSL_CRMF_pbm_new() generates a PBM (Password-Based MAC) based on the given PBM parameters pbmp, the message msg, and the secret sec β€” plus their respective lengths msglen and seclen 🫢. The optional library context libctx and propq parameters may be used to influence the selection of the MAC algorithm referenced in the pbmp; go look at "ALGORITHM FETCHING" in crypto(7) for the whole tea β˜•. On success it writes the address of the newly allocated MAC via the mac reference parameter, and writes the length via the maclen reference parameter β€” unless it its NULL. 😭 (that's the wording, we don't question it, we just vibe)

And OSSL_CRMF_pbmp_new() initializes and returns a brand new PBMParameter structure, bestie, with:

  • a new random salt of length saltlen πŸ§‚
  • the OWF (one-way function) NID owfnid
  • the OWF iteration count itercnt
  • the MAC NID macnid πŸ’…

The library context libctx parameter may be used to select the provider for the random number generation (DRBG) and may be NULL for the default. periodt.


πŸ‘‘ NOTES πŸ‘‘

The algorithms for the OWF (one-way function) and for the MAC (message authentication code) may be any with a NID defined in <openssl/objects.h> 🌈. For backward compatibility with RFC 4210, these should include NID_hmac_sha1. not me reminding you about backward compat 😌

RFC 4210 recommended that the salt SHOULD be at least 8 bytes (64 bits) long β€” where 16 bytes is common. πŸ§‚βœ¨

⚠️ The iteration count must be at least 100, as stipulated by RFC 4211, and is limited to at most 100000 to avoid DoS through manipulated or otherwise malformed input. This is the "no cap" that actually matters πŸ’€ β€” see RFC 9045 for currently suggested values.

πŸ¦‹ RETURN VALUES πŸ¦‹

  • OSSL_CRMF_pbm_new() returns 1 on success, 0 on error. πŸ™ˆ
  • OSSL_CRMF_pbmp_new() returns a new and initialized OSSL_CRMF_PBMPARAMETER structure, or NULL on error. 🫢

πŸŽ€ EXAMPLES πŸŽ€

Reproduced exactly as it appears on the page, bestie β€” verbatim, no edits, we don't fix it, we just show it:

OSSL_CRMF_PBMPARAMETER *pbm = NULL;
unsigned char *msg = "Hello";
unsigned char *sec = "SeCrEt";
unsigned char *mac = NULL;
size_t maclen;

if ((pbm = OSSL_CRMF_pbmp_new(16, NID_sha256, 500, NID_hmac_sha1) == NULL))
    goto err;
if (!OSSL_CRMF_pbm_new(pbm, msg, 5, sec, 6, &mac, &maclen))
    goto err;

πŸ”₯ SEE ALSO πŸ”₯


πŸ’œ HISTORY πŸ’œ

The OpenSSL CRMF support was added in OpenSSL 3.0. ✨


Copyright 2007-2021 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 ate it πŸ“ this was OpenSSL 4.0.3, dated 2026-09-29, and it's the OSSL_CRMF_PBMP_NEW(3SSL) page β€” main character energy, no notes, bye bestie πŸ’…πŸ«Ά

πŸ“¦ where this page comes from