internal override bool Verify(CoseMessage msg, AsymmetricAlgorithm key, byte[] content, byte[]?associatedData = null) { CoseSign1Message sign1Msg = Assert.IsType <CoseSign1Message>(msg); if (content == null) { return(sign1Msg.VerifyDetached(key, (Stream)null !, associatedData)); } using Stream stream = GetTestStream(content); return(sign1Msg.VerifyDetached(key, stream, associatedData)); }
public void DecodeSign1_VerifyDetachedContent() { // Content is replaced with CBOR null - https://github.com/cose-wg/Examples/blob/master/ecdsa-examples/ecdsa-sig-01.json. CoseSign1Message msg = CoseMessage.DecodeSign1(ByteUtils.HexToByteArray("D28445A201260300A104423131F658406520BBAF2081D7E0ED0F95F76EB0733D667005F7467CEC4B87B9381A6BA1EDE8E00DF29F32A37230F39A842A54821FDD223092819D7728EFB9D3A0080B75380B")); Assert.Null(msg.Content); Assert.True(msg.VerifyDetached(DefaultKey, s_sampleContent)); }
public void VerifyWithUnseekableStream() { using Stream stream = GetTestStream(s_sampleContent); byte[] encodedMsg = CoseSign1Message.SignDetached(stream, GetCoseSigner(DefaultKey, DefaultHash)); CoseSign1Message msg = CoseMessage.DecodeSign1(encodedMsg); using Stream unseekableStream = GetTestStream(s_sampleContent, StreamKind.Unseekable); Assert.Throws <ArgumentException>("detachedContent", () => msg.VerifyDetached(DefaultKey, unseekableStream)); }
internal override bool Verify(CoseMessage msg, AsymmetricAlgorithm key, byte[] content, byte[]?associatedData = null) { CoseSign1Message sign1Msg = Assert.IsType <CoseSign1Message>(msg); return(sign1Msg.VerifyDetached(key, content, associatedData)); }