Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix hmac 0.13.0 API: use KeyInit::new_from_slice instead of Mac::new_…
…from_slice

Agent-Logs-Url: https://github.com/RustPython/RustPython/sessions/12c1af8b-0e94-412e-a981-fbdc9dc107f5

Co-authored-by: youknowone <69878+youknowone@users.noreply.github.com>
Signed-off-by: Padraic Fanning <27117322+fanninpm@users.noreply.github.com>
  • Loading branch information
2 people authored and fanninpm committed Apr 25, 2026
commit c1708f9fc6fdfb33675d4a8083aa8415d02182f5
6 changes: 3 additions & 3 deletions crates/stdlib/src/hashlib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub mod _hashlib {
use digest::{DynDigest, OutputSizeUser, core_api::BlockSizeUser};
use digest::{ExtendableOutput, Update};
use dyn_clone::{DynClone, clone_trait_object};
use hmac::Mac;
use hmac::{KeyInit, Mac};
use md5::Md5;
use sha1::Sha1;
use sha2::{Sha224, Sha256, Sha384, Sha512};
Expand Down Expand Up @@ -768,7 +768,7 @@ pub mod _hashlib {

macro_rules! make_hmac {
($hash_ty:ty) => {{
let mut mac = <hmac::Hmac<$hash_ty> as Mac>::new_from_slice(&key_buf)
let mut mac = <hmac::Hmac<$hash_ty> as KeyInit>::new_from_slice(&key_buf)
.map_err(|_| vm.new_value_error("invalid key length".to_owned()))?;
if let Some(ref m) = msg_data {
m.with_ref(|bytes| Mac::update(&mut mac, bytes));
Expand Down Expand Up @@ -806,7 +806,7 @@ pub mod _hashlib {

macro_rules! do_hmac {
($hash_ty:ty) => {{
let mut mac = <hmac::Hmac<$hash_ty> as Mac>::new_from_slice(&key_buf)
let mut mac = <hmac::Hmac<$hash_ty> as KeyInit>::new_from_slice(&key_buf)
.map_err(|_| vm.new_value_error("invalid key length".to_owned()))?;
Mac::update(&mut mac, &msg_buf);
Ok(mac.finalize().into_bytes().to_vec().into())
Expand Down