2
0

OSSL_CRMF_pbmp_new.pod 3.0 KB

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