Browse Source

Code optimization for SodiumIncrement

pull/2937/head
Bruce Wayne 4 years ago
parent
commit
ea1b906b43
No known key found for this signature in database GPG Key ID: 6D396097F05051BF
1 changed files with 3 additions and 22 deletions
  1. +3
    -22
      shadowsocks-csharp/Encryption/CryptoUtils.cs

+ 3
- 22
shadowsocks-csharp/Encryption/CryptoUtils.cs View File

@@ -49,33 +49,14 @@ namespace Shadowsocks.Encryption
return ret.AsSpan();
}

public static void SodiumIncrement(byte[] salt)
{
bool o = true; // overflow flag
for (int i = 0; i < salt.Length; i++)
{
if (!o)
{
continue;
}

salt[i]++;
o = salt[i] == 0;
}
}

public static void SodiumIncrement(Span<byte> salt)
{
bool o = true; // overflow flag
for (int i = 0; i < salt.Length; i++)
for (var i = 0; i < salt.Length; ++i)
{
if (!o)
if (++salt[i] != 0)
{
continue;
break;
}

salt[i]++;
o = salt[i] == 0;
}
}
}


Loading…
Cancel
Save