SRP_VBASE_new.pod 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. =pod
  2. =head1 NAME
  3. SRP_VBASE_new,
  4. SRP_VBASE_free,
  5. SRP_VBASE_init,
  6. SRP_VBASE_add0_user,
  7. SRP_VBASE_get1_by_user,
  8. SRP_VBASE_get_by_user
  9. - Functions to create and manage a stack of SRP user verifier information
  10. =head1 SYNOPSIS
  11. #include <openssl/srp.h>
  12. SRP_VBASE *SRP_VBASE_new(char *seed_key);
  13. void SRP_VBASE_free(SRP_VBASE *vb);
  14. int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file);
  15. int SRP_VBASE_add0_user(SRP_VBASE *vb, SRP_user_pwd *user_pwd);
  16. SRP_user_pwd *SRP_VBASE_get1_by_user(SRP_VBASE *vb, char *username);
  17. SRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username);
  18. =head1 DESCRIPTION
  19. The SRP_VBASE_new() function allocates a structure to store server side SRP
  20. verifier information.
  21. If B<seed_key> is not NULL a copy is stored and used to generate dummy parameters
  22. for users that are not found by SRP_VBASE_get1_by_user(). This allows the server
  23. to hide the fact that it doesn't have a verifier for a particular username,
  24. as described in section 2.5.1.3 'Unknown SRP' of RFC 5054.
  25. The seed string should contain random NUL terminated binary data (therefore
  26. the random data should not contain NUL bytes!).
  27. The SRP_VBASE_free() function frees up the B<vb> structure.
  28. If B<vb> is NULL, nothing is done.
  29. The SRP_VBASE_init() function parses the information in a verifier file and
  30. populates the B<vb> structure.
  31. The verifier file is a text file containing multiple entries, whose format is:
  32. flag base64(verifier) base64(salt) username gNid userinfo(optional)
  33. where the flag can be 'V' (valid) or 'R' (revoked).
  34. Note that the base64 encoding used here is non-standard so it is recommended
  35. to use L<openssl-srp(1)> to generate this file.
  36. The SRP_VBASE_add0_user() function adds the B<user_pwd> verifier information
  37. to the B<vb> structure. See L<SRP_user_pwd_new(3)> to create and populate this
  38. record.
  39. The library takes ownership of B<user_pwd>, it should not be freed by the caller.
  40. The SRP_VBASE_get1_by_user() function returns the password info for the user
  41. whose username matches B<username>. It replaces the deprecated
  42. SRP_VBASE_get_by_user().
  43. If no matching user is found but a seed_key and default gN parameters have been
  44. set, dummy authentication information is generated from the seed_key, allowing
  45. the server to hide the fact that it doesn't have a verifier for a particular
  46. username. When using SRP as a TLS authentication mechanism, this will cause
  47. the handshake to proceed normally but the first client will be rejected with
  48. a "bad_record_mac" alert, as if the password was incorrect.
  49. If no matching user is found and the seed_key is not set, NULL is returned.
  50. Ownership of the returned pointer is released to the caller, it must be freed
  51. with SRP_user_pwd_free().
  52. =head1 RETURN VALUES
  53. SRP_VBASE_init() returns B<SRP_NO_ERROR> (0) on success and a positive value
  54. on failure.
  55. The error codes are B<SRP_ERR_OPEN_FILE> if the file could not be opened,
  56. B<SRP_ERR_VBASE_INCOMPLETE_FILE> if the file could not be parsed,
  57. B<SRP_ERR_MEMORY> on memory allocation failure and B<SRP_ERR_VBASE_BN_LIB>
  58. for invalid decoded parameter values.
  59. SRP_VBASE_add0_user() returns 1 on success and 0 on failure.
  60. =head1 SEE ALSO
  61. L<openssl-srp(1)>,
  62. L<SRP_create_verifier(3)>,
  63. L<SRP_user_pwd_new(3)>,
  64. L<SSL_CTX_set_srp_password(3)>
  65. =head1 HISTORY
  66. The SRP_VBASE_add0_user() function was added in OpenSSL 3.0.
  67. All other functions were added in OpenSSL 1.0.1.
  68. =head1 COPYRIGHT
  69. Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
  70. Licensed under the Apache License 2.0 (the "License"). You may not use
  71. this file except in compliance with the License. You can obtain a copy
  72. in the file LICENSE in the source distribution or at
  73. L<https://www.openssl.org/source/license.html>.
  74. =cut