예제 #1
0
 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;
     }
 }
예제 #2
0
        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();
                }
            }
        }