Skip to content

getentropy apparently considered private on non-macOS darwin #102643

Closed
@thomcc

Description

@thomcc

Ugh. #101011 probably needs reverting before 1.65 hits stable, or Rust apps may1 fail AppStore review on iOS and tvOS.

Apparently, getentropy on Darwin platforms is actually only considered public API on MacOS. This is surprising, since there are several indications to the contrary:

  1. In the declaration in the public header (sys/random.h) on MacOS, it has a availability annotation that indicates it's fine in iOS/tvOS 10.0 and watchOS 3.0:

    int getentropy(void* buffer, size_t size) __OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0);
  2. Apple's security guidelines say to use it for random number generation.

Sadly, does seem to indeed be true that sys/random.h does not exist in any of the platform SDKs aside from MacOSX.sdk, and it also seems to have lead to one to iOS App Store rejection. TBH, it being an accidentally missing file feels plausible, but who knows and it doesn't matter anyway.

This is a bummer, and I guess now I know, I can't really trust the the available annotations anymore.

Footnotes

  1. There's actually a good chance that our use of weak! evades this detection, but I don't want to rely on this or make random Rust apps test it for us.

Metadata

Metadata

Assignees

Labels

O-iosOperating system: iOST-libsRelevant to the library team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions