SRP_create_verifier.pod 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. =pod
  2. =head1 NAME
  3. SRP_create_verifier_ex,
  4. SRP_create_verifier,
  5. SRP_create_verifier_BN_ex,
  6. SRP_create_verifier_BN,
  7. SRP_check_known_gN_param,
  8. SRP_get_default_gN
  9. - SRP authentication primitives
  10. =head1 SYNOPSIS
  11. #include <openssl/srp.h>
  12. int SRP_create_verifier_BN_ex(const char *user, const char *pass, BIGNUM **salt,
  13. BIGNUM **verifier, const BIGNUM *N,
  14. const BIGNUM *g, OSSL_LIB_CTX *libctx,
  15. const char *propq);
  16. char *SRP_create_verifier_BN(const char *user, const char *pass, BIGNUM **salt,
  17. BIGNUM **verifier, const BIGNUM *N, const BIGNUM *g);
  18. char *SRP_create_verifier_ex(const char *user, const char *pass, char **salt,
  19. char **verifier, const char *N, const char *g,
  20. OSSL_LIB_CTX *libctx, const char *propq);
  21. char *SRP_create_verifier(const char *user, const char *pass, char **salt,
  22. char **verifier, const char *N, const char *g);
  23. char *SRP_check_known_gN_param(const BIGNUM *g, const BIGNUM *N);
  24. SRP_gN *SRP_get_default_gN(const char *id);
  25. =head1 DESCRIPTION
  26. The SRP_create_verifier_BN_ex() function creates an SRP password verifier from
  27. the supplied parameters as defined in section 2.4 of RFC 5054 using the library
  28. context I<libctx> and property query string I<propq>. Any cryptographic
  29. algorithms that need to be fetched will use the I<libctx> and I<propq>. See
  30. L<provider(7)/Fetching algorithms>.
  31. SRP_create_verifier_BN() is the same as SRP_create_verifier_BN_ex() except the
  32. default library context and property query string is used.
  33. On successful exit I<*verifier> will point to a newly allocated BIGNUM containing
  34. the verifier and (if a salt was not provided) I<*salt> will be populated with a
  35. newly allocated BIGNUM containing a random salt. If I<*salt> is not NULL then
  36. the provided salt is used instead.
  37. The caller is responsible for freeing the allocated I<*salt> and I<*verifier>
  38. BIGNUMS (use L<BN_free(3)>).
  39. The SRP_create_verifier() function is similar to SRP_create_verifier_BN() but
  40. all numeric parameters are in a non-standard base64 encoding originally designed
  41. for compatibility with libsrp. This is mainly present for historical compatibility
  42. and its use is discouraged.
  43. It is possible to pass NULL as I<N> and an SRP group id as I<g> instead to
  44. load the appropriate gN values (see SRP_get_default_gN()).
  45. If both I<N> and I<g> are NULL the 8192-bit SRP group parameters are used.
  46. The caller is responsible for freeing the allocated I<*salt> and I<*verifier>
  47. (use L<OPENSSL_free(3)>).
  48. The SRP_check_known_gN_param() function checks that I<g> and I<N> are valid
  49. SRP group parameters from RFC 5054 appendix A.
  50. The SRP_get_default_gN() function returns the gN parameters for the RFC 5054 I<id>
  51. SRP group size.
  52. The known ids are "1024", "1536", "2048", "3072", "4096", "6144" and "8192".
  53. =head1 RETURN VALUES
  54. SRP_create_verifier_BN_ex() and SRP_create_verifier_BN() return 1 on success and
  55. 0 on failure.
  56. SRP_create_verifier_ex() and SRP_create_verifier() return NULL on failure and a
  57. non-NULL value on success:
  58. "*" if I<N> is not NULL, the selected group id otherwise. This value should
  59. not be freed.
  60. SRP_check_known_gN_param() returns the text representation of the group id
  61. (i.e. the prime bit size) or NULL if the arguments are not valid SRP group parameters.
  62. This value should not be freed.
  63. SRP_get_default_gN() returns NULL if I<id> is not a valid group size,
  64. or the 8192-bit group parameters if I<id> is NULL.
  65. =head1 EXAMPLES
  66. Generate and store a 8192 bit password verifier (error handling
  67. omitted for clarity):
  68. #include <openssl/bn.h>
  69. #include <openssl/srp.h>
  70. const char *username = "username";
  71. const char *password = "password";
  72. SRP_VBASE *srpData = SRP_VBASE_new(NULL);
  73. SRP_gN *gN = SRP_get_default_gN("8192");
  74. BIGNUM *salt = NULL, *verifier = NULL;
  75. SRP_create_verifier_BN_ex(username, password, &salt, &verifier, gN->N, gN->g,
  76. NULL, NULL);
  77. SRP_user_pwd *pwd = SRP_user_pwd_new();
  78. SRP_user_pwd_set1_ids(pwd, username, NULL);
  79. SRP_user_pwd_set0_sv(pwd, salt, verifier);
  80. SRP_user_pwd_set_gN(pwd, gN->g, gN->N);
  81. SRP_VBASE_add0_user(srpData, pwd);
  82. =head1 SEE ALSO
  83. L<openssl-srp(1)>,
  84. L<SRP_VBASE_new(3)>,
  85. L<SRP_user_pwd_new(3)>
  86. =head1 HISTORY
  87. These functions were added in OpenSSL 1.0.1.
  88. =head1 COPYRIGHT
  89. Copyright 2018-2020 The OpenSSL Project Authors. All Rights Reserved.
  90. Licensed under the Apache License 2.0 (the "License"). You may not use
  91. this file except in compliance with the License. You can obtain a copy
  92. in the file LICENSE in the source distribution or at
  93. L<https://www.openssl.org/source/license.html>.
  94. =cut