Unable to locate package libffi and libffi5-dev on Ubuntu 12.04.4 through apt-get

The packages are be called libffi6 and libffi-dev.

Package names can be searched on http://packages.ubuntu.com/


For searching packages use apt-cache search.
Example in your case following can help you:

$ apt-cache search libffi
libffi-dev - Foreign Function Interface library (development files)
libffi6 - Foreign Function Interface library runtime
libffi6-dbg - Foreign Function Interface library runtime (debug symbols)
ffindex-dbg - simple index/database for huge amounts of small files (debug)
libbfio-dbg - Library to provide basic input/output abstraction (debug)
libffindex0 - library for simple index/database for huge amounts of small files
libffindex0-dev - library for simple index/database for huge amounts of small files (development)
libjffi-java - Java Foreign Function Interface
libjffi-jni - Java Foreign Function Interface (JNI library)