| 6 | // |
| 7 | // https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 |
| 15 | #include <openssl/rand.h> |
| 16 |
| 17 | #include "../bcm_support.h" |
| 18 | #include "internal.h" |
| 19 |
| 20 | #if defined(OPENSSL_RAND_IOS) |
| 21 | #include <stdlib.h> |
| 22 |
| 23 | #include <CommonCrypto/CommonRandom.h> |
| 24 |
| 25 | void CRYPTO_init_sysrand(void) {} |
| 26 |
| 27 | void CRYPTO_sysrand(uint8_t *out, size_t requested) { |
| 28 | if (CCRandomGenerateBytes(out, requested) != kCCSuccess) { |
| 29 | abort(); |
| 30 | } |
| 31 | } |
| 32 |
| 33 | int CRYPTO_sysrand_if_available(uint8_t *buf, size_t len) { |
| 34 | CRYPTO_sysrand(buf, len); |
| 35 | return 1; |
| 36 | } |
| 37 |
| 38 | void CRYPTO_sysrand_for_seed(uint8_t *out, size_t requested) { |
| 39 | CRYPTO_sysrand(out, requested); |
| 40 | } |
| 41 |
| 42 | #endif // OPENSSL_RAND_IOS |
| 43 |