def createWithDataSignBlob(blob, deviceKey=None): keybag = tlvToDict(blob) kb = Keybag(keybag["DATA"]) kb.deviceKey = deviceKey if len(keybag.get("SIGN", "")): hmackey = AESUnwrap(deviceKey, kb.attrs["HMCK"]) #hmac key and data are swapped (on purpose or by mistake ?) sigcheck = hmac.new(keybag["DATA"], hmackey, hashlib.sha1).digest() if sigcheck == keybag.get("SIGN", ""): print "Keybag: SIGN check OK" else: print "Keybag: SIGN check FAIL" return kb
def createWithDataSignBlob(blob, deviceKey=None): keybag = tlvToDict(blob) kb = Keybag(keybag.get("DATA", "")) kb.deviceKey = deviceKey kb.KeyBagKeys = blob kb.unlockAlwaysAccessible() if len(keybag.get("SIGN", "")): hmackey = AESUnwrap(deviceKey, kb.attrs["HMCK"]) #hmac key and data are swapped (on purpose or by mistake ?) sigcheck = hmac.new(keybag["DATA"], hmackey, sha1).digest() if sigcheck != keybag.get("SIGN", ""): print "Keybag: SIGN check FAIL" return kb
def createWithDataSignBlob(blob, deviceKey=None): keybag = tlvToDict(blob) kb = Keybag(keybag.get("DATA", "")) kb.deviceKey = deviceKey kb.KeyBagKeys = blob kb.unlockAlwaysAccessible() if len(keybag.get("SIGN", "")): hmackey = AESUnwrap(deviceKey, kb.attrs["HMCK"]) # hmac key and data are swapped (on purpose or by mistake ?) sigcheck = hmac.new(keybag["DATA"], hmackey, sha1).digest() if sigcheck != keybag.get("SIGN", ""): print "Keybag: SIGN check FAIL" return kb