pyca / pyca/pynacl

Possible inconsistency in the API

Open
#207 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
1.2k
Forks
267
Avg merge
42m
Merged PRs (30d)
2

Description

This was discussed briefly on irc.

The problem is that when using encoders for signing and verifying pynacl also uses the encoding in the message being signed or verified. Example:

> verifey_key.verify(b'Hello', signing_key.sign(b'Hello', encoder=nacl.encoding.HexEncoder).signature)
> BadSignatureError

My proposal is for pynacl not to assume anything about the encoding of the message and only use the encoding on the signature.

When signing:

signature = encoder.encode(raw_signed[:crypto_sign_BYTES])
message = raw_signed[crypto_sign_BYTES:]
signed = encoder.encode(raw_signed)

And when verifying:

if signature is not None:
    smessage = encoder.decode(signature) + smessage
else:
    smessage = encoder.decode(smessage)

I wouldn't mind creating a pull request for these changes.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from PyNaCl's signing and verification API, focusing on the encoder handling shown in the examples. Check how signing and verification currently apply encoder.encode and encoder.decode to the message and signature; done means encoded signatures verify correctly without requiring the message itself to use that encoding.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, cryptography
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.