X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=vendor%2Fparagonie%2Frandom_compat%2Flib%2Frandom_bytes_com_dotnet.php;h=077fb90d1d6346e38161b6704298a91756aa77ff;hb=4e1bfbf98b844da83b18aca92ef00f11a4735806;hp=fc1926e5cac064e4f8d6190338ea3857cffa0cdf;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/vendor/paragonie/random_compat/lib/random_bytes_com_dotnet.php b/vendor/paragonie/random_compat/lib/random_bytes_com_dotnet.php index fc1926e5c..077fb90d1 100644 --- a/vendor/paragonie/random_compat/lib/random_bytes_com_dotnet.php +++ b/vendor/paragonie/random_compat/lib/random_bytes_com_dotnet.php @@ -5,7 +5,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2015 - 2017 Paragon Initiative Enterprises + * Copyright (c) 2015 - 2018 Paragon Initiative Enterprises * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -41,6 +41,7 @@ if (!is_callable('random_bytes')) { function random_bytes($bytes) { try { + /** @var int $bytes */ $bytes = RandomCompat_intval($bytes); } catch (TypeError $ex) { throw new TypeError( @@ -54,12 +55,14 @@ if (!is_callable('random_bytes')) { ); } + /** @var string $buf */ $buf = ''; if (!class_exists('COM')) { throw new Error( 'COM does not exist' ); } + /** @var COM $util */ $util = new COM('CAPICOM.Utilities.1'); $execCount = 0; @@ -68,12 +71,12 @@ if (!is_callable('random_bytes')) { * get N bytes of random data, then CAPICOM has failed us. */ do { - $buf .= base64_decode($util->GetRandom($bytes, 0)); + $buf .= base64_decode((string) $util->GetRandom($bytes, 0)); if (RandomCompat_strlen($buf) >= $bytes) { /** * Return our random entropy buffer here: */ - return RandomCompat_substr($buf, 0, $bytes); + return (string) RandomCompat_substr($buf, 0, $bytes); } ++$execCount; } while ($execCount < $bytes);