EXHIBIT 5 --------- OPINION RE LEGALITY 13 [LOGO OF GRAY CARY WARE FREIDENRICH APPEARS HERE] ATTORNEYS AT LAW 400 HAMILTON AVENUE PALO ALTO, CA 94301-1825 TEL (415) 328-6561 FAX (415) 327-3699 OUR FILE NO. 1030733-903101 September 6, 1995 Securities and Exchange Commission 450 Fifth Street, N.W. Washington, D.C. 20549 RE: CUPERTINO NATIONAL BANCORP REGISTRATION STATEMENT ON FORM S-8 REGISTERING SHARES ISSUABLE UNDER THE CUPERTINO NATIONAL BANCORP 401(K) PROFIT SHARING PLAN, THE CUPERTINO NATIONAL BANCORP EMPLOYEE STOCK PURCHASE PLAN AND THE CUPERTINO NATIONAL BANCORP 1995 STOCK OPTION PLAN Ladies and Gentlemen: As legal counsel for Cupertino National Bancorp, a California corporation (the "Company"), we are rendering this opinion in connection with the registration under the Securities Act of 1933, as amended, of up to 425,000 shares of the Common Stock, without par value, of the Company which may be issued pursuant to the exercise of options and purchase rights granted under the Cupertino National Bancorp 401(k) Profit Sharing Plan, the Cupertino National Bancorp Employee Stock Purchase Plan and the Cupertino National Bancorp 1995 Stock Option Plan (the "Plans"). We have examined all instruments, documents and records which we deemed relevant and necessary for the basis of our opinion hereinafter expressed. In such examination, we have assumed the genuineness of all signatures and the authenticity of all documents submitted to us as originals and the conformity to the originals of all documents submitted to us as copies. We are admitted to practice only in the State of California and we express no opinion concerning any law other than the law of the State of California, and the federal law of the United States. 14 Securities and Exchange Commission Page 2 Based on such examination, we are of the opinion that the 425,000 shares of Common Stock which may be issued upon exercise of options and purchase rights granted under the Plans are duly authorized shares of the Company's Common Stock, and, when issued against payment of the purchase price therefor in accordance with the provisions of the Plans, will be validly issued, fully paid and non-assessable. We hereby consent to the filing of this opinion as an exhibit to the Registration Statement referred to above and the use of our name wherever it appears in said Registration Statement. Respectfully submitted, /s/ Gray Cary Ware & Freidenrich GRAY CARY WARE & FREIDENRICH A Professional Corporation 15