It is true that some Orientalists tend to use the two occasions – as you have mentioned – to prove that Prophet Muhammad (pbuh) was literate. However, by analyzing each one of the incidents, one can easily discover the fallacies in the allegation.
For example, in the al-Hudaybiyah Treaty, the prophet (pbuh) did not write the treaty, but his cousin Ali (may Allah be pleased with him) was the writer. While writing the treaty, Suhail ibnAmr [Quraish side] rejected that the prophet would have his name signed as the messenger or apostle of Allah (rasoulu Allah).
Sohail asked to have it changed to “Muhammad, son of Abdullah”. Prophet Muhammad (pbuh) then asked `Ali to omit rasoulu Allah, which means the messenger of Allah. Yet, Ali did not like the idea of omitting it and said: “By Allah I swear I will never omit rasoulu Allah!” Thus, the prophet himself – with his thumb – omitted rasoulu Allah.
One part of the story, which the Orientalists usually – deliberately – do not mention, is the fact that when Ali refused to omit rasoulu Allah, Prophet Muhammad (pbuh) said toAli: “show it to me.” After `Ali showed it to him, the prophet omitted it.
As for the second incident, although there is a dispute among some scholars about its authenticity, the way Orientalists are reporting it is quite inconceivable! The report says that the Prophet Muhammad (pbuh) asked for a pen and a paper, to write the letter, saying who would be the successor after him.
In dealing with this incident, Orientalists totally ignore the fact that in the Arabic language, as well as culture, you can simply use the tools to indicate the profession! Thus, Prophet Muhammad (pbuh), by asking for a pen and a paper, he was asking for some one to write the letter for him…
Furthermore, the companions who happened to be near the prophet at that moment were not astonished by the prophet’s request for one reason; they were aware of exactly what he meant. Also, throughout history, none of the Arabic speaking people ever used this incident to doubt the illiteracy of the prophet (pbuh)!
In fact, it is the miracle that despite this illiteracy, he received the Qur’an as a last testament. This is what Muslims believe to be a sign that the Qur’an is a divine revelation.
Indeed, as no illiterate man could come up with such a beautifully accomplished and complete text. Also, stories of the prophets, narrated in the Qur’an – from Adam to Jesus – could not have been read by Muhammad in the Old or New Testament. This as he could not read in the first place!
Allah knows best…
Wa-salaam.