| 762 | } |
| 763 | |
| 764 | void RandBytes(unsigned char* buf, size_t num) { |
| 765 | if (num > static_cast<size_t>(std::numeric_limits<int>::max())) { |
| 766 | std::stringstream ss; |
| 767 | ss << "Length " << num << " for RandBytes overflows int"; |
| 768 | throw ParquetException(ss.str()); |
| 769 | } |
| 770 | openssl::EnsureInitialized(); |
| 771 | int status = RAND_bytes(buf, static_cast<int>(num)); |
| 772 | if (status != 1) { |
| 773 | const auto error_code = ERR_get_error(); |
| 774 | char buffer[256]; |
| 775 | ERR_error_string_n(error_code, buffer, sizeof(buffer)); |
| 776 | std::stringstream ss; |
| 777 | ss << "Failed to generate random bytes: " << buffer; |
| 778 | throw ParquetException(ss.str()); |
| 779 | } |
| 780 | } |
| 781 | |
| 782 | void EnsureBackendInitialized() { openssl::EnsureInitialized(); } |
| 783 |
no test coverage detected