From: Antoine Salon Date: Thu, 1 Nov 2018 18:56:55 +0000 (-0700) Subject: Added SRP_VBASE_add0_user() X-Git-Tag: openssl-3.0.0-alpha1~2895 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=51f03f12270cdebf1dff140cc17925991520fb77;p=oweals%2Fopenssl.git Added SRP_VBASE_add0_user() Signed-off-by: Antoine Salon Reviewed-by: Paul Dale Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/7522) --- diff --git a/crypto/srp/srp_vfy.c b/crypto/srp/srp_vfy.c index 622fffbcd0..397d26c9d7 100644 --- a/crypto/srp/srp_vfy.c +++ b/crypto/srp/srp_vfy.c @@ -514,6 +514,13 @@ static SRP_user_pwd *find_user(SRP_VBASE *vb, char *username) return NULL; } +int SRP_VBASE_add0_user(SRP_VBASE *vb, SRP_user_pwd *user_pwd) +{ + if (sk_SRP_user_pwd_push(vb->users_pwd, user_pwd) <= 0) + return 0; + return 1; +} + # if OPENSSL_API_COMPAT < 0x10100000L /* * DEPRECATED: use SRP_VBASE_get1_by_user instead. diff --git a/doc/man3/SRP_VBASE_new.pod b/doc/man3/SRP_VBASE_new.pod index b235e58710..76044ac451 100644 --- a/doc/man3/SRP_VBASE_new.pod +++ b/doc/man3/SRP_VBASE_new.pod @@ -6,6 +6,7 @@ SRP_VBASE_new, SRP_VBASE_free, SRP_user_pwd_free, SRP_VBASE_init, +SRP_VBASE_add0_user, SRP_VBASE_get1_by_user, SRP_VBASE_get_by_user - Functions to create and manage a stack of SRP user verifier information @@ -20,6 +21,7 @@ SRP_VBASE_get_by_user int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file); + int SRP_VBASE_add0_user(SRP_VBASE *vb, SRP_user_pwd *user_pwd); SRP_user_pwd *SRP_VBASE_get1_by_user(SRP_VBASE *vb, char *username); SRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username); @@ -47,6 +49,10 @@ where the flag can be 'V' (valid) or 'R' (revoked). Note that the base64 encoding used here is non-standard so it is recommended to use L to generate this file. +The SRP_VBASE_add0_user() function adds the B verifier information +to the B structure. +The library takes ownership of B, it should not be freed by the caller. + The SRP_VBASE_get1_by_user() function returns the password info for the user whose username matches B. It replaces the deprecated SRP_VBASE_get_by_user(). @@ -69,6 +75,8 @@ B if the file could not be parsed, B on memory allocation failure and B for invalid decoded parameter values. +SRP_VBASE_add0_user() returns 1 on success and 0 on failure. + =head1 SEE ALSO L, @@ -77,7 +85,9 @@ L =head1 HISTORY -These functions were first added to OpenSSL 1.0.1. +SRP_VBASE_add0_user() was first added to OpenSSL 1.2.0. + +All other functions were first added to OpenSSL 1.0.1. =head1 COPYRIGHT diff --git a/doc/man3/SRP_create_verifier.pod b/doc/man3/SRP_create_verifier.pod index 9741c5c47c..f899b2471a 100644 --- a/doc/man3/SRP_create_verifier.pod +++ b/doc/man3/SRP_create_verifier.pod @@ -90,7 +90,7 @@ omitted for clarity): pwd->v = verifier; pwd->info = NULL; - sk_SRP_user_pwd_push(srpData->users_pwd, pwd); + SRP_VBASE_add0_user(srpData, pwd); =head1 SEE ALSO diff --git a/include/openssl/srp.h b/include/openssl/srp.h index aaf13558e3..8189d3e403 100644 --- a/include/openssl/srp.h +++ b/include/openssl/srp.h @@ -75,6 +75,7 @@ SRP_VBASE *SRP_VBASE_new(char *seed_key); void SRP_VBASE_free(SRP_VBASE *vb); int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file); +int SRP_VBASE_add0_user(SRP_VBASE *vb, SRP_user_pwd *user_pwd); /* This method ignores the configured seed and fails for an unknown user. */ DEPRECATEDIN_1_1_0(SRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username)) /* NOTE: unlike in SRP_VBASE_get_by_user, caller owns the returned pointer.*/ diff --git a/util/libcrypto.num b/util/libcrypto.num index c6de172f8e..c1c90110a8 100644 --- a/util/libcrypto.num +++ b/util/libcrypto.num @@ -4598,3 +4598,4 @@ EVP_MAC_do_all_sorted 4551 1_1_2 EXIST::FUNCTION: EVP_str2ctrl 4552 1_1_2 EXIST::FUNCTION: EVP_hex2ctrl 4553 1_1_2 EXIST::FUNCTION: EVP_PKEY_supports_digest_nid 4554 1_1_2 EXIST::FUNCTION: +SRP_VBASE_add0_user 4555 1_1_2 EXIST::FUNCTION:SRP