feat(app): allow hexadecimal HMAC key specification and redact keys from debug output
This commit is contained in:
14 files changed
+72
-40
No files matched your search
@@ -0,0 +1,14 @@
|
||||
/// Decode CLI key syntax without ever including key material in diagnostics.
|
||||
pub(crate) fn decode_hmac_key(input: &str) -> Result<Vec<u8>, String> {
|
||||
let key = match input.strip_prefix("0x") {
|
||||
Some(hex) => hex::decode(hex).map_err(|_| {
|
||||
"HMAC hexadecimal key must contain an even number of valid hexadecimal digits"
|
||||
.to_owned()
|
||||
})?,
|
||||
None => input.as_bytes().to_vec(),
|
||||
};
|
||||
if key.is_empty() {
|
||||
return Err("HMAC key must not be empty".to_owned());
|
||||
}
|
||||
Ok(key)
|
||||
}
|
||||
Reference in new issue
Block a user