Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class Microsoft.​IdentityModel.​Tokens.​AsymmetricSignatureProvider
Assembly: Microsoft.IdentityModel.Tokens
Inheritance: object → SignatureProvider → AsymmetricSignatureProvider
Implemented Interfaces
- System.​IDisposable Implemented by: SignatureProvider
Provides signature and verification operations for Asymmetric Algorithms using a <see cref="T:Microsoft.IdentityModel.Tokens.SecurityKey" /> .
Fields and Constants
public static readonly
System.​Collections.​Generic.​Dictionary<​string, int>
DefaultMinimumAsymmetricKeySizeInBitsForSigningMap
Mapping from algorithm to minimum <see cref="T:Microsoft.IdentityModel.Tokens.AsymmetricSecurityKey" /> .KeySize when creating signatures.
public static readonly
System.​Collections.​Generic.​Dictionary<​string, int>
DefaultMinimumAsymmetricKeySizeInBitsForVerifyingMap
Mapping from algorithm to minimum <see cref="T:Microsoft.IdentityModel.Tokens.AsymmetricSecurityKey" /> .KeySize when verifying signatures.
Properties
public
System.​Collections.​Generic.​IReadOnlyDictionary<​string, int>
MinimumAsymmetricKeySizeInBitsForSigningMap
Gets the mapping from algorithm to the minimum <see cref="T:Microsoft.IdentityModel.Tokens.AsymmetricSecurityKey" /> .KeySize for creating signatures.
public
System.​Collections.​Generic.​IReadOnlyDictionary<​string, int>
MinimumAsymmetricKeySizeInBitsForVerifyingMap
Gets the mapping from algorithm to the minimum <see cref="T:Microsoft.IdentityModel.Tokens.AsymmetricSecurityKey" /> .KeySize for verifying signatures.
public
string
Algorithm
Gets the signature algorithm.
public
string
Context
Gets or sets a user context for a <see cref="T:Microsoft.IdentityModel.Tokens.SignatureProvider" /> .
Remarks This is null by default. This is for use by the application and not used by this SDK.
public
CryptoProviderCache
CryptoProviderCache
Gets or sets the <see cref="P:Microsoft.IdentityModel.Tokens.SignatureProvider.CryptoProviderCache" /> that is associated with this <see cref="T:Microsoft.IdentityModel.Tokens.SignatureProvider" />
public
SecurityKey
Key
Gets the <see cref="T:Microsoft.IdentityModel.Tokens.SecurityKey" /> .
public
bool
WillCreateSignatures
Gets or sets a bool indicating if this <see cref="T:Microsoft.IdentityModel.Tokens.SignatureProvider" /> is expected to create signatures.
Methods
protected
System.​Security.​Cryptography.​HashAlgorithmName
GetHashAlgorithmName​(string algorithm)
Creating a Signature requires the use of a <see cref="T:System.Security.Cryptography.HashAlgorithm" /> .
This method returns the <see cref="T:System.Security.Cryptography.HashAlgorithmName" />
that describes the <see cref="T:System.Security.Cryptography.HashAlgorithm" /> to use when generating a Signature.
Returns The <see cref="T:System.Security.Cryptography.HashAlgorithmName" /> to use.
algorithm
The SignatureAlgorithm in use.
public
bool
Sign​(System.​ReadOnlySpan<​byte> input,
System.​Span<​byte> signature,
System.​Int32& bytesWritten)
public
byte[]
Sign​(byte[] input)
Produces a signature over the 'input' using the <see cref="T:Microsoft.IdentityModel.Tokens.AsymmetricSecurityKey" /> and algorithm passed to <see cref="M:Microsoft.IdentityModel.Tokens.AsymmetricSignatureProvider.#ctor(Microsoft.IdentityModel.Tokens.SecurityKey,System.String,System.Boolean)" /> .
Returns A signature over the input.
input
The bytes to be signed.
Remarks
Sign is thread safe.
public
byte[]
Sign​(byte[] input,
int offset,
int count)
public
void
ValidateAsymmetricSecurityKeySize​(SecurityKey key,
string algorithm,
bool willCreateSignatures)
Validates that an asymmetric key size is of sufficient size for a SignatureAlgorithm.
key
The asymmetric key to validate.
algorithm
The algorithm for which this key will be used.
willCreateSignatures
If true, the provider will be used for creating signatures.
Remarks
<seealso cref="P:Microsoft.IdentityModel.Tokens.AsymmetricSignatureProvider.MinimumAsymmetricKeySizeInBitsForSigningMap" /> for minimum signing sizes.
<seealso cref="P:Microsoft.IdentityModel.Tokens.AsymmetricSignatureProvider.MinimumAsymmetricKeySizeInBitsForVerifyingMap" /> for minimum verifying sizes.
public
bool
Verify​(byte[] input,
byte[] signature)
Verifies that the <paramref name="signature" /> over <paramref name="input" /> using the
<see cref="T:Microsoft.IdentityModel.Tokens.SecurityKey" /> and <see cref="P:Microsoft.IdentityModel.Tokens.SignatureProvider.Algorithm" /> specified by this
<see cref="T:Microsoft.IdentityModel.Tokens.SignatureProvider" /> are consistent.
Returns true if signature matches, false otherwise.
input
The bytes to generate the signature over.
signature
The value to verify against.
Remarks
Verify is thread safe.
public
bool
Verify​(byte[] input,
int inputOffset,
int inputLength,
byte[] signature,
int signatureOffset,
int signatureLength)
protected
void
Dispose​(bool disposing)
Releases the resources used by the current instance.
disposing
If true, release both managed and unmanaged resources; otherwise, release only unmanaged resources.
public
void
Dispose​()
Inherited from SignatureProvider
Calls <see cref="M:Microsoft.IdentityModel.Tokens.SignatureProvider.Dispose(System.Boolean)" /> and <see cref="M:System.GC.SuppressFinalize(System.Object)" />
public
bool
Equals​(object obj)
Inherited from object
protected
void
Finalize​()
Inherited from object
public
int
GetHashCode​()
Inherited from object
protected
object
MemberwiseClone​()
Inherited from object
public
string
ToString​()
Inherited from object