Jump to content
HWBOT Community Forums

There is an issue with the supplied data file. when uploading data file


Monabuntur

Recommended Posts

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...