1
1
Fork
You've already forked tsp-http-client
0

Nonce implementation might be buggy #1

Open
opened 2025年11月10日 08:48:41 +01:00 by wolfvollprecht · 4 comments

I've been working on sigstore-rs and had issues with the nonce generation.

I believe your implementation might also suffer from a bug: When nonce[0] has values 0x80-0xFF (50% of the time), the Int will be interpreted as negative, which violates the RFC 3161 requirement that nonces be positive integers.

Here is a patch that was added to the Python library: https://github.com/trailofbits/rfc3161-client/pull/33/files

I've been working on sigstore-rs and had issues with the nonce generation. I believe your implementation might also suffer from a bug: When nonce[0] has values 0x80-0xFF (50% of the time), the Int will be interpreted as negative, which violates the RFC 3161 requirement that nonces be positive integers. Here is a patch that was added to the Python library: https://github.com/trailofbits/rfc3161-client/pull/33/files

Thank you a lot for the hint! I will have a look regarding my implementation.

Thank you a lot for the hint! I will have a look regarding my implementation.

Thanks!

Thanks!

I checked the RFC 3161 again and couldn't find a requirement for the nonce being a positive integer value. The example in the definition even mentions a signed type:

The nonce is a large random number with a high probability that the client generates it only once (e.g., a 64 bit integer).

Maybe I am missing something there. Can you give me a hint from where the requirement for a positive value can be derived, @wolfvollprecht?

I checked the RFC 3161 again and couldn't find a requirement for the nonce being a positive integer value. The example in the definition even mentions a signed type: > The nonce is a large random number with a high probability that the client generates it only once (e.g., a 64 bit integer). Maybe I am missing something there. Can you give me a hint from where the requirement for a positive value can be derived, @wolfvollprecht?

I can't really, just that the https://timestamp.sigstore.dev/api/v1/timestamp endpoint seemed to reject nonces with negative values.

Our working implementation (similar to trail of bits) here: github.com/prefix-dev/sigstore-rust@3818f0afd0/crates/sigstore-tsa/src/asn1.rs

I can't really, just that the `https://timestamp.sigstore.dev/api/v1/timestamp` endpoint seemed to reject nonces with negative values. Our working implementation (similar to trail of bits) here: https://github.com/prefix-dev/sigstore-rust/blob/3818f0afd00b9031fc1dcb5984c110b1efca7a8a/crates/sigstore-tsa/src/asn1.rs
Sign in to join this conversation.
No Branch/Tag specified
main
v0.1.0
Labels
Clear labels
Compat/Breaking
Breaking change that won't be backward compatible
Kind/Bug
Something is not working
Kind/Documentation
Documentation changes
Kind/Enhancement
Improve existing functionality
Kind/Feature
New functionality
Kind/Security
This is security issue
Kind/Testing
Issue or pull request related to testing
Priority
Critical
The priority is critical
Priority
High
The priority is high
Priority
Low
The priority is low
Priority
Medium
The priority is medium
Reviewed
Confirmed
Issue has been confirmed
Reviewed
Duplicate
This issue or pull request already exists
Reviewed
Invalid
Invalid issue
Reviewed
Won't Fix
This issue won't be fixed
Status
Abandoned
Somebody has started to work on this but abandoned work
Status
Blocked
Something is blocking this issue or pull request
Status
Need More Info
Feedback is required to reproduce issue or to continue work
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
winterstein/tsp-http-client#1
Reference in a new issue
winterstein/tsp-http-client
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?