6internal sealed class RsaPaddingProcessor
10 48, 32, 48, 12, 6, 8, 42, 134, 72, 134,
11 247, 13, 2, 5, 5, 0, 4, 16
16 48, 33, 48, 9, 6, 5, 43, 14, 3, 2,
22 48, 49, 48, 13, 6, 9, 96, 134, 72, 1,
23 101, 3, 4, 2, 1, 5, 0, 4, 32
28 48, 65, 48, 13, 6, 9, 96, 134, 72, 1,
29 101, 3, 4, 2, 2, 5, 0, 4, 48
34 48, 81, 48, 13, 6, 9, 96, 134, 72, 1,
35 101, 3, 4, 2, 3, 5, 0, 4, 64
42 private readonly
int _hLen;
55 return (
int)((uint)(keySizeInBits + 7) / 8u);
67 digestInfoPrefix = s_digestInfoMD5;
71 digestInfoPrefix = s_digestInfoSha1;
75 digestInfoPrefix = s_digestInfoSha256;
79 digestInfoPrefix = s_digestInfoSha384;
83 if (!(hashAlgorithmName == HashAlgorithmName.SHA512))
85 throw new CryptographicException();
89 if (incrementalHash.TryGetHashAndReset(
destination, out var bytesWritten))
93 byte[] hashAndReset = incrementalHash.GetHashAndReset();
111 FillNonZeroBytes(data);
112 source.CopyTo(destination2);
121 int num = checked(
destination.Length - _hLen - _hLen - 2);
133 if (!incrementalHash.TryGetHashAndReset(destination2, out var bytesWritten) || bytesWritten != _hLen)
143 Mgf1(incrementalHash, span2, span);
146 Mgf1(incrementalHash, span3, span6);
184 Span<byte> destination2 = stackalloc
byte[_hLen];
200 for (
int i = 0; i < data.
Length; i++)
208 for (
int j = num + 1; j < data.
Length; j++)
212 data[num++] = data[j];
215 data = data.
Slice(num);
225 for (
int i = 0; i < b.
Length; i++)
static void WriteInt32BigEndian(Span< byte > destination, int value)
static string Cryptography_KeyTooSmall
static string Format(string resourceFormat, object p1)
static string Cryptography_Encryption_MessageTooLong
static void Return(byte[] array, int clearSize=-1)
static byte[] Rent(int minimumLength)
static void ZeroMemory(Span< byte > buffer)
static IncrementalHash CreateHash(HashAlgorithmName hashAlgorithm)
void AppendData(byte[] data)
bool TryGetHashAndReset(Span< byte > destination, out int bytesWritten)
static void Fill(Span< byte > data)
void Mgf1(IncrementalHash hasher, ReadOnlySpan< byte > mgfSeed, Span< byte > mask)
void PadOaep(ReadOnlySpan< byte > source, Span< byte > destination)
static readonly byte[] s_digestInfoSha256
static void PadPkcs1Encryption(ReadOnlySpan< byte > source, Span< byte > destination)
RsaPaddingProcessor(HashAlgorithmName hashAlgorithmName, int hLen, ReadOnlyMemory< byte > digestInfoPrefix)
static System.Security.Cryptography.RsaPaddingProcessor OpenProcessor(HashAlgorithmName hashAlgorithmName)
static readonly byte[] s_digestInfoSha512
static void Xor(Span< byte > a, ReadOnlySpan< byte > b)
readonly ReadOnlyMemory< byte > _digestInfoPrefix
static readonly byte[] s_digestInfoSha1
static int BytesRequiredForBitCount(int keySizeInBits)
static void FillNonZeroBytes(Span< byte > data)
static readonly ConcurrentDictionary< HashAlgorithmName, RsaPaddingProcessor > s_lookup
readonly HashAlgorithmName _hashAlgorithmName
static readonly byte[] s_digestInfoMD5
static readonly byte[] s_digestInfoSha384
static HashAlgorithmName SHA1
static HashAlgorithmName SHA256
static HashAlgorithmName SHA384
static HashAlgorithmName MD5
void CopyTo(Span< T > destination)
Span< T > Slice(int start)