/// <summary> /// Validates nonce in request and response. /// </summary> /// <param name="request">Request against which this response was produced.</param> /// <exception cref="ArgumentNullException"> /// <strong>request</strong> parameter is null. /// </exception> /// <remarks>Nonce validation failure is added to <see cref="ResponseErrors"/> property.</remarks> public void ValidateNonce(TspRfc3161Request request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } validateNonce(request); }
void validateNonce(TspRfc3161Request request) { if (request.UseNonce && !NonceReceived) { ResponseErrors |= TspValidationErrorStatus.MissingNonce; } if (request.UseNonce && NonceReceived) { Byte[] reqNonce = request.GetNonceBytes(); Byte[] rspNonce = GetNonceBytes(); if (reqNonce.Intersect(rspNonce).Count() != rspNonce.Length) { ResponseErrors |= TspValidationErrorStatus.NonceMismatch; } } }