Example #1
0
 private static byte[] CreateKMSV4ResponseBytes(KMSV4Response responsev4)
 {
     using MemoryStream stream       = new MemoryStream();
     using BinaryWriter binaryWriter = new BinaryWriter(stream);
     binaryWriter.Write(responsev4.BodyLength);
     binaryWriter.Write(responsev4.Unknown);
     binaryWriter.Write(responsev4.BodyLength2);
     binaryWriter.Write(responsev4.Response);
     binaryWriter.Write(responsev4.Hash);
     binaryWriter.Write(responsev4.Padding);
     binaryWriter.Flush();
     stream.Position = 0;
     return(stream.ToArray());
 }
Example #2
0
        public byte[] HandleRequest(byte[] request)
        {
            KMSV4Request v4Request = CreateKMSV4Request(request);

            byte[] response = Server.ExecuteKMSServerLogic(v4Request.Request, Logger);

            byte[] hash = GetHashV4(response);

            KMSV4Response kmsv4Response = new KMSV4Response {
                Response = response, Hash = hash
            };

            byte[] responseBytes = CreateKMSV4ResponseBytes(kmsv4Response);
            return(responseBytes);
        }