Skip to content

Commit 27edb04

Browse files
keegan-carusoKeegan Caruso
and
Keegan Caruso
authored
Move virtual methods to public in Signature Provider (#2497)
These methods need to be moved to public so that the extensibility story works for user provider signature providers. Co-authored-by: Keegan Caruso <[email protected]>
1 parent d5dc77e commit 27edb04

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

src/Microsoft.IdentityModel.Tokens/AsymmetricSignatureProvider.cs

+4-9
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,8 @@ internal bool ValidKeySize()
195195
internal override int ObjectPoolSize => _asymmetricAdapterObjectPool.Size;
196196

197197
#if NET6_0_OR_GREATER
198-
/// <summary>
199-
/// This must be overridden to produce a signature over the 'input'.
200-
/// </summary>
201-
/// <param name="input">bytes to sign.</param>
202-
/// <param name="signature">pre allocated span where signature bytes will be placed.</param>
203-
/// <param name="bytesWritten">number of bytes written into the signature span.</param>
204-
/// <returns>returns true if creation of signature succeeded, false otherwise.</returns>
205-
internal override bool Sign(ReadOnlySpan<byte> input, Span<byte> signature, out int bytesWritten)
198+
/// <inheritdoc/>
199+
public override bool Sign(ReadOnlySpan<byte> input, Span<byte> signature, out int bytesWritten)
206200
{
207201
if (input == null || input.Length == 0)
208202
throw LogHelper.LogArgumentNullException(nameof(input));
@@ -273,7 +267,8 @@ public override byte[] Sign(byte[] input)
273267
}
274268
}
275269

276-
internal override byte[] Sign(byte[] input, int offset, int count)
270+
/// <inheritdoc/>
271+
public override byte[] Sign(byte[] input, int offset, int count)
277272
{
278273
if (input == null || input.Length == 0)
279274
throw LogHelper.LogArgumentNullException(nameof(input));

src/Microsoft.IdentityModel.Tokens/SignatureProvider.cs

+18-2
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,36 @@ internal int Release()
9595
/// <returns>signed bytes</returns>
9696
public abstract byte[] Sign(byte[] input);
9797

98-
internal virtual byte[] Sign(byte[] input, int offset, int count)
98+
/// <summary>
99+
/// Produces a signature over the specified region of the <paramref name="input"/>.
100+
/// </summary>
101+
/// <param name="input">The bytes to produce a signature over.</param>
102+
/// <param name="offset">The offset to specify the beginning of the region.</param>
103+
/// <param name="count">The count to specify the end of the region.</param>
104+
/// <returns>The signature bytes.</returns>
105+
public virtual byte[] Sign(byte[] input, int offset, int count)
99106
{
100107
throw LogHelper.LogExceptionMessage(new NotImplementedException());
101108
}
102109

103110
#if NET6_0_OR_GREATER
104-
internal virtual bool Sign(ReadOnlySpan<byte> data, Span<byte> destination, out int bytesWritten)
111+
/// <summary>
112+
/// Produces a signature over the <paramref name="data"/> and writes it to <paramref name="destination"/>.
113+
/// </summary>
114+
/// <param name="data">The bytes to produce a signature over.</param>
115+
/// <param name="destination">The pre-allocated span where signature bytes will be placed.</param>
116+
/// <param name="bytesWritten">The number of bytes written into the signature span.</param>
117+
/// <returns>returns <see langword="true"/> if creation of signature succeeded, <see langword="false"/> otherwise.</returns>
118+
public virtual bool Sign(ReadOnlySpan<byte> data, Span<byte> destination, out int bytesWritten)
105119
{
106120
throw LogHelper.LogExceptionMessage(new NotImplementedException());
107121
}
108122
#endif
123+
/// <summary>
109124
/// Verifies that the <paramref name="signature"/> over <paramref name="input"/> using the
110125
/// <see cref="SecurityKey"/> and <see cref="SignatureProvider.Algorithm"/> specified by this
111126
/// <see cref="SignatureProvider"/> are consistent.
127+
/// </summary>
112128
/// <param name="input">the bytes that were signed.</param>
113129
/// <param name="signature">signature to compare against.</param>
114130
/// <returns>true if the computed signature matches the signature parameter, false otherwise.</returns>

src/Microsoft.IdentityModel.Tokens/SymmetricSignatureProvider.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ public override byte[] Sign(byte[] input)
204204
}
205205

206206
#if NET6_0_OR_GREATER
207-
internal override bool Sign(ReadOnlySpan<byte> input, Span<byte> signature, out int bytesWritten)
207+
/// <inheritdoc/>
208+
public override bool Sign(ReadOnlySpan<byte> input, Span<byte> signature, out int bytesWritten)
208209
{
209210
if (input == null || input.Length == 0)
210211
throw LogHelper.LogArgumentNullException(nameof(input));
@@ -235,7 +236,8 @@ internal override bool Sign(ReadOnlySpan<byte> input, Span<byte> signature, out
235236
}
236237
#endif
237238

238-
internal override byte[] Sign(byte[] input, int offset, int count)
239+
/// <inheritdoc/>
240+
public override byte[] Sign(byte[] input, int offset, int count)
239241
{
240242
if (input == null || input.Length == 0)
241243
throw LogHelper.LogArgumentNullException(nameof(input));

0 commit comments

Comments
 (0)