Пример #1
0
        internal override bool Verify(CoseMessage msg, AsymmetricAlgorithm key, byte[] content, byte[]?associatedData = null)
        {
            CoseSign1Message sign1Msg = Assert.IsType <CoseSign1Message>(msg);

            if (content == null)
            {
                return(sign1Msg.VerifyDetachedAsync(key, null !, associatedData).GetAwaiter().GetResult());
            }

            using Stream stream = GetTestStream(content);
            return(sign1Msg.VerifyDetachedAsync(key, stream, associatedData).GetAwaiter().GetResult());
        }
Пример #2
0
        public async Task VerifyAsyncWithUnreadableStream()
        {
            using Stream stream = GetTestStream(s_sampleContent);
            byte[] encodedMsg = await CoseSign1Message.SignDetachedAsync(stream, GetCoseSigner(DefaultKey, DefaultHash));

            CoseSign1Message msg = CoseMessage.DecodeSign1(encodedMsg);

            using Stream unseekableStream = GetTestStream(s_sampleContent, StreamKind.Unreadable);
            await Assert.ThrowsAsync <ArgumentException>("detachedContent", () => msg.VerifyDetachedAsync(DefaultKey, unseekableStream));
        }