2
0

OSSL_CRMF_pbmp_new.pod 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. =pod
  2. =head1 NAME
  3. OSSL_CRMF_pbm_new,
  4. OSSL_CRMF_pbmp_new
  5. - functions for producing Password-Based MAC (PBM)
  6. =head1 SYNOPSIS
  7. #include <openssl/crmf.h>
  8. int OSSL_CRMF_pbm_new(const OSSL_CRMF_PBMPARAMETER *pbmp,
  9. const unsigned char *msg, size_t msglen,
  10. const unsigned char *sec, size_t seclen,
  11. unsigned char **mac, size_t *maclen);
  12. OSSL_CRMF_PBMPARAMETER *OSSL_CRMF_pbmp_new(size_t saltlen, int owfnid,
  13. int itercnt, int macnid);
  14. =head1 DESCRIPTION
  15. OSSL_CRMF_pbm_new() generates a PBM (Password-Based MAC) based on given PBM
  16. parameters B<pbmp>, message B<msg>, and secret B<sec>, along with the respective
  17. lengths B<msglen> and B<seclen>. On success writes the address of the newly
  18. allocated MAC via the B<mac> reference parameter and writes the length via the
  19. B<maclen> reference parameter unless it its NULL.
  20. The iteration count must be at least 100, as stipulated by RFC 4211, and is
  21. limited to at most 100000 to avoid DoS through manipulated or otherwise
  22. malformed input.
  23. OSSL_CRMF_pbmp_new() initializes and returns a new PBMParameter
  24. structure with a new random salt of given length B<saltlen>, OWF (one-way
  25. function) NID B<owfnid>, iteration count B<itercnt>, and MAC NID B<macnid>.
  26. =head1 NOTES
  27. The algorithms for the OWF (one-way function) and for the MAC (message
  28. authentication code) may be any with a NID defined in B<openssl/objects.h>.
  29. As specified by RFC 4210, these should include NID_hmac_sha1.
  30. RFC 4210 recommends that the salt SHOULD be at least 8 bytes (64 bits) long.
  31. =head1 RETURN VALUES
  32. OSSL_CRMF_pbm_new() returns 1 on success, 0 on error.
  33. OSSL_CRMF_pbmp_new() returns a new and initialized OSSL_CRMF_PBMPARAMETER
  34. structure, or NULL on error.
  35. =head1 EXAMPLES
  36. OSSL_CRMF_PBMPARAMETER *pbm = NULL;
  37. unsigned char *msg = "Hello";
  38. unsigned char *sec = "SeCrEt";
  39. unsigned char *mac = NULL;
  40. size_t maclen;
  41. if ((pbm = OSSL_CRMF_pbmp_new(16, NID_sha256, 500, NID_hmac_sha1) == NULL))
  42. goto err;
  43. if (!OSSL_CRMF_pbm_new(pbm, msg, 5, sec, 6, &mac, &maclen))
  44. goto err;
  45. =head1 SEE ALSO
  46. RFC 4211 section 4.4
  47. =head1 HISTORY
  48. The OpenSSL CRMF support was added in OpenSSL 3.0.
  49. =head1 COPYRIGHT
  50. Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved.
  51. Licensed under the Apache License 2.0 (the "License"). You may not use
  52. this file except in compliance with the License. You can obtain a copy
  53. in the file LICENSE in the source distribution or at
  54. L<https://www.openssl.org/source/license.html>.
  55. =cut