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, unsigned int *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>. Will write the adddress of the newly allocated
26 MAC via the B<mac> reference parameter and the length via the B<maclen> reference
27 parameter. Any previous pointer referred to by B<mac> will be freed if not 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 new a 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 OWF (one-way function) and for the MAC (message authentication code) may be
40 any with a NID defined in B<openssl/objects.h>,
41 which also should include NID_hmac_sha1 which is specified by RFC 4210.
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 unsigend char *sec = "SeCrEt";
57 unsigend 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 Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved.
73 Licensed under the OpenSSL license (the "License"). You may not use
74 this file except in compliance with the License. You can obtain a copy
75 in the file LICENSE in the source distribution or at
76 L<https://www.openssl.org/source/license.html>.