martes, 30 de octubre de 2012

Reporte #3

Aqui tenemos nuestra funcion de transferencia, ignoraremos unas variables por ser constantes y asi es como queda:


Ahora probaremos esta funcion con distintas entradas de temperatura ya que dependiendo de la temperatura mandara voltaje para prender los ventiladores.

Probaremos con las siguientes temperaturas:
10°
30°


Al parecere mi funcion no hay tanto cambio ya que con los diferentes temperaturas que e puesto salen los resultados anteriores.


La siguiente es una distorsion con una entrada en exponencial


Aqui probamos los polos y ceros de nuestra funcion y esto es lo que nos arroja octave:



Algo indispensable en los sistemas de control, es determinar el grado de estabilidad de mismo.
"Un sistema de control es estable si ante cualquier entrada acotada, el sistema genera una salida acotada"

Criterio de estabilidad de Routh.Este criterio sirve para determinar si es o no estable un sistema de control. Su funcionamiento se basa en la ecuación característica, la cual es la ecuación en el denominador dentro de la función de transferencia.

El objetivo de este criterio es determinar si la ubicación de las raíces de la ecuación esta dentro de la región estable en el plano s.


En nuestra imagen anterior los polos quedaron en los negativos por lo que se puede deducir que la funcion es estable.

nyquist en mi funcion:

En los valores que se dieron en las funciones anteriores fueron inestables

Sistemas de transicion

En esta entrada se modelara un sistema simple y lo representáramos mediante un sistema de transiciones o un grafo de programa, y para mas puntos si se queria, crear la representación en PROMELA. 

El sistema a modelar es la de un microondas:

Componentes.

  • Microondas: Este aparato funcion simplemente al oprimir los botones numericos y al darle en aceptar comienza a calentar la comida mediante giros.
  • Tabla numerica (para el tiempo de calentado): Esta parte del microondas es la que permite al sistema realizar su trabajo ya que si no se presiona un tiempo y al boton aceptar este no hace su trabajo
  • Personas: Este componente no forma parte del microondas (sistema) se implemento ya que sin el las entradas al microondas no serian posibles. Lo que hara es meter la comida y darle tiempo al microondas y oprimir aceptar para que esto funcione.
Microondas:

  • Estados:
-Standby: El microondas permanece esperando a que pongan comida
-Comida: La comida entra y se espera a que el tiempo acabe para calentarla.
-Calentando: El tiempo comienza y se inicia calentar, al terminar el microondas hace un sonido de terminado.
-Fin: La comida es devuelto caliente a la persona, y se regresa al estado de inicio.
  • Acciones Involucradas:
-Insertar comida: La persona inserta la comida al microondas.
-Teclea_tiempo: Se teclea el tiempo y se presiona aceptar para comenzar a calentar.
-Sonido: El microondas realiza un sonido para decir que a acabado

Aqui parte del grafo:

Tabla numerica
  • Estados:
-Inicio: La tabla numerica tiene un pequeño display donde muestra la hora a la espera de la hora.
-Timer: Al precionar aceptar, el timer hace una cuenta hacia atras hasta terminar calentando la comida.
  • Acciones Involucradas:
-Sonido: para poder sacar la comida.
-btn aceptar: Teclear el tiempo deseado y y oprimir aceptar para que empiece a calentar.

Aqui parte del grafo:

Persona:
  • Estados:
-Inicio: La persona se encuentra sin hacer nada hasta que le de hambre.
-Espera: La persona espera a que la comida este lista.
  • Acciones Involucradas:
-Insertar comida: La persona inserta la comida al microondas.
-Sonido/cancelar: La persona espera o cancela para poder sacar su comida.

Aqui la parte del grafo:

Estados:
0, 1 = Estados del componente Persona (Inicio, Espera)
A, B, C, D = Estados del componente Tostador(Standby, Comida, Calentando, Fin)
X, Y, Z = Estados del componente de las teclas (Stanby, Esperar, Sonido)

Acciones:
1, 2, 3, 4: meter_comida, sonido, Teclear, cancelar

Aqui el grafo completo:



jueves, 25 de octubre de 2012

Extra points

what will be done with this problem is to know if a group with the theory of gruop.

Problem to solve

2 + 3 = 10
8 + 4 = 96
7 + 2 = 63
6 + 5 = 66
9 + 5 = ?

Solution to problem:

2 + 3 = 10 (2+3=5(2))
8 + 4 = 96 (8+4=12(8))
7 + 2 = 63 (7+2=9(7))
6 + 5 = 66 (6+5=11(6))
9 + 5 = ? (9+5=14(9))
 
Result:
9 + 5 = 126



Associativity:
a \circ (b \circ c)=(a \circ b) \circ c, \forall a,b,c \in G


this point is not met and the order matters of factors in this problem, the result is not the same.

Neutral element:

 \exists e \in G : e \circ a=a \circ e=a

This time this point is not met because the result set given in the problem are not equal to the sum of any factor.


Symmetrical element: 
 \forall a \in G\quad \exists a^{-1} \in G : a\circ a^{-1}=a^{-1} \circ a=e


At this point I think it's obviously not apply to what is being done on the problem

Group:
A group is a set G which has defined an internal composition law that satisfies the above axioms.

Then this, problem is not a group because don´t meets with some requeriments, do as explain his definition.

This is of wikipedia now i try explain of the pdf of Elisa Schaeffer:

Identity:
                                                  e°g = g°e = g

this is not true since we have to
a(a + b) = c
a(a + e) is different from c

Reverse:
so if there is no identity, can not be reversed and also used "e"



Associativity:
the associativity is not because we
a (a + b) = c
Not the same that
b (b + a) = c

Closing:
this point is correct because it says that if g ° h belongs to G
And that g, h belongs to G
Are integers
If you multiply
You get a whole number


Then we come to the same conclusion on this problem is not a group

Well, I hope that the result is the desired and sorry for my bad english. 


References:
http://es.wikipedia.org/wiki/Teor%C3%ADa_de_grupos

Panama Stream cipher

Introduction:
Panama is a cryptography primitive which can be used both as a hash function and a stream cipher. Based on StepRightUp, it was designed by Joan Daemen and Craig Clapp and presented in the paper Fast Hashing and Stream Encryption with PANAMA on the Fast Software Encryption (FSE) conference 1998. The cipher has influenced several other designs, for example MUGI.
The primitive can be used both as a hash function and a stream cipher. The stream cipher uses a 256-bit key and the performance of the cipher is very good reaching 2 cycles per byte.
As a hash function, collisions have been shown by Vincent Rijmen et al. in the paper Producing Collisions for PANAMA presented at FSE 2001. The attack shows a computational complexity of 2^82 and with negligible memory requirements.
At FSE 2007, Joan Daemen and Gilles Van Assche presented a practical attack on the Panama hash function that generates a collision in 2^6 evaluations of the state updating function.
Guido Bertoni, Joan Daemen, Michaël Peeters, and Gilles Van Assche proposed, at NIST's 2006 Second Cryptographic Hash Workshop, unveiled a Panama variant called RadioGatún. RadioGatún is strictly a hash function; it does not have the known weaknesses that Panama's hash function has.


Structure of Panama



Panama contains two main elements. A shift register, with 32 cells, each containing a vector with eight 32-bit words, and a recirculating mixing function, resembling the f-function in a block cipher, which operates on a "state" consisting of seventeen 32-bit words. (While it has been noted that SHA-1 inspired Panama, I do not find the resemblance obvious.)

There are three fundamental operations that form part of Panama:
  • Panama is reset by setting both the 17-word state and the contents of the shift register to all zeroes.
  • A vector of eight 32-bit words is fed to Panama through a Push operation. Operations unique to the Push function are shown by the light dotted lines in the diagram. In a Push operation, the incoming vector is used as one of the inputs to the state transition function (the other input is the contents of one of the cells in the shift register), and is also used to XOR with the recirculating values in the shift register.
  • A vector of eight 32-bit words is recieved from Panama by means of a Pull operation. The line of alternating dots and dashes shows the operations unique to the Pull function in the diagram. In a Pull operation, the 32-bit words numbered 9 through 16 in the state are used as the output, and words 1 through 8 are XORed with the recirculating values in the shift register. The inputs to the state transition function both come from stages in the shift register, one not used for any special purpose in the Push operation replacing the input, absent from a Pull operation.
When Panama is used as a stream cipher, first the key is input by one Push operation, and then an initialization vector is input by a second Push operation. Then, 32 Pull operations are performed, discarding their output, to allow the internal state of Panama to be fully mixed.

When Panama is used as a hash function, the message to be hashed, followed by a 1 bit and as many zeroes as are needed to cause the message to occupy an integer number of 256-bit blocks, is input to Panama through a series of Push operations. Then, after a number of Pull operations with their output discarded, so that the effects of even the last block of the message are fully diffused, the output from a final Pull operation constitutes the hash.

The state transition function of Panama operates on 17 32-bit words, numbered 0 through 16. Its steps are visible in the diagram, and are, in order:
  • Nonlinearity: each word is XORed with the OR of the previous values of the next word and the complement of the word after, going around the circle from word 0 to 16 and back to 0.
  • Bit Dispersion: first, the words are transposed (by a simple decimation with interval 4), then the words undergo circular left shifts of different sizes.
  • Diffusion: each word is XORed with both the previous values of the next word and the word four positions ahead, again going around the circle.
  • Buffer Injection: Word 0 is XORed with 1; words 1 through 8 are XORed with the first input to the function, and words 9 through 16 are XORed with the second input to the function.


The Panama Stream Encryption Scheme
The stream cipher is initialized by first loading the 256-bit key K, the 256-bit diversification parameter Q, and performing 32 additional blank Pull iterations. During key-stream generation, an eight-word block z is delivered at the output for every iteration. In practice, the diversification parameter allows for frequent resynchronization without the need to change the key.

Vulnerabilities
The first thing to note is that the presence of the blank rounds makes it hard
to produce a collision in the digest if there is a difference in either the state or
the buffer after all the message blocks are input. Due to the invertibility of the
state updating function such a difference will not cancel out. Moreover, the lack
of external input and the propagation properties of the state updating function
give the attacker almost no control over the final difference. Therefore, our goal is to produce a collision in both the state and the buffer before the blank rounds.
We produce a collision by following a trail. Two instances of Panama process
two different messages (p and p + dp), which have a given difference (dp). The
trail also specifies the differences in the state (da) and in the buffer (db) between the two instances of Panama, at each round. So, not only the two messages must have the given difference, they must also produce the right difference in the state and in the buffer.
We shall now describe the general structure of the trail used in the scope of
this article. We will first talk about the sequence of message differences, then
about the differences in the state.
In the sequel, the round numbers are specified between brackets in super-
script: ·(i) . The convention is that p(i) is the message block processed during
round i, and a(i) is the value of the state after round i.



Tracing the path of information through the state transition function of Panama shows that a trivial application of differential cryptanalysis principles does not suffice to obtain some bits of the buffer by means of a known plaintext attack on Panama when used as a stream cipher. The following diagram illustrates what happens when an attack is attempted:

With known plaintext, one knows the value of the output bits from Panama. If one has two successive output blocks from Panama, tracing through the state transition function leads to the following results:

Initially, words 9 through 16 of the state are known.
After the nonlinearity step, words 9 through 14 of the state are still known for certain. The bits of word 15 which correspond to 1 bits in the former value of word 16 are known as well, but the other bits of word 6 are unknown. The bits of word 16 are, with a probability of 75%, the inverses of their former values.
After the bit dispersion step, the words known with certainty are words 2, 4, 9, 11, 14, and 16, and the words about which partial information is available are words 7 and 12. The right words in the right places are not available to allow a known or partly known word to exit the diffusion step for comparison with a word known from the current output block, by which means some buffer contents could be found.
Even so, the fact that it comes this close to solution makes one wary of the danger of a differential attack.



References:
http://en.wikipedia.org/wiki/Panama_(cryptography)
http://www.quadibloc.com/crypto/co4821.htm
http://www.cosic.esat.kuleuven.be/publications/article-81.pdf

martes, 23 de octubre de 2012

Red de petri

Bueno para esta semana se encargo realizar una Red de Petri, primer daremos un poco de introduccion:

Una Red de Petri es una simulación de un sistema, con eventos de forma paralela, concurrente o de manera distribuida, puede ser representada tanto matemáticamente o gráficamente.

Estos sistemas por lo general están compuestos por:
  • Transiciones: Estas transiciones están unidas por lo general a dos lugares o mas.
  • Lugares: Son los estados del sistema.
  • Marcas: Representación de los objetos dentro de los lugares.
Estas redes de petri tienen condiciones que se deben cumplir al momento de construirse:
  • Un arco une siempre lugares con transiciones y nunca dos lugares o dos transiciones.
  • Una transición puede ser destino de varios lugares y un lugar puede ser el destino devarias transiciones.
  • Una transición puede ser origen de varios lugares y un lugar puede ser origen de varias transiciones.
  • Los lugares pueden presentar marcas (una marca se representa mediante un punto en el interior del círculo).
  • Cada lugar tiene asociada una acción o salida. Los lugares que contiene marcas se consideran lugares activos. Cuando un lugar está activo sus salidas están a uno.
  • A las transiciones se les asocia eventos (funciones lógicas de las variables de entrada). Una transición se dice que está sensibilizada cuando todos su lugares origen están marcados.
  • Cuando ocurre un evento asociado a una transición (la función lógica se hace uno), se dice que la transición está validada.
Bien ahora vamos a realizar nuestra red de petri con la ayuda de python-snakes.


Bien lo que se hizo fue la del funcionamiento de un elevador

Estos son los estados:
  • Espera
  • BPS = Boton para subir
  • BPB = Boton para bajar
  • Abrirps = puerta se abre para subir
  • Cerrar = puerta se cierra para el viaje
  • P1 = Piso 1 
  • P2 = Piso 2
  • P3 = Piso 3 
  • Abrirpb = se abre elevador para bajar.
Estas son las transiciones:
  • Selec Pet = Selecciona peticion(para que llegue el elevador).
  • Esperabps = Espera la llegada si presiono BPS.
  • Esperabpb = Espera la llegada si presiono BPB.
  • Tiempo Subida = Tiempo para abordar el elevador.
  • Presion P1 = Se preciono la tecla P1.
  • Presion P2 = Se preciono la tecla P2.
  • Presion P3 = Se preciono la tecla P3.
  • Tiempo Bajada = Tiempo para bajar del elevador.
  • if btn <= 1 = esta es condicion por si otro boton esta presionado.



Aqui la imagen que me lanza python snake:





Aqui esta el codigo:


Referencias:
http://es.wikipedia.org/wiki/Red_de_Petri
Tutorial

jueves, 18 de octubre de 2012

Laboratorio auto: tarea 4

Este es el problema que se escogió para la tarea 4 en laboratorio:
  • Obtenga la respuesta impulso unitario y la respuesta escalón unitario de un sistema realimentado unitariamente cuya función de transferencia en lazo abierto sea.

Primero sacaremos el impulso unitario con la ayuda de octave haciendo lo siguiente:
  • Entramos a octave en la terminal tecleando "octave", ya dentro de octave le daremos los valores de nuestra G(s), que en este caso son 2s + 1 / s^2, y se hará de la siguiente manera.


En octave para sacar el impulso la podremos sacar con la funcion "impulse" que nos brinda este lenguaje, hay que acomodarlo tal y como muestra la imagen para que nos de el resultado, bien los valores dados en los corchetes son los valores de nuestra formula de transferencia solamente que también se esta contando los valores del cuadrado (x^2) es por eso que se le pone 0 a los valores que no se tengan.
  • Aqui el resultado que nos da al teclear los valores:

Ahora sacaremos el siguiente resultado que es la respuesta escalón unitario, solo que esta sera a mano y en octave.

  • Bien tenemos nuestra función:

  • Convertimos nuestra función a una función de transferencia de lazo cerrado que es la siguiente:



  • La respuesta escalon unitario es:


C(t) =  1 + te^-t - e^-t

Aqui unos tutoriales para resolver la funcion escalon unitario 
http://www.youtube.com/watch?v=cC50zfVxR0c&feature=fvwrel

Aqui los resultados computacionalmente:

  • Nuevamente con octave y con la funcion que tiene este lenguaje "step" podremos sacar facilmente el resultado de manera grafica aqui los resultados:
Aqui vemos que el acomodo es similar al de la funcion "impulse"


Esta es la grafica que nos arroja:

Cipher block: Safer

Introduction.

In cryptography, SAFER (Secure And Fast Encryption Routine) is the name of a family of block ciphers designed primarily by James Massey (one of the designers of IDEA) on behalf of Cylink Corporation. The early SAFER K and SAFER SK designs share the same encryption function, but differ in the number of rounds and the key schedule. More recent versions SAFER+ and SAFER++ were submitted as candidates to the AES process and the NESSIE project respectively. All of the algorithms in the SAFER family are unpatented and available for unrestricted use.
A weakness in the key schedule was corrected, with an S being added to the original Safer K designation to create Safer SK. There are some attacks against reduced round variants of Safer. Safer is secure against differential and linear cryptanalysis. However, Bruce Schneier, author of Applied Cryptography, recommends against using Safer because, "Safer was designed for Cylink, and Cylink is tainted by the NSA."


Structure




Description of SAFER

SAFER is a block cipher that operates on 64-bit blocks considered as 8 bytes. It consists of a round transformation iterated r times followed by a final output transformation. Recommended values of r are 6 for SAFER K-64 and 10 for SAFER K-128. The key scheduling, described below, gives (2r + 1)  8-byte subkeys K1; : : : ; K2r+1. Subkeys K2i¡-1 and K2i are used in round i, and the subkey K2r+1 is used in the output transformation. A diagram of the round function is given in the image. The ith round function is built from four basic operations.


1. Mixed XOR/Addition Layer: Bytes 1; 4; 5; 8 of the round input are XORed with bytes 1; 4; 5; 8 of subkey K2i¡-1. Bytes 2; 3; 6; 7 of the round input are added bytewise (modulo 256) with bytes 2; 3; 6; 7 of subkey K2i¡-1.

2. Nonlinear Layer: For a byte x, 45 .x/is defined to be 45x modulo 257, where x is regarded as a number 0 · x · 255, with the convention that 45 .128/ D 0. As 257 is prime and 45 is a primitive element modulo 257, this is an invertible function of a byte, and log 45.¢/ is defined to be its inverse. The 45.¢/transformation is applied to bytes 1; 4; 5; 8 of the output of the mixed XOR=addition layer and the log 45.¢/transformation to bytes 2; 3; 6; 7.

3. Mixed Addition=XOR Layer: Bytes 1; 4; 5; 8 of the output of the nonlinear layer are added bytewise (modulo 256) with bytes 1; 4; 5; 8 of subkey K2i. Bytes 2; 3; 6; 7 of the output of the nonlinear layer are XORed with bytes 2; 3; 6; 7 of subkey K2i.

4. Pseudo-Hadamard Transform (PHT) Layer: The transforms 2-PHT in Fig. 1 map the byte pair .a1; a2/ to the byte pair .2a1 Ca2; a1 Ca2/, where addition is modulo 256. The effect of the three layers of 2-PHT transforms on the output v of the mixed addition=XOR layer is to map it to vM, where addition is modulo 256 and the output of the PHT layer is the output of the round function.
The final output transformation afterr rounds is an application of the mixed XOR/addition layer with the output of the rth round and the subkey K2r+1.
Decryption using SAFER is carried out by reversing these operations and we do not describe it in detail.


Design Principles for SAFER
 •Encrypting structure – faster diffusion than for substitution-permutation cipher.
• Byte orientation – during encryption and decryption, all operations are on bytes.
• Group operation at round input – “perfect secrecy” with a “one-time key”.
•Use of 2 additive group operations on bytes -- takes advantage of each’s
strength.
•Confusion via well-defined nonlinear functions – no “suspicious-looking”
tables.
•Fast-diffusing linear transformation – via the PHT and the Armenian shuffle.
•Scalability – Bytes can be made to 2 or 4 (or even 16) bit characters for study.
•Biases in key schedules – eliminates “weak keys”.
•Parity word and selections in key schedules – diversity in round subkeys.
•Number of rounds – chosen for security with a margin of safety.

ANSI C with 200 MHz Pentium Platform: • SAFER+ with 128 bit key (8 rounds) – about 18.2* megabits/s of
encrypted data and about 15.3 microseconds to run the key schedule.
• SAFER+ with 192 bit key (12 rounds) – about 12.3* megabits/s of
encrypted data and about 28.6 microseconds to run the key schedule.
• SAFER+ with 256 bit key (16 rounds) – about 9.3* megabits/s of
encrypted data and about 45.7 microseconds to run the key schedule.

Assembly on 8-bit Processors of the MCS 51 family with 16 MHz clock: •SAFER+ with 128 bit key (8 rounds) – about 25.6 kilobits/s of encrypted data.
• SAFER+ with 192 bit key (12 rounds) – about 16.9 kilobits/s of encrypted data.
• SAFER+ with 256 bit key (16 rounds) – about 12.7 kilobits/s of encrypted data.

Advantages of SAFER+•A proven track record of security
•Speed and simplicity
• Transparency
• Flexibility of Use
• Flexibility of Environment

Limitations of SAFER+ •No proof of complete security
• Encryption/Decryption Dissimilarity
References:
http://tlapixqui.izt.uam.mx/sem_cripto/safer/AnalysisOfSAFER.pdf
http://csrc.nist.gov/archive/aes/round1/conf1/saferpls-slides.pdf
http://en.wikipedia.org/wiki/SAFER
http://kremlinencrypt.com/algorithms.htm

martes, 9 de octubre de 2012

Reporte 2: Diagrama de bloques

Para comenzar primero se definiran nuevas entras y salidas asi com la funcion de transferencia ya que al parecer las anteriores estaban equivocadas, para empezar:

¿Que se esta haciendo?
Se esta trabajando en un ventilador(cooler) que pueda ser controlado por la temperatura de la laptop o computadora.

Entonces:
mi entrada es:
donde:
  • dT/dt = cambio de tempuratura con respecto al tiempo.
  • k = constante de proporcionalidad.
  • T= Temperatura final.
  • T0 = Temperatura inicial.

Sacamos la transformada de la entrada por lo tanto nos queda:

y la salida sera:
dodne:
  • w = Velocidad angular
  • dΘ/dt = cambio de velocidad angular con respecto al tiempo

le sacamos su transformada:

donde L = es la transformada.

como estamos hablando de movimientos del ventilador se penso que esta formula seria la mejor.

Funcion de transferencia:
Cabe destacar que esto es rapido ya que esta no es la tarea.

Bien ya que quedo todo ahora haremos lo que se nos pidio que es realizar un diagrama de bloques ahora si con las funciones bien hechas.

Este es el primero que nos queda:
Asi es como queda: