Esempio n. 1
0
        public static void Sign(this ECDsa key, IVerificableMessage message)
        {
            var meta = message.GetMetaHeader();
            IVerificationHeader verify = message is IRequest ?
                                         new RequestVerificationHeader() : message is IResponse ?
                                         new ResponseVerificationHeader() : throw new InvalidOperationException("unsupport message type");
            var verifyOrigin = message.GetVerificationHeader();

            if (verifyOrigin is null)
            {
                verify.BodySignature = key.SignMessagePart(message.GetBody());
            }
            verify.MetaSignature   = key.SignMessagePart(meta);
            verify.OriginSignature = key.SignMessagePart(verifyOrigin);
            verify.SetOrigin(verifyOrigin);
            message.SetVerificationHeader(verify);
        }
Esempio n. 2
0
 void IVerificableMessage.SetVerificationHeader(IVerificationHeader verificationHeader)
 {
     VerifyHeader = (RequestVerificationHeader)verificationHeader;
 }
Esempio n. 3
0
 void IVerificationHeader.SetOrigin(IVerificationHeader verificationHeader)
 {
     Origin = (RequestVerificationHeader)verificationHeader;
 }
Esempio n. 4
0
 void IVerificationHeader.SetOrigin(IVerificationHeader verificationHeader)
 {
     Origin = (ResponseVerificationHeader)verificationHeader;
 }