If the key is longer than HMAC support, it will usually be hashed to the desired size. This is mainly for supporting human-readable keys of arbitrary lengths. If you generate the key programmatically and do not need it to be human readable, I would recommend using RandomNumberGenerator . This is basically what it was made for.
using System.Security.Cryptography; RandomNumberGenerator rng = RandomNumberGenerator.Create(); byte[] data = new byte[32]; rng.GetBytes(data);
source share