bogolib - Bogosoft.Security.Passwords 1.0.0.9
Contracts and implementations related to password security.
PM> Install-Package Bogosoft.Security.Passwords -Version 1.0.0.9 -Source https://www.myget.org/F/bogolib/api/v3/index.json
> nuget.exe install Bogosoft.Security.Passwords -Version 1.0.0.9 -Source https://www.myget.org/F/bogolib/api/v3/index.json
> dotnet add package Bogosoft.Security.Passwords --version 1.0.0.9 --source https://www.myget.org/F/bogolib/api/v3/index.json
source https://www.myget.org/F/bogolib/api/v3/index.json
nuget Bogosoft.Security.Passwords ~> 1.0.0.9
Copy to clipboard
> choco install Bogosoft.Security.Passwords --version 1.0.0.9 --source https://www.myget.org/F/bogolib/api/v2
Import-Module PowerShellGet
Register-PSRepository -Name "bogolib" -SourceLocation "https://www.myget.org/F/bogolib/api/v2"
Install-Module -Name "Bogosoft.Security.Passwords" -RequiredVersion "1.0.0.9" -Repository "bogolib"
Copy to clipboard
Browse the sources in this package using Visual Studio or WinDbg by configuring the following legacy symbol server URL: https://www.myget.org/F/bogolib/symbols/
Bogosoft.Security.Passwords
This project contains contracts and implementations related to password security for .NET.
Contracts
The following table lists the various contracts and their purposes that can be coded against in your application.
| Goal | Interface | Delegate |
|---|---|---|
| Compare a given salt and password to a previously hashed password. | IComparePasswords |
PasswordComparer |
| Generate a salt for use in password hashing operations. | IGenerateSalts |
SaltGenerator |
| Generate password hashes given a salt and a clear password. | IHashPasswords |
PasswordHasher |
Implementations
The following table lists the out-of-the-box concrete implementations of above interfaces.
| Name | Implemented Interfaces | Notes |
|---|---|---|
CsprngSaltGenerator |
IGenerateSalts |
Uses System.Security.Cryptography.RNGCryptoServiceProvider for salt generation. The resulting salt is random enough to be considered cryptographically secure. |
Pbkdf2PasswordHasher |
IComparePasswords, IHashPasswords |
Password comparison and hashing strategy using the password-based key derivation functionality provided by the System.Security.Cryptography.Rfc2898DeriveBytes type. |
Example Usage
The following examples are listed in the order of operations common to creating and later comparing password hashes.
Generating a Salt
// Let's make our salt twice the length of the password hash we want to end up with, which is 32.
var saltsize = 64;
// Generate the salt.
var salt = new CsprngSaltGenerator().Generate(saltsize);
Since this salt is randomly generated, you'll want to store this alongside the hashed password (which we'll be going over next) in your data storage provider of choice.
Generating a Password Hash
// Instantiate a new hash provider.
IHashPasswords hasher = new Pbkdf2PasswordHasher(saltsize / 2);
// Declare a password.
var password = "Hello, World!";
// Generate a hash against it.
var hashed = hasher.Hash(salt, password);
Obviously you'll be storing this. Don't forget to store the salt we generated earlier alongside it.
Comparing a Given Password to a Password Hash
// Instantiate a new password hash comparer.
IComparePasswords comparer = new Pbkdf2PasswordHasher(saltsize / 2);
// Perform the comparison.
if(Comparer.Compare(salt, password, hashed))
{
// Authenticated!
}
else
{
// User-given password is not a match. Don't let them in.
}
NuGet Providers
| Branch | Package ID | Feed URL |
|---|---|---|
| develop | Bogosoft.Security.Passwords |
https://www.myget.org/feed/bogolib/package/nuget/Bogosoft.Security.Passwords |
| master | Bogosoft.Security.Passwords |
https://www.nuget.org/packages/Bogosoft.Security.Passwords/ |
Additional Notes
Various QOL extension methods are included. The contracts may ask for byte arrays, but you can just as easily pass in string passwords and achieve the same results.
This project does its best to mitigate timing attacks during password hash comparison by using constant-time byte array comparisons.
- .NETFramework 4.5.2: 4.5.2.0
| Assembly | Assembly hash | Match |
|---|---|---|
| /lib/net452/bogosoft.security.passwords.dll | 9816cc5b6a9d4f07ac466562416ad0b11 |
Ownersbogocles |
AuthorsClayton Roth |
Project URLhttps://github.com/bogosoft/Security.Passwords |
LicenseMIT |
Tagshash password pbkdf2 security |
Info20 total downloads |
| 6 downloads for version 1.0.0.9 |
| Download (7.08 KB) |
| Download legacy symbols (18.88 KB) |
| Found on the current feed only |
Package history
| Version | Size | Last updated | Downloads | Mirrored? | |||
|---|---|---|---|---|---|---|---|
|
|
1.0.0.9 | 7.08 KB | Sun, 23 Jul 2017 18:31:39 GMT | 6 |
|
||
|
|
1.0.0.7 | 7.07 KB | Sun, 23 Jul 2017 17:46:11 GMT | 1 |
|
||
|
|
1.0.0.5 | 7.08 KB | Sun, 23 Jul 2017 17:36:38 GMT | 6 |
|
||
|
|
1.0.0.4 | 7.08 KB | Sun, 23 Jul 2017 08:23:15 GMT | 4 |
|
||
|
|
1.0.0.2 | 7.07 KB | Sun, 23 Jul 2017 07:33:56 GMT | 3 |
|