Skip to content

Commit

Permalink
added GetNonce() to IRfc3161TimestampRequest interface (#3427)
Browse files Browse the repository at this point in the history
  • Loading branch information
kartheekp-ms authored Jun 4, 2020
1 parent f612071 commit 86ede6b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,11 @@ namespace NuGet.Packaging.Signing
internal interface IRfc3161TimestampRequest
{
Task<IRfc3161TimestampToken> SubmitRequestAsync(Uri timestampUri, TimeSpan timeout);

/// <summary>
/// Gets the nonce for this timestamp request.
/// </summary>
/// <returns>The nonce for this timestamp request as byte[], if one was present; otherwise, null</returns>
byte[] GetNonce();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ public async Task<SignedCms> GetTimestampAsync(TimestampRequest request, ILogger
RequestTimeout);

// quick check for response validity
ValidateTimestampResponse(nonce, request.HashedMessage, timestampToken);
var normalizedNonce = rfc3161TimestampRequest.GetNonce();
ValidateTimestampResponse(normalizedNonce, request.HashedMessage, timestampToken);

var timestampCms = timestampToken.AsSignedCms();
ValidateTimestampCms(request.SigningSpecifications, timestampCms, timestampToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public Task<IRfc3161TimestampToken> SubmitRequestAsync(Uri timestampUri, TimeSpa
{
return Task.FromResult(_rfc3161TimestampRequest.SubmitRequest(timestampUri, timeout));
}

public byte[] GetNonce()
{
return _rfc3161TimestampRequest.GetNonce();
}
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ public async Task<IRfc3161TimestampToken> SubmitRequestAsync(Uri timestampUri, T
}
}
}

public byte[] GetNonce()
{
ReadOnlyMemory<byte>? normalizedNonce = _rfc3161TimestampRequest.GetNonce();
return normalizedNonce.HasValue ? normalizedNonce.Value.ToArray() : null;
}
}
#endif
}

0 comments on commit 86ede6b

Please sign in to comment.