') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); chacha20: fix big endian failure and test in CI by nstilt1 · Pull Request #447 · RustCrypto/stream-ciphers · GitHub
Skip to content

chacha20: fix big endian failure and test in CI - #447

Merged
tarcieri merged 4 commits into
RustCrypto:masterfrom
nstilt1:big-endian-testing
Aug 23, 2025
Merged

chacha20: fix big endian failure and test in CI#447
tarcieri merged 4 commits into
RustCrypto:masterfrom
nstilt1:big-endian-testing

Conversation

@nstilt1

@nstilt1nstilt1 commented Aug 23, 2025

Copy link
Copy Markdown
Contributor

Big endian tests don't currently run tests in src/rng.rs. If they did they would fail. Working on getting this yml thing working.

@nstilt1

Copy link
Copy Markdown
ContributorAuthor

Not sure why it's only running fmt and clippy

@tarcieri

Copy link
Copy Markdown
Member

Not sure why it's only running fmt and clippy

@nstilt1 yeah there's some pre-existing misconfiguration, it's missing the CI config in its triggers:

on:
pull_request:
paths:
- ".github/workflows/chacha20.yml"
- "chacha20/**"
- "Cargo.*"push:
branches: masterpaths:
- ".github/workflows/chacha20.yml"
- "chacha20/**"
- "Cargo.*"

@nstilt1

Copy link
Copy Markdown
ContributorAuthor

There we go, there are the failing tests. Do you want me to move all of the rng.rs tests to /tests now? I think it should wait until after the #439 passes because I might have added a test to rng.rs and I don't want to have to move tests in 2 PRs when I could do it in 1. It doesn't have to be done in #439 but I don't want it to be before #439.

@nstilt1 yeah there's some pre-existing misconfiguration, it's missing the CI config in its triggers:

I'm not sure what you want me to do with that... I'm new to this CI/CD stuff.

@nstilt1

Copy link
Copy Markdown
ContributorAuthor

Or should I add that big endian cfg back in this PR?

@tarcieri

Copy link
Copy Markdown
Member

#448 fixes the CI misconfiguration I noted earlier.

Thanks for reproducing the big endian failure. Now that we know it's broken if you can fix it in this same PR that'd be great, even if the fix is just changing it back to what it was before.

@tarcieritarcieri changed the title chacha20: revised big endian tests to use all featureschacha20: fix big endian failure and test in CIAug 23, 2025
@tarcieri
tarcieri merged commit b247cd5 into RustCrypto:masterAug 23, 2025
27 checks passed
Comment threadchacha20/src/rng.rs
Comment on lines +365 to +368
#[cfg(target_endian = "big")]
for word in r.0.iter_mut() {
*word = word.to_le();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is wrong: there is no type change here (u32 to u32) so there should be no endian-switch.

We also don't do this in rand_chacha.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dug through rand_chacha and ppv-lite86 for a few minutes and couldn't find anywhere with endian conversions regarding the output. But multiple tests fail on big endian. If you look closely, you can see that the bytes within the words are in reverse order. I don't know why they are in reverse order, but the tests pass as soon as to_le() is called on all of the words.

https://github.com/RustCrypto/stream-ciphers/actions/runs/17169966574/job/48717538576

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might have found the problem. Line 48 of soft.rs converts each word to little endian. Big endian code will most likely be hitting the soft.rs backend. Even if this isn't the culprit, then this part of the code should be using conditional compilation. Will change the code and run a test right quick

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep... that was it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm pretty sure the backends shouldn't be doing any endian conversions.

nstilt1 added a commit to nstilt1/stream-ciphers-rng that referenced this pull request Aug 26, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@nstilt1@tarcieri@dhardy