Skip to main content
Log in

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

  • SI: SAC-SVT'12
  • Published:
Innovations in Systems and Software Engineering Aims and scope Submit manuscript

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.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6
Fig. 7
Fig. 8
Fig. 9
Fig. 10
Fig. 11
Fig. 12
Fig. 13
Fig. 14
Fig. 15
Fig. 16
Fig. 17

Similar content being viewed by others

References

  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).

  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–1074

    Article  MATH  Google Scholar 

  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).

  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).

  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. 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).

  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).

  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).

  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. 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).

  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).

  12. ElGamal T (1985) A public key cryptosystem and a signature scheme based on discrete logarithms. IEEE Transactions on Information Theory 31(4):469–472

    Article  MathSciNet  MATH  Google Scholar 

  13. Gonthier, G., Mahboubi, A., Tassi, E.: A Small Scale Reflection Extension for the Coq System. Technical Report 6455. Version 11. INRIA (2012).

  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).

  15. Knuth, D.E.: The Art of Computer Programming. Vol. 2, 3rd edition. Addison-Wesley (1997).

  16. Leroy X (2009) A formally verified compiler back-end. J. Autom. Reasoning. 43(4):363–446

    Article  MathSciNet  MATH  Google Scholar 

  17. Lynch NA, Vaandrager FW (1995) Forward and Backward Simulations Part I: Untimed Systems. Inform. Comput. 121(2):214–233

    Article  MathSciNet  MATH  Google Scholar 

  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).

  19. Marti N, Affeldt R (2008) A Certified Verifier for a Fragment of Separation Logic. Computer Software 25(3):135–147

    Google Scholar 

  20. Menezes, A.J., van Oorschot, P.C., Vanstone, S.A.: Handbook of Applied Cryptography. 5th printing. CRC Press (2001).

  21. MIPS Technologies: MIPS32 4KS Processor Core Family Software User’s Manual (2001).

  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).

  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).

  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).

  25. Reynolds, J.C.: The Craft of Programming. Prentice-Hall, International (1981).

  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).

  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. 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).

  29. The Coq Proof Assistant: Reference Manual. Ver. 8.4. Available at http://coq.inria.fr. INRIA (2012)

  30. The Coq Proof Assistant: Frequently Asked Questions. Available at http://coq.inria.fr/faq. INRIA (2012)

  31. The GNU Multi Precision Arithmetic Library. Edition 5.0.2. http://gmplib.org/ (2011)

  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).

  33. Yang H (2007) Relational separation logic. Theor. Comput. Sci. 375(1–3):308–334

    Article  MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Reynald Affeldt.

Additional information

A preliminary version of this work appeared in the proceedings of the 27th ACM SIGAPP Symposium On Applied Computing (SAC 2012), Software Verification and Testing Track [3].

Appendix: Additional assembly code

Appendix: Additional assembly code

This section provides for the sake of completeness assembly code that is explicitly referred to in the body of this paper. See [5] for other assembly code or formal proofs (see Figs. 18, 19, 20).

Fig. 18
figure 18

In-place signed–unsigned subtraction (appears in Fig. 5)

Fig. 19
figure 19

Unsigned–unsigned addition (appears in Figs. 4 and 18)

Fig. 20
figure 20

Assembly code for the main function of the binary extended gcd algorithm (see Fig. 10 for the corresponding pseudo-code)

Rights and permissions

Reprints and permissions

About this article

Cite this article

Affeldt, R. On construction of a library of formally verified low-level arithmetic functions. Innovations Syst Softw Eng 9, 59–77 (2013). https://doi.org/10.1007/s11334-013-0195-x

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s11334-013-0195-x

Keywords

Navigation