public static PassHashRequest ParseRequest(byte[] request)
 {
     if (request.Length < 1)
     {
         Console.Error.WriteLine("Received request with no bytes");
         return(new InvalidRequest());
     }
     if (request[0] == 1)
     {
         return(PerformHashRequest.ParsePassHashRequest(request));
     }
     Console.Error.WriteLine("Received request with invalid type");
     return(new InvalidRequest());
 }
Beispiel #2
0
        public byte[] HandleRequest(byte[] requestBytes)
        {
            PassHashRequest request = PassHashRequest.ParseRequest(requestBytes);

            if (request is PerformHashRequest)
            {
                PerformHashRequest performHashRequest = (PerformHashRequest)request;
                byte[]             message            = performHashRequest.message;
                byte[]             salt = performHashRequest.salt;

                byte[] mashup = CommonRoutines.CombineByteArrays(secret, salt, message);
                byte[] hash   = hasher.ComputeHash(mashup);
                return(PassHashResponse.EncodePerformHashResponse(0, hash));
            }
            else
            {
                return(Common.InvalidResponse.Encode());
            }
        }