// Note: This implementation must be thread-safe, as it is used by workers. void Crypto::getRandomValues(ArrayBufferView* array, ExceptionState& es) { if (!array || !isIntegerArray(array)) { es.throwUninformativeAndGenericDOMException(TypeMismatchError); return; } if (array->byteLength() > 65536) { es.throwUninformativeAndGenericDOMException(QuotaExceededError); return; } cryptographicallyRandomValues(array->baseAddress(), array->byteLength()); }
void Crypto::getRandomValues(ArrayBufferView* array, ExceptionCode& ec) { if (!array || !isIntegerArray(array)) { ec = TYPE_MISMATCH_ERR; return; } if (array->byteLength() > 65536) { ec = QUOTA_EXCEEDED_ERR; return; } cryptographicallyRandomValues(array->baseAddress(), array->byteLength()); }
void Crypto::getRandomValues(ArrayBufferView* array, ExceptionCode& ec) { #if USE(OS_RANDOMNESS) if (!array || !isIntegerArray(array)) { ec = TYPE_MISMATCH_ERR; return; } cryptographicallyRandomValues(array->baseAddress(), array->byteLength()); #else ASSERT_UNUSED(array, array); ec = NOT_SUPPORTED_ERR; #endif }
DOMArrayBufferView* Crypto::getRandomValues(DOMArrayBufferView* array, ExceptionState& exceptionState) { ASSERT(array); if (!isIntegerArray(array)) { exceptionState.throwDOMException(TypeMismatchError, String::format("The provided ArrayBufferView is of type '%s', which is not an integer array type.", array->typeName())); return nullptr; } if (array->byteLength() > 65536) { exceptionState.throwDOMException(QuotaExceededError, String::format("The ArrayBufferView's byte length (%u) exceeds the number of bytes of entropy available via this API (65536).", array->byteLength())); return nullptr; } cryptographicallyRandomValues(array->baseAddress(), array->byteLength()); return array; }