protected bool Equals(OpenPgpSignature other) { #region Sanity checks if (other == null) throw new ArgumentNullException(nameof(other)); #endregion return KeyID == other.KeyID; }
public void TestGetSignatures() { var openPgpMock = CreateMock<IOpenPgp>(); var result = new OpenPgpSignature[] {OpenPgpUtilsTest.TestSignature}; openPgpMock.Setup(x => x.Verify(_feedBytes, _signatureBytes)).Returns(result); string input = FeedText + FeedUtils.SignatureBlockStart + _signatureBase64 + FeedUtils.SignatureBlockEnd; FeedUtils.GetSignatures(openPgpMock.Object, Encoding.UTF8.GetBytes(input)).Should().Equal(result); }
public void TestGetSignatures() { var openPgpMock = MockRepository.Create<IOpenPgp>(); var result = new OpenPgpSignature[] {new ValidSignature("fingerprint", new DateTime(2000, 1, 1))}; openPgpMock.Setup(x => x.Verify(_feedBytes, _signatureBytes)).Returns(result); string input = FeedText + FeedUtils.SignatureBlockStart + _signatureBase64 + FeedUtils.SignatureBlockEnd; CollectionAssert.AreEqual(result, FeedUtils.GetSignatures(openPgpMock.Object, Encoding.UTF8.GetBytes(input))); }
protected bool Equals(OpenPgpSignature other) { #region Sanity checks if (other == null) { throw new ArgumentNullException(nameof(other)); } #endregion return(KeyID == other.KeyID); }
/// <inheritdoc/> public IEnumerable <OpenPgpSignature> Verify(byte[] data, byte[] signature) { #region Sanity checks if (data == null) { throw new ArgumentNullException("data"); } if (signature == null) { throw new ArgumentNullException("signature"); } #endregion string result; using (var signatureFile = new TemporaryFile("0install-sig")) { File.WriteAllBytes(signatureFile, signature); result = Execute("--batch --no-secmem-warning --status-fd 1 --verify " + signatureFile.Path.EscapeArgument() + " -", inputCallback: writer => { writer.BaseStream.Write(data, 0, data.Length); writer.Close(); }); } string[] lines = result.SplitMultilineText(); // Each signature is represented by one line of encoded information var signatures = new List <OpenPgpSignature>(lines.Length); foreach (var line in lines) { try { var parsedSignature = OpenPgpSignature.Parse(line); if (parsedSignature != null) { signatures.Add(parsedSignature); } } #region Error handling catch (FormatException ex) { // Wrap exception since only certain exception types are allowed throw new IOException(ex.Message, ex); } #endregion } return(signatures); }
/// <inheritdoc/> public IEnumerable <OpenPgpSignature> Verify(byte[] data, byte[] signature) { #region Sanity checks if (data == null) { throw new ArgumentNullException(nameof(data)); } if (signature == null) { throw new ArgumentNullException(nameof(signature)); } #endregion var signatureList = ParseObject <PgpSignatureList>(new MemoryStream(signature)); var result = new OpenPgpSignature[signatureList.Count]; for (int i = 0; i < result.Length; i++) { result[i] = Verify(data, signatureList[i]); } return(result); }
public void TestGetSignautes() { var result = new OpenPgpSignature[0]; // Expect pass-through _backingCacheMock.Setup(x => x.GetSignatures(FeedTest.Test1Uri)).Returns(result); var signatures = _cache.GetSignatures(FeedTest.Test1Uri); CollectionAssert.AreEqual(signatures, result); }
protected bool Equals(OpenPgpSignature other) => KeyID == other.KeyID;
public void TestGetSignatures() { var result = new OpenPgpSignature[0]; var signatures = _cache.GetSignatures(FeedTest.Test1Uri); CollectionAssert.AreEqual(signatures, result); }