diff --git a/pyghmi/ipmi/private/session.py b/pyghmi/ipmi/private/session.py index 56fc0986..052d9473 100644 --- a/pyghmi/ipmi/private/session.py +++ b/pyghmi/ipmi/private/session.py @@ -19,6 +19,7 @@ import atexit import collections import fcntl import hashlib +import hmac import os import random import select @@ -27,8 +28,6 @@ import struct import threading from Crypto.Cipher import AES -from Crypto.Hash import HMAC -from Crypto.Hash import SHA import pyghmi.exceptions as exc from pyghmi.ipmi.private import constants @@ -657,10 +656,10 @@ class Session(object): message.append(7) # reserved, 7 is the required value for the # specification followed integdata = message[4:] - authcode = HMAC.new(self.k1, + authcode = hmac.new(self.k1, struct.pack("%dB" % len(integdata), *integdata), - SHA).digest()[:12] # SHA1-96 + hashlib.sha1).digest()[:12] # SHA1-96 # per RFC2404 truncates to 96 bits message += struct.unpack("12B", authcode) self.netpacket = struct.pack("!%dB" % len(message), *message) @@ -1011,8 +1010,8 @@ class Session(object): if data[5] & 0b10000000: encrypted = 1 authcode = rawdata[-12:] - expectedauthcode = HMAC.new( - self.k1, rawdata[4:-12], SHA).digest()[:12] + expectedauthcode = hmac.new( + self.k1, rawdata[4:-12], hashlib.sha1).digest()[:12] if authcode != expectedauthcode: return # BMC failed to assure integrity to us, drop it sid = struct.unpack("