Skip to content

std: add CCRandomGenerateBytes macOs native api.#15317

Merged
Vexu merged 2 commits intoziglang:masterfrom
devnexen:darwin_rand_nativegen
May 5, 2023
Merged

std: add CCRandomGenerateBytes macOs native api.#15317
Vexu merged 2 commits intoziglang:masterfrom
devnexen:darwin_rand_nativegen

Conversation

@devnexen
Copy link
Copy Markdown
Contributor

No description provided.

@devnexen
Copy link
Copy Markdown
Contributor Author

cc @kubkon

I think it can replace, for iOs/macOs only tough, the actual arc4random_buf call from the getrandom wrapper for similar reasons as openssl did (e.g. this call returning a status, possible issue with no len with arc4random_buf, ...), what do you think ?

@kubkon
Copy link
Copy Markdown
Member

kubkon commented Apr 16, 2023

cc @kubkon

I think it can replace, for iOs/macOs only tough, the actual arc4random_buf call from the getrandom wrapper for similar reasons as openssl did (e.g. this call returning a status, possible issue with no len with arc4random_buf, ...), what do you think ?

If this is what openssl did I think it's a good idea. @jedisct1 thoughts?

@jedisct1
Copy link
Copy Markdown
Contributor

As far as I know the underlying RNG is exactly the same. The only difference being that using that API increases the chances of getting an app accepted on the App Store.

Still not a bad thing.

@kubkon
Copy link
Copy Markdown
Member

kubkon commented Apr 16, 2023

Mhm, I see. Is there a minimum OS version where this is available? If this is a fairly recent addition we need to either version-gate, or wait a couple of macOS releases for it to be supported across the latest OS versions.

@devnexen
Copy link
Copy Markdown
Contributor Author

Since Yosemite/iOs 8.

@kubkon
Copy link
Copy Markdown
Member

kubkon commented Apr 16, 2023

Just to double check, CCRandomGenerateBytes is part of libSystem and not of Security.framework?

@devnexen
Copy link
Copy Markdown
Contributor Author

not part of Security.framework.

@kubkon
Copy link
Copy Markdown
Member

kubkon commented Apr 16, 2023

In that case I would be in favour of moving from arc4random_buf to CCRandomGenerateBytes. Also, as per https://www.niap-ccevs.org/Documents_and_Guidance/view_td.cfm?TD=0510 it's apparently faster and as per microsoft/mimalloc#390 it doesn't silently fail unlike the old interface.

@devnexen
Copy link
Copy Markdown
Contributor Author

@kubkon what do you think now ? 🙂

@kubkon
Copy link
Copy Markdown
Member

kubkon commented Apr 22, 2023

Are the macOS CI failures related?

@devnexen
Copy link
Copy Markdown
Contributor Author

does not seem to be the case, beside it happens only on x86 64 arch.

@devnexen
Copy link
Copy Markdown
Contributor Author

seems all pass @kubkon 🙂

@devnexen
Copy link
Copy Markdown
Contributor Author

devnexen commented May 5, 2023

cc @Vexu 🙂

@Vexu Vexu merged commit a111130 into ziglang:master May 5, 2023
andrewrk added a commit that referenced this pull request Jul 31, 2023
LinuxUserGD pushed a commit to LinuxUserGD/zig that referenced this pull request Aug 2, 2023
…tivegen"

This reverts commit a111130, reversing
changes made to 9f3f9fb.
QusaiHroub pushed a commit to QusaiHroub/zig that referenced this pull request Aug 3, 2023
…tivegen"

This reverts commit a111130, reversing
changes made to 9f3f9fb.
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

Successfully merging this pull request may close these issues.

4 participants