By: \\ [[mailto:jonathan.alvaradosolano@ucr.ac.cr|Jonathan Alvarado.]]\\ [[mailto:caroobangonz@gmail.com|Carolina Obando González.]]
====== BeRrYLoCkY_2.1_BETA ======
**Group:**\\
Carolina Obando\\
Jonathan Alvarado
===== Description =====
The BerryLock 2.1 BETA is a security system to be installed in the ARCOSLAB School of Electrical Engineering. This lock already has a circuit that will connect to a computer that runs a Python script function. The design of the remote control software that will open the lock from a mobile device is the work to be done in this first part of the project. In the second part of security is implemented in communication for greater control user login.
===== Justification =====
An automated security system for the laboratory, to keep track of incomes a lot faster and organized is needed.
===== Objectives =====
==== General ====
Design control software for electronic security lock, which allows the user to manage the income from your mobile device. This was created under Debian (Raspbian) operating system and using Python as a programming language.
==== Specifics ====
* Install security lock containing an electrical circuit in ARCOSLAB.
* Design a controller that allows the basic functions of electronic lock Using Python programming skills.
* Installing the software that controls the connection to the network lock using a Raspberry Pi with raspbian.
* Achieve the basic operation of the lock installed in the laboratory.
* Add security features to the application designed for the opening of the laboratory.
===== Contents =====
====What is a Raspberry Pi?===
It Is a little size computer with a data processor ARM structure, Graphic processor (GPU VideoCore IV), firmware capabilities overclock up to 1GHz, ram included 256Mb, does not have a disk drive (HDD) included but use a SD CARD to install the operating system and data storage. This contains a set of pins Input / Output called (GPIO) allowing input signals and data through printed buses on the motherboard of the PC.
====Installing Raspbian OS====
There is an operating system For Raspberry PI with a path that accepts commands as received by the path of Debian and others as "raspbian-config".
Debian Wheezy is downloaded from the official website, where OS images with different characteristics can be downloaded.
http://www.raspberrypi.org/downloads
Unzip the image contained in a zip file extension with the following command in the respective directory where you’re downloaded image:
unzip /Donwloads/2014-01-07-wheezy-raspbian.zip
Format the SD Card, which can be about 2GB to 4GB. For OS just one 1 GB may be necessary but should take into account that this is the total storage device so if you subsequently use files to store data or customer information as could be, is better to use more space, in this case we used a 4GB memory. This command provides the free and occupied space:
df –h
Format the SD card in FAT32 file system with a single partition:
sudo mkdosfs –F 32 /dev/sdd
Dismount and flash the SD CARD:
umount /dev/sdd1
Copy the image in the SD Card:
sudo dd bs = 4M if = / Downloads/2014-01-07-wheezy-raspbian.img of = / dev / sdd
Start Raspbian in your Raspberry Pi and expand the root file system to recognize all the free space in the SD CARD.
when you start your Pi using the wheezy image The Raspi-config menu appears and has the following entries.
{{:ie0117_proyectos_i_2014:proyecto_1:int.jpg?200|}}
Iniciando la interfaz gráfica:
startx
{{:ie0117_proyectos_i_2014:proyecto_1:raspbiandesktop.jpg?200|}}
==== RPI.GPIO for Python ====
There is a module in Python libraries containing classes already defined to configure and control the Raspberry Pi GPIO, in this OS image objects and the library is updated to the latest version:
sudo python
import RPi.GPIO
RPi.GPIO.VERSION
Note that if it is not updated to the latest version you need to download the latest from:
https://pypi.python.org/packages/source/R/RPi.GPIO/
====Unlocking BerryLock2.1 BETA with GPIO ====
#!/usr/bin/env python
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
def signal_handler():
print “Unlocking”
GPIO.setup(26, GPIO OUT, pull_up_down = GPIO.pud_UP)
GPIO.output(26, GPIO.HIGH)
time.sleep(1)
GPIO.output(26, GPIO.LOW)
time.sleep(3)
GPIO.output(26, GPIO.HIGH)
GPIO.cleanup()
def main():
signal_handler()
if__ name__==”__main__”
main()
==== SRP-Socket connection ====
“SRPSocket is a Python module that creates an authenticated socket. The socket is authenticated using the SRP (Secure Remote Password) protocol. That is, the server requires the client to supply a passphrase in order to create the socket. SRP is safe to use over the network. It resists offline dictionary attacks, man-in-the-middle attacks, allows both client and host authentication (to prevent host spoofing), creates a secure, shared session key as a side effect, and has several other nice properties.”
=== Server ===
The server is the computer server.py all respective algorithms and modules for functions that compare client authentication, the user and password that the client sends must match this with. This implements the Socket connection using authentication using SRP algorithm and using the HMAC (keyed hashing for message authentication, as described in RFC2104) SRPSocket.py comparing a file which contains the functions responsible for process authentication socket, this only once authenticated user to enter the correct password achieve real gain access to the laboratory by activating the function for opening the lock.
#! /usr/bin/env python
import SRPSocket
SRPSocket.SRPServer(port)
=== Client ===
The client needs to send the correct password and apply the same algorithm for communication is established, there is a verification key to ensure that the user is permitted. After that opening the lock will always be authenticated by a user through the process of creating the client-server socket.
import SRPSocket
# Start the server with "python server.py"
# This will create an authenticated socket and secure session key for 'user':
sock, key = SRPSocket.SRPSocket('Host', Port, 'password')
====SL4A ====
Scripting Layer for Android (SL4A) brings scripting languages to Android by allowing you to edit and execute scripts and interactive interpreters directly on the Android device.
===== Conclusion =====
After the installation of raspbian, it was possible to connect the lock and the Raspberry Pi using an authentication protocol SRP, a sockets connection and using unique keys from user-server in one connection established. The remote control from the Android device running Python script via SL4A to open the lock was successful.
===== References=====
http://www.raspberrypi.org/downloads/
http://robologs.net/2014/04/12/tutorial-de-raspberry-pi-gpio-y-python-i/
http://www.frambuesapi.co/2013/08/10/tutorial-3-instalacion-y-configuracion-de-inicial-del-raspberry-pi-raspi-config/
http://www.debian.org/releases/woody/i386/fdisk.txt
http://raspi.tv/2013/how-to-use-interrupts-with-python-on-the-raspberry-pi-and-rpi-gpio-part-2
http://www.necronet.info/2011/10/jugando-con-android-python.html
https://code.google.com/p/android-scripting/
http://librosweb.es/libro/python/capitulo_10/modulos_de_sistema.html
http://www.lawebdelprogramador.com/foros/Python/1313926-por_favor_ayuda_con_programa_en_python_cliente-servidor.html
http://pleac.sourceforge.net/pleac_python/sockets.html
https://wiki.python.org/moin/HowTo/Sockets
http://srp.stanford.edu/srp/
http://tools.ietf.org/rfc/rfc5054.txt
http://www.securityfocus.com/tools/987