@@ -75,12 +75,12 @@ def gsa_authenticate(username, password, second_factor='sms'):
75
75
if "sp" not in r :
76
76
print ("Authentication Failed. Check your Apple ID and password." )
77
77
raise Exception ("AuthenticationError" )
78
- if r ["sp" ] != "s2k" :
79
- print (f"This implementation only supports s2k. Server returned { r ['sp' ]} " )
78
+ if r ["sp" ] != "s2k" and r [ "sp" ] != "s2k_fo" :
79
+ print (f"This implementation only supports s2k and s2k_fo . Server returned { r ['sp' ]} " )
80
80
return
81
81
82
82
# Change the password out from under the SRP library, as we couldn't calculate it without the salt.
83
- usr .p = encrypt_password (password , r ["s" ], r ["i" ])
83
+ usr .p = encrypt_password (password , r ["s" ], r ["i" ], r [ "sp" ] == "s2k_fo" )
84
84
85
85
M = usr .process_challenge (r ["s" ], r ["B" ])
86
86
@@ -207,8 +207,9 @@ def generate_meta_headers(serial="0", user_id=uuid.uuid4(), device_id=uuid.uuid4
207
207
}
208
208
209
209
210
- def encrypt_password (password , salt , iterations ):
211
- p = hashlib .sha256 (password .encode ("utf-8" )).digest ()
210
+ def encrypt_password (password , salt , iterations , hex = False ):
211
+ hash = hashlib .sha256 (password .encode ("utf-8" ))
212
+ p = hash .hexdigest () if hex else hash .digest ()
212
213
return pbkdf2 .PBKDF2 (p , salt , iterations , SHA256 ).read (32 )
213
214
214
215
0 commit comments