equal
deleted
inserted
replaced
3011 } |
3011 } |
3012 |
3012 |
3013 /** |
3013 /** |
3014 * DANGER! UNAUTHENTICATED ENCRYPTION! |
3014 * DANGER! UNAUTHENTICATED ENCRYPTION! |
3015 * |
3015 * |
3016 * Unless you are following expert advice, do not used this feature. |
3016 * Unless you are following expert advice, do not use this feature. |
3017 * |
3017 * |
3018 * Algorithm: XSalsa20 |
3018 * Algorithm: XSalsa20 |
3019 * |
3019 * |
3020 * This DOES NOT provide ciphertext integrity. |
3020 * This DOES NOT provide ciphertext integrity. |
3021 * |
3021 * |
3110 } |
3110 } |
3111 |
3111 |
3112 /** |
3112 /** |
3113 * DANGER! UNAUTHENTICATED ENCRYPTION! |
3113 * DANGER! UNAUTHENTICATED ENCRYPTION! |
3114 * |
3114 * |
3115 * Unless you are following expert advice, do not used this feature. |
3115 * Unless you are following expert advice, do not use this feature. |
3116 * |
3116 * |
3117 * Algorithm: XChaCha20 |
3117 * Algorithm: XChaCha20 |
3118 * |
3118 * |
3119 * This DOES NOT provide ciphertext integrity. |
3119 * This DOES NOT provide ciphertext integrity. |
3120 * |
3120 * |
3531 throw new TypeError( |
3531 throw new TypeError( |
3532 'Argument 1 must be an integer, ' . gettype($numBytes) . ' given.' |
3532 'Argument 1 must be an integer, ' . gettype($numBytes) . ' given.' |
3533 ); |
3533 ); |
3534 } |
3534 } |
3535 } |
3535 } |
|
3536 /** @var positive-int $numBytes */ |
3536 if (self::use_fallback('randombytes_buf')) { |
3537 if (self::use_fallback('randombytes_buf')) { |
3537 return (string) call_user_func('\\Sodium\\randombytes_buf', $numBytes); |
3538 return (string) call_user_func('\\Sodium\\randombytes_buf', $numBytes); |
|
3539 } |
|
3540 if ($numBytes < 0) { |
|
3541 throw new SodiumException("Number of bytes must be a positive integer"); |
3538 } |
3542 } |
3539 return random_bytes($numBytes); |
3543 return random_bytes($numBytes); |
3540 } |
3544 } |
3541 |
3545 |
3542 /** |
3546 /** |