# Function ring::hmac::recommended_key_len [−] [src]

    pub fn recommended_key_len(digest_alg: &Algorithm) -> usize

Returns the recommended key length for HMAC using the given digest algorithm.

The value returned is the chaining length of the digest function, `digest_alg.chaining_len`. This is 32 bytes (256 bits) for SHA-256, and 64 bytes (512 bits) for SHA-384 and SHA-512.

This recommendation is based on NIST SP 800-107, Section 5.3.4: Security Effect of the HMAC Key. The chaining length of the digest algorithm, instead of its block length, is used to be consistent with the key lengths chosen for TLS for SHA-256 (see RFC 5246, Appendix C) and most other protocols.

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result
+
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)