What is the format returned by hmac's into_bytes()?

I'm implementing something similar to How to set HMAC CSRF token, after the user logs in?

but using the code the crate recommends on their docs. But

HmacSha256::new_from_sliceHmacSha256::new_from_slice(b"my secret and secure key")
    .update(b"a long string")
    .finalize()
    .to_bytes();

i'm left with:

GenericArray<u8, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>>

What is that monstrosity supposed to be?

just instantiating a Hmac::new_from_slice(), i end up with CoreWrapper<HmacCore<CoreWrapper<CtVariableCoreWrapper<Sha256VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, OidSha256>>>> Manual says it should have been Self :slight_smile:

The monstrous part is an approach to having integers in the type system that predates const generics (and is still in some ways more capable than the current minimal const support).

In this case the type represents a [u8; 32] (32 is 0b100000). You can use .into() to transform between the monstrosity and [u8; 32].

1 Like