Skip to content
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

SPAKE2 transcript does not appear to be encoded as shown in RFC 9382 #186

Open
potto216 opened this issue Dec 28, 2024 · 2 comments
Open

Comments

@potto216
Copy link

The SPAKE2 transcript does not appear to be encoded as shown in RFC 9382 section 3.3 because the order of the transcript elements and what is being hashed for those elements is different.

It looks like in the SPAKE2 code the transcript is computed in finish which calls either hash_ab or hash_symmetric
and they are forming the transcript from first the hash of the password and then the hash of the identities (below).

    let mut transcript = [0u8; 6 * 32];

    let mut pw_hash = Sha256::new();
    pw_hash.update(password_vec);
    transcript[0..32].copy_from_slice(&pw_hash.finalize());

    let mut ida_hash = Sha256::new();
    ida_hash.update(id_a);
    transcript[32..64].copy_from_slice(&ida_hash.finalize());

    let mut idb_hash = Sha256::new();
    idb_hash.update(id_b);
    transcript[64..96].copy_from_slice(&idb_hash.finalize());
...

But this differs from section 3.3 of the RFC because the transcript TT is encoded as:

        TT = len(A)  || A
          || len(B)  || B
          || len(pA) || pA
          || len(pB) || pB
          || len(K)  || K
          || len(w)  || w

where A and B are the identities and the pA and pB are hashes of the password hash multiplied by a point on the elliptic curve and added to another random point on the elliptic curve.

I'm happy to continue the analysis and write a fix, but I want to make sure this is a valid issue first

@tarcieri
Copy link
Member

tarcieri commented Jan 3, 2025

If you can help make our implementation RFC9382 compliant, great

@potto216
Copy link
Author

potto216 commented Jan 5, 2025

Okay great, I'll work on a PR with potential changes to discuss.

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

No branches or pull requests

2 participants