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.​SymmetricSignatureProvider

Assembly: Microsoft.IdentityModel.Tokens

Inheritance: object → SignatureProvider → SymmetricSignatureProvider

Implemented Interfaces

Provides signing and verifying operations using a <see cref="T:Microsoft.IdentityModel.Tokens.SymmetricSecurityKey" /> and specifying an algorithm.

Fields and Constants

public static readonly int
DefaultMinimumSymmetricKeySizeInBits
This is the minimum <see cref="T:Microsoft.IdentityModel.Tokens.SymmetricSecurityKey" /> .KeySize when creating and verifying signatures.

Properties

public int
MinimumSymmetricKeySizeInBits
Gets or sets the minimum <see cref="T:Microsoft.IdentityModel.Tokens.SymmetricSecurityKey" /> .KeySize"/&gt;.
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.
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 byte[]
GetKeyBytes​(SecurityKey key)
Called to obtain the byte[] needed to create a <see cref="T:System.Security.Cryptography.KeyedHashAlgorithm" />
Returns <see cref="T:System.Byte" /> [] that is used to populated the KeyedHashAlgorithm.
key <see cref="T:Microsoft.IdentityModel.Tokens.SecurityKey" /> that will be used to obtain the byte[].
Remarks <see cref="T:Microsoft.IdentityModel.Tokens.SymmetricSecurityKey" /> and <see cref="T:Microsoft.IdentityModel.Tokens.JsonWebKey" /> are supported. <para>For a <see cref="T:Microsoft.IdentityModel.Tokens.SymmetricSecurityKey" /> .Key is returned</para> <para>For a <see cref="T:Microsoft.IdentityModel.Tokens.JsonWebKey" />Base64UrlEncoder.DecodeBytes is called with <see cref="P:Microsoft.IdentityModel.Tokens.JsonWebKey.K" /> if <see cref="P:Microsoft.IdentityModel.Tokens.JsonWebKey.Kty" /> == JsonWebAlgorithmsKeyTypes.Octet</para>
GetKeyedHashAlgorithm​(byte[] keyBytes, string algorithm)
Returns a <see cref="T:System.Security.Cryptography.KeyedHashAlgorithm" /> . This method is called just before a cryptographic operation. This provides the opportunity to obtain the <see cref="T:System.Security.Cryptography.KeyedHashAlgorithm" /> from an object pool. If this method is overridden, it is importont to override <see cref="M:Microsoft.IdentityModel.Tokens.SymmetricSignatureProvider.ReleaseKeyedHashAlgorithm(System.Security.Cryptography.KeyedHashAlgorithm)" /> if custom releasing of the <see cref="T:System.Security.Cryptography.KeyedHashAlgorithm" /> is desired.
Returns An instance of <see cref="T:System.Security.Cryptography.KeyedHashAlgorithm" />
keyBytes The byte array of the key.
algorithm The hash algorithm to use to create the hash value.
protected void
ReleaseKeyedHashAlgorithm​(System.​Security.​Cryptography.​KeyedHashAlgorithm keyedHashAlgorithm)
This method is called just after the cryptographic operation. If <see cref="M:Microsoft.IdentityModel.Tokens.SymmetricSignatureProvider.GetKeyedHashAlgorithm(System.Byte[],System.String)" /> was overridden this method can be overridden for any custom handling such as returning the <see cref="T:System.Security.Cryptography.KeyedHashAlgorithm" /> to an object pool.
keyedHashAlgorithm The <see cref="T:System.Security.Cryptography.KeyedHashAlgorithm" /> " in use.
public byte[]
Sign​(byte[] input)
Produces a signature over the 'input' using the <see cref="T:Microsoft.IdentityModel.Tokens.SymmetricSecurityKey" /> and 'algorithm' passed to <see cref="M:Microsoft.IdentityModel.Tokens.SymmetricSignatureProvider.#ctor(Microsoft.IdentityModel.Tokens.SecurityKey,System.String)" /> .
Returns Signed bytes
input The bytes to sign.
Remarks Sign is thread safe.
public bool
Sign​(System.​ReadOnlySpan<​byte> input, System.​Span<​byte> signature, System.​Int32& bytesWritten)
public byte[]
Sign​(byte[] input, int offset, int count)
public bool
Verify​(byte[] input, byte[] signature)
Verifies that a signature created over the 'input' matches the signature. Using <see cref="T:Microsoft.IdentityModel.Tokens.SymmetricSecurityKey" /> and 'algorithm' passed to <see cref="M:Microsoft.IdentityModel.Tokens.SymmetricSignatureProvider.#ctor(Microsoft.IdentityModel.Tokens.SecurityKey,System.String)" /> .
Returns true if computed signature matches the signature parameter, false otherwise.
input The bytes to verify.
signature signature to compare against.
Remarks Verify is thread safe.
public bool
Verify​(byte[] input, byte[] signature, int length)
Verifies that a signature created over the 'input' matches the signature. Using <see cref="T:Microsoft.IdentityModel.Tokens.SymmetricSecurityKey" /> and 'algorithm' passed to <see cref="M:Microsoft.IdentityModel.Tokens.SymmetricSignatureProvider.#ctor(Microsoft.IdentityModel.Tokens.SecurityKey,System.String)" /> .
Returns true if computed signature matches the signature parameter, false otherwise.
input The bytes to verify.
signature signature to compare against.
length number of bytes of signature to use.
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
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object
public string
ToString​()
Inherited from object