aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-netdoc/src/doc/authcert.rs
Commit message (Collapse)AuthorAgeFilesLines
* tor-netdoc: Use encode_netdoc_unsigned in several placesIan Jackson2026-07-231-3/+2
|
* tor-checkable: Rename `TimeBound::check_valid_*` to `if_valid_*`Ian Jackson2026-07-231-11/+11
| | | | | | | I find these names confusing. To my mind "check" implies a function returning `Result<(), _>`. Some other APIs use `unwrap` here but I think `if` is good.
* tor-checkable: TimeRangeBound: Rename extend_tolerance to extend_end_boundIan Jackson2026-07-231-2/+2
| | | | | | | | | It was confusing that one of these functions had "which bound" mentioned in its name, but the other didn't. So add `end` and switch from `tolerance` to `bound` (see previous commit message). *This* commit should deal only in `extend_tolerance` and `end` and shouldn't touch `extend_start_bound` or `extend_pre_tolerance`.
* tor-checkable: TimeRangeBound: Rename extend_pre_tolerance to extend_start_boundIan Jackson2026-07-231-2/+2
| | | | | | | | | | | | | | Although it is often used to apply a tolerance, it doesn't make sense to say that this is extending the "tolerance" of a `TimeRangeBound`. A `TimeRangeBound` doesn't have a tolerance, only bounds. Also we should be consistent in our terminology, and use `start` rather than `pre`. We'll rename the other method too. Doing them one at a time will makes it easier to spot any "pre/start" vs "<nothing>/end" slips: *this* commit should deal only in `pre` and `start` and shouldn't touch `extend_tolerance`.
* Use new TimeRangeBound name throughout the treeIan Jackson2026-07-161-7/+7
|
* Use new TimeBound name throughout the treeIan Jackson2026-07-161-2/+2
|
* tor-netdoc: Stabilise votes and encoding of authcertsIan Jackson2026-07-151-7/+0
|
* tor-netdoc: Replace string slices with str::get() in doc (fmt)Clara Engler2026-06-241-2/+7
| | | | No functional change, just reformatting.
* tor-netdoc: Replace string slices with str::get() in docClara Engler2026-06-241-4/+3
| | | | | | | | | | | | This commit replaces the use of string slices with str::get() in all document related code. While this is not a perfect replacement for it, the relevant parts in the code heavily depend upon the byte offsets returned by the low level (legacy) parser where changing it would lead to a very big refactoring. Nonetheless, this approach is better because returning a bug is better than crashing.
* tor-netdoc: tests: Move poc authcert test to authcert.rsIan Jackson2026-06-171-0/+18
| | | | | | | | There is no separate poc authcert type any more. This is a perfectly fine test case. Almost entirely code motion; review with git show --color-moved --color-moved-ws=allow-indentation-change
* tor-netdoc: Use assert_eq_or_diff in three more placesIan Jackson2026-06-111-1/+1
|
* tor-netdoc: authcert: use TimerangeBound for UnverifiedAuthCert::verify (fmt)Ian Jackson2026-06-101-94/+44
| | | | Precisely the result of rustfmt.
* tor-netdoc: authcert: use TimerangeBound for UnverifiedAuthCert::verifyIan Jackson2026-06-101-37/+47
| | | | | | | | | | | | | | TimerangeBound is reasonably nice and this will fit in better when we want to verify votes. Adjust the one non-test call site (in tor-dirserver) using .and_then. In the tests: * Where we expected success, call .check_valid_at and add another .unwrap(). * Where we expected signature verification failure, delete the time parameters. * Where we expected timeliness failure, call .check_valid_at and map the error. * With nontrivial tolerance, add calls to `extend_[pre_]tolerance`.
* tor-netdoc: authcert tests: add some parenthesesIan Jackson2026-06-101-4/+4
|
* tor-netdoc: authcert tests: insist on return value typeIan Jackson2026-06-101-5/+5
| | | | | | | We're about to make UnverifiedAuthCert::verify return a TimerangeBound, not an AuthCert. For the success cases, declare the expected return type.
* everywhere: Add #[allow(clippy::string_slice)]Clara Engler2026-06-091-0/+1
| | | | | | | | This commit adds #[allow(clippy::string_slice)] to all functions in the code where string slices are used, alongside a TODO comment. We do this add the function header to have it consistent, as things like expression based allow's are still experimental.
* maint: Run maint/add_warning to deny string slicesClara Engler2026-06-091-0/+1
| | | | | | | | | | | | This commit executes maint/add_warning with the just added change to deny string slices except in tests. I recommend auditing this by checking out the previous commit followed by running the script yourself and then verifying that the diff is identical to this commit. This commit makes cargo clippy fail. We will add exceptions in the next commit.
* tor-netdoc: Rename NetdocUnverified trait to NetdocParseableUnverifiedIan Jackson2026-06-021-1/+1
| | | | | | | | | | | | The NetdocParseableUnverified derive macro implements this trait (amongst other things). Traits and derive macros should have aligned names. This is only used for parsing, so let's keep the "Parseable" part of the name. I don't think the effort of deprecated alias, for downstream compatibility, is worth it, our compatibility policy notwithstanding.
* tor-netdoc: Apply deferred rustfmt churnIan Jackson2026-04-291-3/+5
|
* tor-netdoc: derive ItemValue parsing/encoding for SignatureIan Jackson2026-04-291-1/+0
| | | | This doesn't let us do any verification or anything.
* tor-netdoc: impl parsing/encoding for AuthCertKeyIds in directory-signatureIan Jackson2026-04-291-1/+68
| | | | | This module will be used when we derive ItemValueParseable on Signature.
* tor-netdoc: Unify authcert test modules (fmt)Ian Jackson2026-04-291-313/+308
|
* tor-netdoc: Unify authcert test modulesIan Jackson2026-04-291-32/+18
| | | | | | | | Abolish the parse2_test and encode_test modules. These mostly existed because of cfg gates. Now, we can unify the test module namespace, and also remove an indentation level (that will come next, with rustfmt).
* tor-netdoc: Gate vote-related incomplete code with "incomplete"Ian Jackson2026-04-281-1/+1
| | | | | | | | | | | Change "ns-vote" gates to "incomplete": * `vote` modules, and in the variety macro. (And make a TODO more likely to be found.) Change "parse2" gates to "incomplete": * VoteAuthoritySection
* tor-netdoc: Un-gate "plain-consensus" cargo featureIan Jackson2026-04-281-4/+4
| | | | As per #2492.
* tor-netdoc: Gate authcert/encoded.rs and poc behind incomplete and ↵Ian Jackson2026-04-231-0/+4
| | | | | | | | | plain-consensus "incomplete" is correct since encoded authcert depends on votes. "plain-consensus" is going backwards, but stripping "plain-consensus" gates from everything will be very intrusive.
* tor-netdoc: Tidy use's in authcert.rsIan Jackson2026-04-231-9/+5
|
* tor-netdoc: Un-gate parse2 and encode in authcert.rsIan Jackson2026-04-231-31/+5
|
* Merge branch 'netdoc-test-fix' into 'main'Clara Engler2026-04-081-126/+135
|\ | | | | | | | | Fix the testdata2 situation See merge request tpo/core/arti!3861
| * tor-netdoc: Remove dead authcert test codeClara Engler2026-04-081-29/+0
| | | | | | | | | | This removes unused imports as well as the read_b64 and to_der helper functions which are all no longer used.
| * tor-netdoc: Update dir_auth_cross_cert() test caseClara Engler2026-04-081-1/+12
| | | | | | | | | | | | | | | | | | | | This commit updates the dir_auth_cross_cert() test case with the new constants, replacing the longclaw ones. The replacement also involves a slight refactoring on the way how we obtain the encoded and decoded variable, namely because we have the data in a PEM encoded string now and no longer in separate file, making the use of read_b64 impossible.
| * tor-netdoc: Update invalid outer signature test caseClara Engler2026-04-081-10/+7
| | | | | | | | | | | | | | | | | | This commit updates the invalid outer signature test case by copying the outer signature of the alternative certificate into our test object, which should obviously render this to a failure. It also updates the test vectors to the constant ones because it moves away from longclaw.
| * tor-netdoc: Update the invalid cross-cert test caseClara Engler2026-04-081-10/+7
| | | | | | | | | | | | | | | | | | This commit updates the invalid cross-cert test case by copying the cross-cert from the alternative cert into our test object, resulting in a failure. Of course this also updates the other test vectors to use the constants declared above, as this moves away from longclaw.
| * tor-netdoc: Update inconsistent fingerprint test caseClara Engler2026-04-081-7/+9
| | | | | | | | | | | | | | | | | | | | This commit updates the inconsistent fingerprint test case that tests whether the fingerprint matches with the identity RSA key. For this, we load the alternative authority cert and move its identity key into the identity key of the canonical cert. Of course, this also replaces the other test vectors that are now required for this change because it moves away from longclaw.
| * tor-netdoc: Constify ALTERNATIVE_AUTHCERT_RAWClara Engler2026-04-081-0/+5
| | | | | | | | | | | | | | | | This commit adds a new constant to the parse2 authcert unit tests, ALTERNATIVE_AUTHCERT_RAW, with the idea being to be different than AUTHCERT_RAW, which we will utilize in order to mix up cross-cert objects from one authcert with the one of another one in order to see it fail.
| * tor-netdoc: Update "trivial" test cases in dir_auth_signature()Clara Engler2026-04-081-50/+20
| | | | | | | | | | | | | | | | This commit updates the "trivial" test cases in the dir_auth_signature unit tests, namely the ones concerning the outer signature as well as the timestamp tolerance. A follow-up commit will also update the more tricky ones, such as the ones testing inconsistent cross-certificates, etc.
| * tor-netdoc: Constify VALID_SYSTEM_TIMEClara Engler2026-04-081-0/+5
| | | | | | | | | | | | This commit constifies VALID_SYSTEM_TIME, a timestamp indicating a point in time at which the certificate is valid. We will need this to test timestamp validation.
| * tor-netdoc: Update test vectors in dir_auth_certClara Engler2026-04-081-15/+10
| | | | | | | | | | | | | | | | | | | | | | This commit replaces the longclaw test vectors in dir_auth_cert with the ones we constified previously and represent the ones found in testdata2/. It may look a bit odd that we replaced the file includes for the public keys but this is because those files should have never existed in testdata2/ in the first place and were only added by accident, meaning that the current approach is the correct one.
| * tor-netdoc: Remove outdated longclaw comment in testClara Engler2026-04-081-2/+0
| |
| * tor-netdoc: Replace a File::open with include_strClara Engler2026-04-081-7/+2
| | | | | | | | | | This commit replaces a File::open with the AUTHCERT_RAW constant in the dir_auth_cert test because that is obviously less error prone.
| * tor-netdoc: Constify the raw authcert test vectorClara Engler2026-04-081-0/+1
| | | | | | | | | | | | | | This commit adds `const AUTHCERT_RAW` which `include_str`'s the actual raw authcert we will use for parsing test purposes. The reason for that being that a single include_str! of the same file is obviously better than multiple ones.
| * tor-netdoc: Constify the authcert test vectorsClara Engler2026-04-081-0/+41
| | | | | | | | | | This commit constifies the authcert test vectors by extracting them from testdata2/keys/authority_certificate.
| * tor-netdoc: Add to_rsa_id() helper functionClara Engler2026-04-081-0/+7
| | | | | | | | | | | | | | | | | | This commit adds a to_rsa_id() helper function to the authcert tests in order to convert a hex-encoded RSA identity to an RsaIdentity. It will be required later on for converting the test vector values to the inner representations and this function is helpful here because it avoids us to do repetitive unwrapping and RsaIdentity::from_hex calls, which overall increase the length/readability.
| * tor-netdoc: Add pem_to_rsa_pk helper functionClara Engler2026-04-081-0/+7
| | | | | | | | | | | | | | This commit adds the pem_to_rsa_pk helper function to the authcert tests in order to convert a PEM encoded RSA public key to the internal data structure. It will be required later on in order to convert the test vector strings to internal representations.
| * tor-netdoc: Add to_system_time helper functionClara Engler2026-04-081-0/+7
| | | | | | | | | | | | | | | | This commit adds a to_system_time helper function accepting an &str in the Iso8601TimeSp format and converting it to a SystemTime to the authcert test cases. It will be required later on in order to conveniently convert human readable timestamps to the test vectors expected from parsed data.
* | tor-netdoc: parse2/encode derive: Use unquoted attributes at call sitesIan Jackson2026-04-071-1/+1
| |
* | tor-netdoc: Constructor derive: Use meta_quoted rigorousIan Jackson2026-04-071-1/+1
|/
* tor-netdoc: Gate encode_sign on plain-consensus featureIan Jackson2026-04-011-1/+4
|
* tor-netdoc: Replace AuthCert::verify_selfcert implIan Jackson2026-04-011-1/+13
| | | | | Get rid of the version in poc. Instead, implement the same functionality in terms of AuthCert::verify, outside poc.
* tor-netdoc: authcert: Test encoding and signing methodIan Jackson2026-04-011-0/+43
|