dotnet / dotnet/dotnet-api-docs

Error in key parameter description

Open
#1,954 3 comments 0 reactions 0 assignees View on GitHub
area-System.Security dotnet-api/prod Pri2 waiting-on-feedback
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

This sentence is incorrect ... "If the key is more than 64 bytes long, it is hashed (using SHA-256) to derive a 64-byte key."

What actually happens is that if the key is longer than 64 bytes then it is SHA-256 hashed to **32** bytes (which is 256 bits), and zero padding is applied to create the 64 byte key.

Also, see this discussion that suggests that using 32bits of entropy in the HMAC key is probably OK:

[Key size for HMAC-SHA256](https://crypto.stackexchange.com/questions/34864/key-size-for-hmac-sha256)

Then again, it's possible the author(s) of HMACSHA256 intended to keep 64 bytes of entropy if more than 64 bytes are supplied, so maybe the docs are 'correct' and the implementation is wrong.

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: 7b800ca9-c626-458d-bb1f-a9f6ade40602
* Version Independent ID: 8841807e-5527-df34-4607-6a745b88f2fc
* Content: [HMACSHA256 Constructor (System.Security.Cryptography)](https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography.hmacsha256.-ctor?view=netframework-4.7.2)
* Content Source: [xml/System.Security.Cryptography/HMACSHA256.xml](https://github.com/dotnet/dotnet-api-docs/blob/master/xml/System.Security.Cryptography/HMACSHA256.xml)
* Product: **dotnet-api**
* GitHub Login: @dotnet-bot
* Microsoft Alias: **dotnetcontent**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.