secure-remote-password / srp.net

SRP-6a protocol implementation for .NET Standard 1.6+ and .NET Framework 3.5+

Home Page:https://www.nuget.org/packages/srp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: Methods to validate salt/verifier on sign up

alexrp opened this issue · comments

Right now, I have code looking like the following when processing sign-ups on the server:

string salt = ..., verifier = ...;

var param = SrpParameters.Create8192<SHA512>();
var valid = salt.Length == param.HashSizeBytes * 2 && verifier.Length == param.PaddedLength;

try
{
    _ = new SrpInteger(salt);
    _ = new SrpInteger(verifier);
}
catch (Exception)
{
    valid = false;
}

if (valid)
{
    // Save to DB...
}

It would be convenient if the library exposed methods to do this kind of validation.

Hello @alexrp,

What's the proposed API?
Something like this?

srpParameters.IsValidSalt(salt);
srpParameters.IsValidVerifier(verifier);

That looks reasonable.

Here you are: https://www.nuget.org/packages/srp/1.0.5

if (param.IsValidSalt(salt) && param.IsValidVerifier(verifier))
{
    // Save to DB...
}