jueves, 18 de octubre de 2012

Lab 4. Problema 5.11

Considere el sistema de la Figura 5.85 determine el valor de k de modo que el factor de amortiguamiento  $\zeta$ sera 0.5. Después obtenga el tiempo de salida $t_{r}$ , el tiempo pico tp $t_{p}$, la sobreelongacion maxima $M_{p}$ y el tiempo de asentamiento $t_{s}$, en la respuesta escalon unitario.


El valor de "k" obtenido mediante la función de transferencia mostrada en la figura es el siguiente:


$\frac{C(s) }{R(s)}= \frac{16}{s^{2}+(0.8+16k)s+16}$

 $W_{n}= 4$

 $25W_{n} = (2)(0.5)(0.4)= 0.8 + 16k$
Finalmente el valor de "K"
$k = 0.2$
 
Valores de $W_{d}$ y $\beta$
$W_{d}= W_{n}\sqrt{1-5^{2}}= 4\sqrt{1-0.25}= 3.46$

$\beta = sin^{-1}\frac{W_{d}}{W_{n}}= sin^{-1}(0.866)= \frac{\Pi }{3}$

Obteniendo los valores del tiempo de salida  $t_{r}$
$t_{r}=\frac{\Pi -\beta }{W_{d}}$ $t_{r}=\frac{\Pi -1/3\Pi }{3.46}= 0.605 seg$

Tiempo pico del sistema se obtiene de la siguiente manera:
$t_{p}=\frac{\Pi }{W_{d}}=\frac{3.1416}{3.46}=0.907 seg$

Para sacar la sobreelongación máxima $M_{p}$ utilizaremos la siguiente formula:

$M_{p}= e^{-\frac{\zeta \Pi }{\sqrt{1-\zeta ^{2}}}}$
$M_{p}= e ^{-\frac{(0.5)(3.1416) }{\sqrt{1-(0.25)}}}$
$M_{p}= e ^{-1.314}=0.163$

Por ultimo para sacar el tiempo de asentamiento utilizamos la siguiente formula con el valor de $W_{n}$ obtenido anteriormente
$t_{s}=\frac{4}{\zeta W_{n}}= \frac{4}{(0.5)(4)}= 2 seg$










 
 
 
 
 




miércoles, 17 de octubre de 2012

3-Way Block cipher

For this week we need chose a block cipher.  I chose the 3-Way block cipher this is the explain.
 
Origins
In cryptography, 3-Way is a block cipher designed in 1994 by Joan Daemen. One of such block cipher algorithm is the 3-Way Algorithm and has a key and block size of 96 bits.
The 3-Way algorithm is an iterated block cipher that repeats some relatively simple operations a specified number of times.
 
Has the following characteristics:
Merits of 3-Way Algorithm
  • 3-Way algorithm is efficient in wide range of platforms from 8-bit processors to specialized hardware.
  • 3-Way algorithm resembles more mathematical features which enable all the decryption to be done in exactly same way as in encryption.
  • 3-Way encryption ensures total security in on-line transactions.
  • This algorithm provides additional security to protect customers order information such as credit card numbers.

DeMerits of 3-Way Algorithm

  • 3-Way algorithm requires a lot of space for its execution.
  • Resynchronization is one of the main problems in 3-way algorithm.

Applications of 3-Way Algorithm

  • 3-Way algorithms are used in web browsing, electronic mail, internet faxing, instant messaging and voice-over-IP.
  • 3-Way algorithm has prominent role in establishing network over wide ranges.
  • They are used in many web applications.
  • 3-Way algorithm provides more security when compared to any other algorithms.

Steps Involved in 3-Way Encryption

  • Information is coded between the customer and our server.
  • An e-mail is sent to merchant (the information where it is to be transmitted) notifying the order, when the Information is coded on our own hard drive.
  • At last when the merchant retrieves the order, the third coding takes place.

Steps Involved in 3-Way Decryption

  • The server must use a RSA key exchange mechanism.
  • RSA key mechanism can be replaced by Diffie-Hellman key exchange mechanism also.
  • We must have access to server’s private RSA key and be able to be coped to the required destination.
  • Outputting a fake 3-way TCP handshake is possible for the decrypted traffic. Thus by keeping the TCP sequence numbers up to date, decrypted server satisfies all the client requests.
Structure:
A related key attack on 3-way requires one related key query and 2 22 chosen plaintexts. It is closely related to BaseKing; indeed, the two are variants of the same general cipher technique.

Type of mathematics that is based on this algorithm
  • 3-Way is an 11-round substitution-permutation network.
  • 3-Way is designed to be very efficient in a wide range of platforms from 8-bit processors to specialized hardware, and has some elegant mathematical features which enable nearly all the decryption to be done in exactly the same circuits as did the encryption.
Implement
One way to implement decipherment with 3-Way is to implement it as encipherment with a modified key schedule, preceded and followed by a step reversing the order of all the bits in the 96-bit block; this is the scheme shown in the C code given in Bruce Schneier's famed book Applied Cryptography.



As can be seen from the diagram, a round consists of a number of distinct steps.

1st step: Is the XOR of key material with a round constant.

The round constants for the eleven rounds, and the final additional key XOR operation,
of 3-Way are:
 1) 0000 1011 0000 1011     0B0B
 2) 0001 0110 0001 0110     1616
 3) 0010 1100 0010 1100     2C2C
 4) 0101 1000 0101 1000     5858
 5) 1011 0000 1011 0000     B0B0
 6) 0111 0001 0111 0001     7171
 7) 1110 0010 1110 0010     E2E2
 8) 1101 0101 1101 0101     D5D5
 9) 1011 1011 1011 1011     BBBB
10) 0110 0111 0110 0111     6767
11) 1100 1110 1100 1110     CECE
12) 1000 1101 1000 1101     8D8D


So the symmetry does not break down, but the period is not maximal.

2nd step: Called theta, is a matrix multiplication using XORs; it is indeed a matrix multiplication, modulo 2, carried out in parallel eight times, for each of the eight bits each of the twelve bytes in the block contains.
The matrix multiplication involves the matrix: 
The matrix multiplication has a structure that allows it to be implemented in terms of shifts and XORs of 32-bit words.

3rd step, pi-1, now provides diffusion between the bits of the bytes by performing two different rotations on two of the 32-bit subblocks of the 96-bit block. In this step, the first 32-bit subblock is rotated 10 bits to the right, and the third 32-bit subblock is rotated 1 bit to the left. The second subblock is not modified.

4th step: Gamma, applies a nonlinear S-box with three inputs and three outputs to corresponding bits of the three subblocks.
Each bit is XORed with the OR of the next bit and the inverse of the bit after that, leading to an S-box with the table:
 
5th step: pi-2, provides diffusion between bits, as well as maintaining the symmetry that relates decipherment to encipherment. Here, it is the first 32-bit subblock that is rotated 1 bit to the left, and the third 32-bit subblock that is rotated 10 bits to the right.

Decipherment
The theta and gamma operations both become their own inverses when the 96 bits of the block are handled in reverse order, and pi-2 with bits reversed becomes the inverse of the original pi-1, and so on.

To invert a cipher, one has to perform the inverses of each of the steps in reverse order. The fact that the XOR of the key precedes the theta step is the only complication; in addition to being used in reverse order, and with bits reversed, the key for each round must go through the theta step. 

Attacks and vulnerabilities
3-Way is vulnerable to related-key attacks, and therefore it should only be used with keys that are generated by a strong RNG, or by a source of bits
that are sufficiently uncorrelated (such as the output of a hash function).
http://www.slideshare.net/rajeevrvis/3way

http://www.cosic.esat.kuleuven.be/publications/article-141.pdf

martes, 9 de octubre de 2012

Reporte 2. Diagrama de Bloques

A partir de un modelo matematico del sistema, podemos determinar una función matematica que ligue a las variables de entrada y las de salida, a esto lo podemos llamar función de transferencia.

Este diagrama de bloques representa la función de transferencia del motor que actuara en el sistema.
Se tomara como variable de entrada al voltaje aplicado definido como y como variable de salida a la velocidad de rotación.

$Ve(t)$

$\Omega (t)$

$\Omega (s) =\frac{ \frac{Re}{k\Theta }}{Tms} [le(S)-lc(S))]$

Se realiza una reducción de ecuaciones mediante el reemplazo de equivalencias, hasta obtener una unica ecuación que intervendra en el sistema.

Diagrama de Bloques:

A partir de la ecuación unica iniciamos la construcción del diagrama.






Bibliografía:
Sistemas de Control
Diagrama de Bloques

jueves, 20 de septiembre de 2012

RSA-Firmas Digitales

For this homework I need to implement a HTTP public-key repository for key exchange that employs RSA-Based digital signatures,  I used PHP and a little database in mysql also a little script in Python.

This is the PHP+MySQL code



This is the script in python



This is the authentication with the web service, here is the validation 


martes, 18 de septiembre de 2012

Entrega 3.

Para esta entrega seleccione el ejercicio B.3.15 el cual consiste en:
Obtener una representación en el espacio de estados del sistema mecánico de la figura 3.80,
donde u1 y u2 son entradas e y1 e y2 son salidas.


Representación en el espacio de estados:

La representación de un sistema en espacio de estados permite relacionar las variables de entrada u(t) y de salida y(t) mediante una ecuación diferencial matricial de primer orden (Ecuación de Estado) y una combinación lineal de la entrada y los estados x(t) (Ecuación de Salida) de la forma:

Ecuación de Estado:
$\frac{dx(t)}{dt}= Ax(t)+Bu(t)$
Ecuación de salida:
 $y(t)=Cx(t)+Du(t)$
La teoría que representa los sistemas mecánicos es la Segunda Ley de Newton, donde tenemos las sumatoria de fuerzas que intervienen en el sistema.

$\sum Fext=ma$

Las variables de estado que intervienen en el comportamiento del sistema son las siguientes:
$u_{1}$ y $u_{2}$ = fuerzas aplicadas y son las entradas del sistema
En el sistema se muestran 2 fuerzas aplicadas estas son a las 2 masas que intervienen en el sistema $m_{1}$ y $m_{2}$

$k_{1}$ y $k_{2}$ representa la constante de elastica.
b es la constante de biscosidad
$y_{1}$ y $y_{2}$ son las salidas del sistema.

Tomando en cuenta las ecuaciones anteriores pasamos a la solución del problema

1. Esta es la ecuación de la sumatoria de las fuerzas para las dos masas representadas en el sistema.
 $m_{1}\ddot{y_{1}}+ b_{1}(\dot{y_{_{1}}})-\dot{y_{2}}+k_{1}y_{1}=u_{1}$

$m_{1}\ddot{y_{1}}+ b_{1}(\dot{y_{_{1}}})-\dot{y_{2}}+k_{1}y_{1}=u_{1}$

2. Variables de desplazamiento
$x_{1}= y_{1}$
$x_{2}= \dot{y_{1}}$
$x_{3}= y_{2}$
$x_{4}= \dot{y_{2}}$

3.Aquí obtenemos las ecuaciones diferenciales para encontrar las salidas del sistema
$m_{1}\dot{x_{2}}+b_{1}(x_{2}-x_{4})+k_{1}x_{1}=u_{1}$
$m_{2}\dot{x_{4}}+b_{1}(x_{4}-x_{2})+k_{2}x_{3}=u_{2}$

4. Obteniendo la representación de las salidas o ecuación final del sistema
$\dot{x_{1}}=x_{2}$

$\dot{x}_{2}= -1/m_{1}[b_{1}(x_{2}- x_{4})+k_{1}x_{1}]+ (1/m_{1})u_{1}$

$\dot{x_{3}}=x_{4}$

Representación en el espacio de los estados dentro del sistema. 
$\dot{x}_{4}= -1/m_{2}[b_{1}(x_{4}- x_{2})+k_{2}x_{3}]+ (1/m_{2})u_{2}$



jueves, 13 de septiembre de 2012

RSA Authentication

For this week, we had to do the following:
  •  Implement RSA authentication in Python for a client-server system with sockets.

Key generation
RSA involves a public key and a private key. The public key can be known to everyone and is used for encrypting messages. Messages encrypted with the public key can only be decrypted using the private key. 

So, the algorithm is:

    * Generate n = p × q, where both p and q are prime.
    * (e, n) is the public key; c = m^e mod n.
    * e is to be relatively prime with ɸ(n)
    * (d, n) is the private key; m = c^d mod n.
          o Requirement: e × d ≣ 1 mod ɸ(n) (or in other words d needs to be the inverse multiplicative of e);
    * ɸ(n) = (p - 1) × (q - 1).
    * m^(e×d)≣ m mod n due to Euler’s theorem.

 
These are the results.


Code RSAKeys: 






Server:



Cliente: 
 Here I have a difficult with of server, this is the code but it hasn´function

domingo, 9 de septiembre de 2012

Reporte 1(Clase). Modelo matemático

Estaremos trabajando con un estacionamiento giratorio, el sistema es mecánico giratorio, en este caso trataremos el movimiento del motor, dentro de este intervienen factores de entrada y salida para realizar el movimiento.

Para que la rueda haga su funcionamiento, interviene lo que es una señal de impulso esta sera emitida por el arduino, la rueda realizara un desplazamiento  al aplicar una fuerza considerando el peso de la rueda y de la cantidad de autos. 


Entrada:
Para poder realizar el movimiento de la rueda y del motor, se consideraría la 2 fuerzas aplicando la segunda Ley de Newton


Estas formadas por las masas de los objetos que serian los autos y el peso de la rueda en sí que serán aplicadas al motor.
$Ft=m(r\alpha )$
$Fr=ma_{r}=m(\omega ^{2}r)$

Salida:
Dentro del sistema existe un movimiento rotacional, una extensión de la Ley de Newton para este tipo de movimiento indica que: 
“La suma algebraica de los momentos o pares alrededor de un eje fijo es igual al producto de la inercia por la aceleración angular alrededor de dicho eje” 
  • ω = velocidad angular
  • ∝ = aceleración angular
  • θ = posición angular 
 Considerando la velocidad angular existe el desplazamiento que realizara el motor.