7 - functions for producing Password-Based MAC (PBM)
11 #include <openssl/crmf.h>
13 int OSSL_CRMF_pbm_new(const OSSL_CRMF_PBMPARAMETER *pbmp,
14 const unsigned char *msg, size_t msglen,
15 const unsigned char *sec, size_t seclen,
16 unsigned char **mac, size_t *maclen);
18 OSSL_CRMF_PBMPARAMETER *OSSL_CRMF_pbmp_new(size_t saltlen, int owfnid,
19 int itercnt, int macnid);
23 OSSL_CRMF_pbm_new() generates a PBM (Password-Based MAC) based on given PBM
24 parameters B<pbmp>, message B<msg>, and secret B<sec>, along with the respective
25 lengths B<msglen> and B<seclen>. On success writes the address of the newly
26 allocated MAC via the B<mac> reference parameter and writes the length via the
27 B<maclen> reference parameter unless it its NULL.
29 The iteration count must be at least 100, as stipulated by RFC 4211, and is
30 limited to at most 100000 to avoid DoS through manipulated or otherwise
33 OSSL_CRMF_pbmp_new() initializes and returns a new PBMParameter
34 structure with a new random salt of given length B<saltlen>, OWF (one-way
35 function) NID B<owfnid>, iteration count B<itercnt>, and MAC NID B<macnid>.
39 The algorithms for the OWF (one-way function) and for the MAC (message
40 authentication code) may be any with a NID defined in B<openssl/objects.h>.
41 As specified by RFC 4210, these should include NID_hmac_sha1.
43 RFC 4210 recommends that the salt SHOULD be at least 8 bytes (64 bits) long.
47 OSSL_CRMF_pbm_new() returns 1 on success, 0 on error.
49 OSSL_CRMF_pbmp_new() returns a new and initialized OSSL_CRMF_PBMPARAMETER
50 structure, or NULL on error.
54 OSSL_CRMF_PBMPARAMETER *pbm = NULL;
55 unsigned char *msg = "Hello";
56 unsigned char *sec = "SeCrEt";
57 unsigned char *mac = NULL;
60 if ((pbm = OSSL_CRMF_pbmp_new(16, NID_sha256, 500, NID_hmac_sha1) == NULL))
62 if (!OSSL_CRMF_pbm_new(pbm, msg, 5, sec, 6, &mac, &maclen))
71 The OpenSSL CRMF support was added in OpenSSL 3.0.
75 Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved.
77 Licensed under the Apache License 2.0 (the "License"). You may not use
78 this file except in compliance with the License. You can obtain a copy
79 in the file LICENSE in the source distribution or at
80 L<https://www.openssl.org/source/license.html>.