Skip to content

A C# implementation of the rfc5869 HMAC based Extract-and-Expand Key Derivation Function

License

Notifications You must be signed in to change notification settings

stevewgh/HKDFrfc5869

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HKDFrfc5869

A C# implementation of the rfc5869 HMAC based Extract-and-Expand Key Derivation Function (HKDF) (https://tools.ietf.org/html/rfc5869)

Overview

  • Follows the algorithm and tests from https://tools.ietf.org/html/rfc5869
  • Uses Span for high performance
  • Extract and Expand have been combined to simplify the API, just call the DeriveKey() method

Getting started

Install-Package HKDFrfc5869

Examples

  1. Provide just the initial key material, use default values for other options
using HKDFrfc5869;

using var hkdf = new HKDF(HashAlgorithmName.SHA256);
var keyMaterial = hkdf.DeriveKey(new byte[1]);
  1. Provide a salt
using HKDFrfc5869;

using var hkdf = new HKDF(HashAlgorithmName.SHA256);
var keyMaterial = hkdf.DeriveKey(new byte[1], salt: new byte[1]);
  1. Provide a salt and info
using HKDFrfc5869;

using var hkdf = new HKDF(HashAlgorithmName.SHA256);
var keyMaterial = hkdf.DeriveKey(new byte[1], salt: new byte[1], info: new byte[1]);
  1. Provide a salt, info and request that the material is 1024 bytes in length
using HKDFrfc5869;

using var hkdf = new HKDF(HashAlgorithmName.SHA256);
var keyMaterial = hkdf.DeriveKey(new byte[1], salt: new byte[1], info: new byte[1], outputLength: 1024);
  1. Provide a salt, info and request that the material is 1024 bytes in length and use an alternative hash algorithm
using HKDFrfc5869;

using var hkdf = new HKDF(HashAlgorithmName.SHA512);
var keyMaterial = hkdf.DeriveKey(new byte[1], salt: new byte[1], info: new byte[1], outputLength: 1024);

Limitations

The algorithm defined by rfc5869 requires a single byte to be used in the intermediate hashed values, this means that the hashing algorithm can be used a maximum of 255 times. If the required keying material size is greater than 255 x the hash size then an exception will be thrown.

About

A C# implementation of the rfc5869 HMAC based Extract-and-Expand Key Derivation Function

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy