-\feffusing System;
+\feff/**
+ * Novacoin classes library
+ * Copyright (C) 2015 Alex D. (balthazar.ad@gmail.com)
+
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+using System;
using System.Security.Cryptography;
namespace Novacoin
hashLength++;
}
int keyLength = dklen / hashLength;
- if ((long)dklen > (0xFFFFFFFFL * hashLength) || dklen < 0)
+ if (dklen > (0xFFFFFFFFL * hashLength) || dklen < 0)
{
throw new ArgumentOutOfRangeException("dklen");
}
{
keyLength++;
}
- byte[] extendedkey = new byte[salt.Length + 4];
+ var extendedkey = new byte[salt.Length + 4];
Buffer.BlockCopy(salt, 0, extendedkey, 0, salt.Length);
using (var ms = new System.IO.MemoryStream())
{
extendedkey[salt.Length + 3] = (byte)(((i + 1)) & 0xFF);
/* Compute U_1 = PRF(P, S || INT(i)). */
- byte[] u = hmac.ComputeHash(extendedkey);
+ var u = hmac.ComputeHash(extendedkey);
Array.Clear(extendedkey, salt.Length, 4);
/* T_i = U_1 ... */
- byte[] f = u;
+ var f = u;
for (int j = 1; j < iterationCount; j++)
{
/* Compute U_j. */
ms.Position = 0;
/* Initialize result array. */
- byte[] dk = new byte[dklen];
+ var dk = new byte[dklen];
/* Read key from memory stream. */
ms.Read(dk, 0, dklen);