On construction of a library of formally verified low-level arithmetic functions

SI: SAC-SVT'12

Abstract

Arithmetic functions are used in many important computer programs such as computer algebra systems and cryptographic software. The latter are critical applications whose correct implementation deserves to be formally guaranteed. They are also computation-intensive applications, so that programmers often resort to low-level assembly code to implement arithmetic functions. We propose an approach for the construction of a library of formally verified low-level arithmetic functions. To build our library, we first introduce a formalization of data structures for signed multi-precision arithmetic in low-level programs. We use this formalization to verify the implementation of several primitive arithmetic functions using Separation logic, an extension of Hoare logic to deal with pointers. Since this direct style of formal verification leads to technically involved specifications, we also propose for larger functions to show a formal simulation relation between pseudo-code and assembly. This style of verification is illustrated with a concrete implementation of the binary extended gcd algorithm.

Keywords

Proof-assistant Coq Hoare logic Separation logic Assembly programming language Multi-precision arithmetic Simulation 

References

  1. 1.
    Affeldt, R., Marti, N.: An Approach to Formal Verification of Arithmetic Functions in Assembly. In: Proceedings of the 11th Annual Asian Computing Science Conference. LNCS, vol. 4435, pp. 346–360. Springer, Heidelberg (2008).Google Scholar
  2. 2.
    Affeldt R, Nowak D, Yamada K (2012) Certifying Assembly with Formal Security Proofs: the Case of BBS. Sci. Comput. Program 77(10–11):1058–1074MATHCrossRefGoogle Scholar
  3. 3.
    Affeldt, R.: On Construction of a Library of Formally Verified Low-level Arithmetic Functions. In: Proceedings of the 27th ACM SIGAPP Symposium On Applied Computing (SAC 2012), Software Verification and Testing Track, vol. 2, pp. 1326–1331. ACM (2012).Google Scholar
  4. 4.
    Affeldt, R., Marti, N.: Towards Formal Verification of TLS Network Packet Processing Written in C. In: Proceedings of the 7th ACM SIGPLAN Workshop on Programming Languages meets Program Verification (PLPV 2013), pp. 35–46. ACM (2013).Google Scholar
  5. 5.
    Affeldt, R.: A Library for Formal Verification of Low-level Programs. Coq documentation. http://staff.aist.go.jp/reynald.affeldt/coqdev (last access: 2013/02/25)
  6. 6.
    Benton, N.: Simple relational correctness proofs for static analyses and program transformations. In: Proceedings of the 31st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2004), pp. 14–25. ACM (2004).Google Scholar
  7. 7.
    Berghofer, S.: Verification of Dependable Software using Spark and Isabelle. In: Proceedings of the 6th International Workshop on Systems Software Verification Proceedings, pp. 48–65 (2011).Google Scholar
  8. 8.
    Boldo, S., Melquiond, G.: Flocq: A Unified Library for Proving Floating-Point Algorithms in Coq. In: Proceedings of the 20th IEEE Symposium on Computer Arithmetic (ARITH 2011), pp. 243–252. IEEE Computer Society (2011).Google Scholar
  9. 9.
    Brent, R.P., Zimmermann, P.: Modern Computer Arithmetic. Version 0.5.9 (7 October 2010). Available at http://www.loria.fr/~zimmerma/mca/mca-cup-0.5.9.pdf (last access: 2012/12/03). Final version published by Cambridge University Press (2010)
  10. 10.
    Cock, D., Klein, G., Sewell, T.: Secure Microkernels, State Monads and Scalable Refinement. In: Proceedings of the 21st International Conference on Theorem Proving in Higher Order Logics (TPHOLs 2008). LNCS, vol. 5170, pp. 167–182. Springer, Heidelberg (2008).Google Scholar
  11. 11.
    Crespo, J.M., Kunz, C.: A Machine-Checked Framework for Relational Separation Logic. In: Proceedings of the 9th International Conference on Software Engineering and Formal Methods (SEFM 2011). LNCS, vol. 7041, pp. 122–137. Springer, Heidelberg (2011).Google Scholar
  12. 12.
    ElGamal T (1985) A public key cryptosystem and a signature scheme based on discrete logarithms. IEEE Transactions on Information Theory 31(4):469–472MathSciNetMATHCrossRefGoogle Scholar
  13. 13.
    Gonthier, G., Mahboubi, A., Tassi, E.: A Small Scale Reflection Extension for the Coq System. Technical Report 6455. Version 11. INRIA (2012).Google Scholar
  14. 14.
    Hur, C.-K., Dreyer, D.: A Kripke logical relation between ML and assembly. In: Proceedings of the 38th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. pp. 133–146. ACM (2011).Google Scholar
  15. 15.
    Knuth, D.E.: The Art of Computer Programming. Vol. 2, 3rd edition. Addison-Wesley (1997).Google Scholar
  16. 16.
    Leroy X (2009) A formally verified compiler back-end. J. Autom. Reasoning. 43(4):363–446MathSciNetMATHCrossRefGoogle Scholar
  17. 17.
    Lynch NA, Vaandrager FW (1995) Forward and Backward Simulations Part I: Untimed Systems. Inform. Comput. 121(2):214–233MathSciNetMATHCrossRefGoogle Scholar
  18. 18.
    Marti, N., Affeldt, R., Yonezawa, A.: Formal Verification of the Heap Manager of an Operating System using Separation Logic. In: Proceedings of the 8th International Conference on Formal Engineering Methods (ICFEM 2006). LNCS, vol. 4260, pp. 400–419. Springer, Heidelberg (2006).Google Scholar
  19. 19.
    Marti N, Affeldt R (2008) A Certified Verifier for a Fragment of Separation Logic. Computer Software 25(3):135–147Google Scholar
  20. 20.
    Menezes, A.J., van Oorschot, P.C., Vanstone, S.A.: Handbook of Applied Cryptography. 5th printing. CRC Press (2001).Google Scholar
  21. 21.
    MIPS Technologies: MIPS32 4KS Processor Core Family Software User’s Manual (2001).Google Scholar
  22. 22.
    Myreen, M.O., Gordon, M.J.C.: Hoare Logic for Realistically Modelled Machine Code. In: Proceedings of the 13th International Conference on Tools and Algorithms for the Construction and Analysis of Systems (TACAS 2007). LNCS, vol. 4424, pp. 568–582. Springer, Heidelberg (2007).Google Scholar
  23. 23.
    Myreen, M., Gordon, M.: Verification of Machine Code Implementations of Arithmetic Functions for Cryptography. In: TPHOLs Emerging Trends Proceedings. Technical report 364/07. Department of Computer Science, University of Kaiserslautern (2007).Google Scholar
  24. 24.
    Myreen, M.O.: Verified just-in-time compiler on x86. In: Proceedings of the 37th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 2010), pp. 107–118. ACM (2010).Google Scholar
  25. 25.
    Reynolds, J.C.: The Craft of Programming. Prentice-Hall, International (1981).Google Scholar
  26. 26.
    Reynolds, J.C.: Separation Logic: A Logic for Shared Mutable Data Structures. In: Proceedings of the 17th IEEE Symposium on Logic in Computer Science (LICS 2002), pp. 55–74. IEEE Computer Society (2002). Google Scholar
  27. 27.
    Shoup, V.: NTL: A Library for doing Number Theory. Version 5.5.2. Available at http://www.shoup.net/ntl (last access: 2012/12/03) (2009)
  28. 28.
    Tan, G., Appel, A.W.: A Compositional Logic for Control Flow. In: Proceedings of the 7th International Conference on Verification, Model Checking, and Abstract Interpretation (VMCAI 2006). LNCS, vol. 3855, pp. 80–94. Springer, Heidelberg (2006).Google Scholar
  29. 29.
    The Coq Proof Assistant: Reference Manual. Ver. 8.4. Available at http://coq.inria.fr. INRIA (2012)
  30. 30.
    The Coq Proof Assistant: Frequently Asked Questions. Available at http://coq.inria.fr/faq. INRIA (2012)
  31. 31.
    The GNU Multi Precision Arithmetic Library. Edition 5.0.2. http://gmplib.org/ (2011)
  32. 32.
    Winwood, S., Klein, G., Sewell, T., Andronick, J., Cock, D., Norrish, M.: Mind the Gap: A Verification Framework for Low-level C. In: Proceedings of the 22nd International Conference on Theorem Proving in Higher Order Logics (TPHOLs 2009). LNCS, vol. 5674, pp. 500–515. Springer, Heidelberg (2009).Google Scholar
  33. 33.
    Yang H (2007) Relational separation logic. Theor. Comput. Sci. 375(1–3):308–334MATHCrossRefGoogle Scholar

Copyright information

© Springer-Verlag London 2013

Authors and Affiliations

  1. 1.National Institute of Advanced Industrial Science and TechnologyUmezono, TsukubaJapan

Personalised recommendations