]> git.ipfire.org Git - thirdparty/openssl.git/blob - doc/man3/OSSL_CRMF_pbmp_new.pod
d386d2b26494a6c4e4d391ea70244fedae3ee665
[thirdparty/openssl.git] / doc / man3 / OSSL_CRMF_pbmp_new.pod
1 =pod
2
3 =head1 NAME
4
5 OSSL_CRMF_pbm_new,
6 OSSL_CRMF_pbmp_new
7 - functions for producing Password-Based MAC (PBM)
8
9 =head1 SYNOPSIS
10
11 #include <openssl/crmf.h>
12
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);
17
18 OSSL_CRMF_PBMPARAMETER *OSSL_CRMF_pbmp_new(size_t saltlen, int owfnid,
19 int itercnt, int macnid);
20
21 =head1 DESCRIPTION
22
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.
28
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
31 malformed input.
32
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>.
36
37 =head1 NOTES
38
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.
42
43 RFC 4210 recommends that the salt SHOULD be at least 8 bytes (64 bits) long.
44
45 =head1 RETURN VALUES
46
47 OSSL_CRMF_pbm_new() returns 1 on success, 0 on error.
48
49 OSSL_CRMF_pbmp_new() returns a new and initialized OSSL_CRMF_PBMPARAMETER
50 structure, or NULL on error.
51
52 =head1 EXAMPLE
53
54 OSSL_CRMF_PBMPARAMETER *pbm = NULL;
55 unsigned char *msg = "Hello";
56 unsigend char *sec = "SeCrEt";
57 unsigend char *mac = NULL;
58 unsigend int maclen;
59
60 if ((pbm = OSSL_CRMF_pbmp_new(16, NID_sha256, 500, NID_hmac_sha1) == NULL))
61 goto err;
62 if (!OSSL_CRMF_pbm_new(pbm, msg, 5, sec, 6, &mac, &maclen))
63 goto err;
64
65 =head1 SEE ALSO
66
67 RFC 4211 section 4.4
68
69 =head1 COPYRIGHT
70
71 Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved.
72
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>.
77
78 =cut