ssl/statem: Replace size_t with int and add the checks
[openssl.git] / doc / man3 / PKCS12_gen_mac.pod
1 =pod
2
3 =head1 NAME
4
5 PKCS12_gen_mac, PKCS12_setup_mac, PKCS12_set_mac,
6 PKCS12_verify_mac - Functions to create and manipulate a PKCS#12 structure
7
8 =head1 SYNOPSIS
9
10  #include <openssl/pkcs12.h>
11
12  int PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen,
13                     unsigned char *mac, unsigned int *maclen);
14  int PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen);
15  int PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen,
16                     unsigned char *salt, int saltlen, int iter,
17                     const EVP_MD *md_type);
18  int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt,
19                       int saltlen, const EVP_MD *md_type);
20
21 =head1 DESCRIPTION
22
23 PKCS12_gen_mac() generates an HMAC over the entire PKCS#12 object using the
24 supplied password along with a set of already configured parameters.
25
26 PKCS12_verify_mac() verifies the PKCS#12 object's HMAC using the supplied
27 password.
28
29 PKCS12_setup_mac() sets the MAC part of the PKCS#12 structure with the supplied
30 parameters.
31
32 PKCS12_set_mac() sets the MAC and MAC parameters into the PKCS#12 object.
33
34 I<pass> is the passphrase to use in the HMAC. I<salt> is the salt value to use,
35 I<iter> is the iteration count and I<md_type> is the message digest
36 function to use.
37
38 =head1 NOTES
39
40 If I<salt> is NULL then a suitable salt will be generated and used.
41
42 If I<iter> is 1 then an iteration count will be omitted from the PKCS#12
43 structure.
44
45 PKCS12_gen_mac(), PKCS12_verify_mac() and PKCS12_set_mac() make assumptions
46 regarding the encoding of the given passphrase. See L<passphrase-encoding(7)>
47 for more information.
48
49 =head1 RETURN VALUES
50
51 All functions return 1 on success and 0 if an error occurred.
52
53 =head1 CONFORMING TO
54
55 IETF RFC 7292 (L<https://tools.ietf.org/html/rfc7292>)
56
57 =head1 SEE ALSO
58
59 L<d2i_PKCS12(3)>,
60 L<PKCS12_create(3)>,
61 L<passphrase-encoding(7)>
62
63 =head1 COPYRIGHT
64
65 Copyright 2021 The OpenSSL Project Authors. All Rights Reserved.
66
67 Licensed under the Apache License 2.0 (the "License").  You may not use
68 this file except in compliance with the License.  You can obtain a copy
69 in the file LICENSE in the source distribution or at
70 L<https://www.openssl.org/source/license.html>.
71
72 =cut