Monabuntur Posted September 26, 2020 Share Posted September 26, 2020 I'm updating my benchmark to use encrypted datafiles, and I get this error when I try to upload something. Without encryption the datafiles seem to work just fine, but when I add it I get this error. I am using AES 128 CBC. this is the unencrypted .xml file datafile.xml and this is the encrypted one datafile.hwbot when it goes public I will change the key, so here it is 3778214125442A472D4B615064536756 and the initialization vector 6E5A723475377821 The iv has to be 16 bytes otherwise cryptodome, the library I use, launches an exception. this is the function that creates the .xml and encrypts it def datafile(second): time = datetime.datetime.now() submission = ET.Element('submission') application = ET.Element('application') name = ET.Element('name') version = ET.Element('version') score = ET.Element('score') points = ET.Element('points') timestamp = ET.Element('timestamp') name.text = 'PYPrime' version.text = '1.4.1' points.text = str(second) timestamp.text = str(time) submission.set('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance") submission.set('xmlns', "http://hwbot.org/submit/api?client=pyprime&clientVersion=1.4.1") submission.append(application) application.append(name) application.append(version) submission.append(score) score.append(points) submission.append(timestamp) file = open("datafile.hwbot", 'wb') file2 = open("datafile.xml", 'wb') key = b'3778214125442A472D4B615064536756' iv = b'6E5A723475377821' cipher = AES.new(key, AES.MODE_CBC, iv=iv) file.write(cipher.encrypt(pad(ET.tostring(submission, xml_declaration=True, encoding="utf-8"), 16))) file2.write(ET.tostring(submission, xml_declaration=True, encoding="utf-8")) file.close() I've been on stuck on this thing for about 10 hours, I hope someone can help me. Quote Link to comment Share on other sites More sharing options...
Monabuntur Posted September 27, 2020 Author Share Posted September 27, 2020 So after a good day of me basically wanting to die I figured out the problem, the hwbot api wants the key and initialization vector encoded in hex notation, while I have to use it in base64 inside python. That's why the iv is 32byes long in hwbot while it has to be 16 bytes long in python! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.