Skip to content

Fix Ascon-80pq tag by padding key's final 4 bytes (for big-endian conv) #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 17, 2023

Conversation

wqweto
Copy link
Contributor

@wqweto wqweto commented Feb 15, 2023

Tested w/ vectors from C reference impl genkat_crypto_aead_ascon80pqv12_ref.exe like this

if __name__ == "__main__":
    variant = "Ascon-80pq"
    key   = bytes.fromhex("000102030405060708090A0B0C0D0E0F10111213")
    nonce = bytes.fromhex("000102030405060708090A0B0C0D0E0F")
    associateddata = bytes.fromhex("000102030405")
    plaintext      = bytes.fromhex("000102030405")
    ciphertext        = ascon_encrypt(key, nonce, associateddata, plaintext,  variant)
    receivedplaintext = ascon_decrypt(key, nonce, associateddata, ciphertext, variant)
    demo_print([("key", key),
                ("nonce", nonce),
                ("plaintext", plaintext),
                ("ass.data", associateddata),
                ("ciphertext", ciphertext[:-16]),
                ("tag", ciphertext[-16:]),
                ("received", receivedplaintext),
               ])

Tested w/ vectors from C reference impl `genkat_crypto_aead_ascon80pqv12_ref.exe` like this
```
if __name__ == "__main__":
    variant = "Ascon-80pq"
    key   = bytes.fromhex("000102030405060708090A0B0C0D0E0F10111213")
    nonce = bytes.fromhex("000102030405060708090A0B0C0D0E0F")
    associateddata = bytes.fromhex("000102030405")
    plaintext      = bytes.fromhex("000102030405")
    ciphertext        = ascon_encrypt(key, nonce, associateddata, plaintext,  variant)
    receivedplaintext = ascon_decrypt(key, nonce, associateddata, ciphertext, variant)
    demo_print([("key", key),
                ("nonce", nonce),
                ("plaintext", plaintext),
                ("ass.data", associateddata),
                ("ciphertext", ciphertext[:-16]),
                ("tag", ciphertext[-16:]),
                ("received", receivedplaintext),
               ])
```
Copy link
Owner

@meichlseder meichlseder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing the alignment of the key to agree with the spec!

@meichlseder meichlseder merged commit cc1a7c3 into meichlseder:master Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants