Created
July 28, 2021 07:28
-
-
Save xperylab/67d1a6da85de27eeb65bf7b8dba68fc6 to your computer and use it in GitHub Desktop.
PM : get main key from PinProtection strategy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib | |
import plistlib | |
from Crypto.Cipher import AES | |
salt = keychainVal['PinProtection.salt'] | |
encMainKey = keychainVal['PinProtection'] | |
def getMainKeyFromPinProtection(pin): | |
iKey = hashlib.scrypt(pin, salt=salt, n=32768, r=8, p=1, maxmem=33*1024*1024, dklen=32) | |
cipher = AES.new(ikey, AES.MODE_CTR, initial_value=encMainKey[:IVsize], nonce=b'') | |
mainKey = bytes(plistlib.loads(cipher.decrypt(encMainKey[IVsize:]))) | |
return mainKey |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment