private static void SignToken(Token token) { using (var dsa = DSAHelper.GetPrivateDsa()) { var rgbHash = token.ComposeData(); var sigBytes = dsa.CreateSignature(rgbHash); var sigStr = ConvertToString(sigBytes); token.Signature = sigStr; } }
public void Validate() { using (var dsa = DSAHelper.GetPublicDsa()) { var sigBytes = ConvertToBytes(this.Signature); var data = this.ComposeData(); if (IsExpired()) { throw new TokenExpiredException(); } if (!dsa.VerifySignature(data, sigBytes) && DateTimeOffset.Now < this.Expiration) { throw new InvalidTokenException(); } } }