Ejemplo 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);
        }
Ejemplo n.º 2
0
 void IVerificableMessage.SetVerificationHeader(IVerificationHeader verificationHeader)
 {
     VerifyHeader = (RequestVerificationHeader)verificationHeader;
 }
Ejemplo n.º 3
0
 void IVerificationHeader.SetOrigin(IVerificationHeader verificationHeader)
 {
     Origin = (RequestVerificationHeader)verificationHeader;
 }
Ejemplo n.º 4
0
 void IVerificationHeader.SetOrigin(IVerificationHeader verificationHeader)
 {
     Origin = (ResponseVerificationHeader)verificationHeader;
 }