Browse Source

Merge pull request #2937 from HMBSbige/v5/master

Code optimization for SodiumIncrement
pull/2950/head
Student Main GitHub 4 years ago
parent
commit
255b465eac
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
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