Measurement of software trustworthiness is an important research field in the software engineering, which is very useful for analyzing the software quality. In this paper, we propose a mathematical programming approach to allocate the trustworthy degree to each sub-attribute of some software attribute appropriately and then to make the trustworthy degree of this attribute maximize under some constraint conditions. Some sufficient or necessary conditions for analyzing this mathematical programming problem are investigated. Moreover, a polynomial allocation algorithm is given for computing the optimal solution of this mathematical programming. Finally, an example is given in order to show the significance of this work. The results obtained here are useful for improving the software quality by adjusting the trustworthy degree of each sub-attribute under the same cost.