SRP_create_verifier.pod 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. =pod
  2. =head1 NAME
  3. SRP_create_verifier,
  4. SRP_create_verifier_BN,
  5. SRP_check_known_gN_param,
  6. SRP_get_default_gN
  7. - SRP authentication primitives
  8. =head1 SYNOPSIS
  9. #include <openssl/srp.h>
  10. char *SRP_create_verifier_BN(const char *user, const char *pass, BIGNUM **salt,
  11. BIGNUM **verifier, const BIGNUM *N, const BIGNUM *g);
  12. char *SRP_create_verifier(const char *user, const char *pass, char **salt,
  13. char **verifier, const char *N, const char *g);
  14. char *SRP_check_known_gN_param(const BIGNUM *g, const BIGNUM *N);
  15. SRP_gN *SRP_get_default_gN(const char *id);
  16. =head1 DESCRIPTION
  17. The SRP_create_verifier_BN() function creates an SRP password verifier from
  18. the supplied parameters as defined in section 2.4 of RFC 5054.
  19. On successful exit B<*verifier> will point to a newly allocated BIGNUM containing
  20. the verifier and (if a salt was not provided) B<*salt> will be populated with a
  21. newly allocated BIGNUM containing a random salt. If B<*salt> is not NULL then
  22. the provided salt is used instead.
  23. The caller is responsible for freeing the allocated B<*salt> and B<*verifier>
  24. BIGNUMS (use L<BN_free(3)>).
  25. The SRP_create_verifier() function is similar to SRP_create_verifier_BN() but
  26. all numeric parameters are in a non-standard base64 encoding originally designed
  27. for compatibility with libsrp. This is mainly present for historical compatibility
  28. and its use is discouraged.
  29. It is possible to pass NULL as B<N> and an SRP group id as B<g> instead to
  30. load the appropriate gN values (see SRP_get_default_gN()).
  31. If both B<N> and B<g> are NULL the 8192-bit SRP group parameters are used.
  32. The caller is responsible for freeing the allocated B<*salt> and B<*verifier>
  33. (use L<OPENSSL_free(3)>).
  34. The SRP_check_known_gN_param() function checks that B<g> and B<N> are valid
  35. SRP group parameters from RFC 5054 appendix A.
  36. The SRP_get_default_gN() function returns the gN parameters for the RFC 5054 B<id>
  37. SRP group size.
  38. The known ids are "1024", "1536", "2048", "3072", "4096", "6144" and "8192".
  39. =head1 RETURN VALUES
  40. SRP_create_verifier_BN() returns 1 on success and 0 on failure.
  41. SRP_create_verifier() returns NULL on failure and a non-NULL value on success:
  42. "*" if B<N> is not NULL, the selected group id otherwise. This value should
  43. not be freed.
  44. SRP_check_known_gN_param() returns the text representation of the group id
  45. (ie. the prime bit size) or NULL if the arguments are not valid SRP group parameters.
  46. This value should not be freed.
  47. SRP_get_default_gN() returns NULL if B<id> is not a valid group size,
  48. or the 8192-bit group parameters if B<id> is NULL.
  49. =head1 EXAMPLES
  50. Generate and store a 8192 bit password verifier (error handling
  51. omitted for clarity):
  52. #include <openssl/bn.h>
  53. #include <openssl/srp.h>
  54. const char *username = "username";
  55. const char *password = "password";
  56. SRP_VBASE *srpData = SRP_VBASE_new(NULL);
  57. SRP_gN *gN = SRP_get_default_gN("8192");
  58. BIGNUM *salt = NULL, *verifier = NULL;
  59. SRP_create_verifier_BN(username, password, &salt, &verifier, gN->N, gN->g);
  60. SRP_user_pwd *pwd = SRP_user_pwd_new();
  61. SRP_user_pwd_set1_ids(pwd, username, NULL);
  62. SRP_user_pwd_set0_sv(pwd, salt, verifier);
  63. SRP_user_pwd_set_gN(pwd, gN->g, gN->N);
  64. SRP_VBASE_add0_user(srpData, pwd);
  65. =head1 SEE ALSO
  66. L<openssl-srp(1)>,
  67. L<SRP_VBASE_new(3)>,
  68. L<SRP_user_pwd_new(3)>
  69. =head1 HISTORY
  70. These functions were added in OpenSSL 1.0.1.
  71. =head1 COPYRIGHT
  72. Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
  73. Licensed under the Apache License 2.0 (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. =cut