Maybe I’m missing something, but I don’t see how HMACing a bad key with another short we’ll known key adds any real security benefit.
That’s interesting that you are bypassing that step as other implementations don’t always make that possible and generally seem to be treating the derived key as an implicit requirement for compatibility.
I’m not sure what existing production implementations are depending on the derived key, but it strikes me as something that would be best to move away from.
On the concern of using adequate keys, there are other options:
1) Fail on keys that are shorter than the required length instead of padding them. (This deviates from the aforementioned RFC, but in a way that makes things more secure). Ideally, you’d want this requirement to be documented and standardized so that other implementations don’t pass off a macaroon that can only be validated with an invalid key.
2) Use more realistic examples in documentation, including possibly the libsodium functions that can generate a secure key for you.
I’m currently working on a new implementation, which is where all of this is coming from. My current plan is not to include the derived key methodology in the core macaroon generation logic and instead have a separate derived key function users can use to prepare their keys if needed for compatibility.