Skip to content

add X25519 test vectors from RFC 7748 section 5.2 - #3685

Merged
alex merged 1 commit into
pyca:masterfrom
reaperhulk:x25519-vectors
Jun 6, 2017
Merged

alex merged 1 commit into
pyca:masterfrom
reaperhulk:x25519-vectors

Conversation

@reaperhulk

Copy link
Copy Markdown
Member

This adds 3 of the 5 x25519 test vectors from RFC 7748. The 4th is a 1000 iteration test that I have encoded directly in the code (currently looks like this):

        old_private = private = public = binascii.unhexlify(
            b"090000000000000000000000000000000000000000000000000000000000"
            b"0000"
        )
        shared_key = binascii.unhexlify(
            b"684cf59ba83309552800ef566f2f4d3c1c3887c49360e3875f2eb94d9953"
            b"2c51"
        )
        private_key = X25519PrivateKey._from_private_bytes(private)
        public_key = X25519PublicKey.from_public_bytes(public)
        for _ in range(1000):
            computed_shared_key = private_key.exchange(public_key)
            private_key = X25519PrivateKey._from_private_bytes(
                computed_shared_key
            )
            public_key = X25519PublicKey.from_public_bytes(old_private)
            old_private = computed_shared_key

        assert computed_shared_key == shared_key

And the 5th is the same test but with 1 million iterations. I don't think I want to include that test in our primary suite since it takes over 220s to run on my laptop.

@mention-bot

Copy link
Copy Markdown

@reaperhulk, thanks for your PR! By analyzing the history of the files in this pull request, we identified @public, @alex and @Ayrx to be potential reviewers.

@reaperhulk reaperhulk mentioned this pull request Jun 6, 2017
@alex
alex merged commit cfdc605 into pyca:master Jun 6, 2017
@reaperhulk
reaperhulk deleted the x25519-vectors branch June 7, 2017 05:40
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants