jueves, 1 de noviembre de 2012

My code based on LSB (the least significant bit) 










The script consists mainly of three functions to hide the message in the image:

The function obtbytim(img):  in this function obtains the three colors of each pixel in the image.


The function enviobyte (byte1, img): in this function writes the new values ​​of the colors.

The function esconder(imagen, escon): loading the hidden message, is converted to bits and then use the function enviobyte () to write new values ​​in the image.

The first for from the function esconder() serves to determine the length of the message and the second to go in getting the message bit

jueves, 25 de octubre de 2012


ORYX

ORYX is an encryption algorithm that is implemented in cellular communications in order to protect the data traffic in a data stream designed for a strong level of 96-bit key with a time complexity of 2 ^ 16, with how to reduce the force to export 32-bit data, but due to errors of force is a 16-bit trivial and any signal can be broken after the first bytes 25-27. ORYX generates a keystream which is used as a one-time pad or XOR with the message to encrypt or decrypt.
ORYX is a simple encryption based on binary linear feedback registers to shift gears (LFSR) that protects mobile data transmission, this figure contains four components: three 32-bit LFSR labeled LFSRA, LFSRB and SP LFSRK and a box containing a known L permutation of integers from 0 to 255.
Each of the functions you if definition of independent feedback:

  • For LFSRK this feedback function defined as follows:

X ^ 32 + X ^ 28 + X ^ 19 + X ^ 18 + X ^ 16 + X ^ 14 + X ^ 11 + X ^ 10 + X 9 + X ^ ^ 6 + x ^ 5 + x + 1

  • For feedback features LFSRA defined:

X ^ 32 + X ^ 26 + X ^ 23 + X ^ 22 + X ^ 16 + X ^ 12 + X ^ 11 + X ^ 10 + X ^ 8 + X ^ 7 + X ^ 5 + X ^ 4 + X ^ 2 + X + 1

And

X ^ 32 + X ^ 27 + X ^ 26 + X ^ 25 + X ^ 24 + X ^ 23 + X ^ 22 + X ^ 17 + X ^ 13 + X ^ 11 + X ^ 10 + X ^ 9 + X ^ 8 + X ^ 7 + 2 + X + 1


  • And the feedback features LFSRB is:

X ^ 32 + X ^ 31 + X ^ 21 + X ^ 20 + X ^ 16 + X ^ 15 + X ^ 6 + X ^ 3 + X + 1

Where L is formed by the duration of the call and is formed from said algorithm initialized with a value during the call set each byte of keystream is generated as follows according to the feedback functions set for each of the shift registers:

  1. Once LFSRK approaches
  2. LFSRA once this step as one of the definitions of different feedback on the content of a stage of LFSRK
  3. LFSRB is stepped, one or two times depending on the contents of the stage LFSRK
  4. The high byte LFSRK states, LFSRB LFSRA and combine with the purpose of forming a keystream byte:


Keystream = (High8K + L [High8A] + L [High8B]) mod 256

Table L no secret L is different for each message or byte input








In the higher byte of LFSRK where the key is determined for the LFSRA, B and sometimes varies depending LFSR implementation since the algorithm is known chains the only unknown to an attack is the initial contents of the registers 32 -bit linear feedback shift. As believed to have a space of 96-bit key in which there are 2 ^ 96 possible initial states in ORYX, but if an attacker obtains a portion of the keystream produced by ORYX can work backwards and divide and get the full 96-bit initial state all the attacker has to do is apply XOR to the known parts of the plaintext and the ciphertext to obtain the portion of the key chain.

Means known keystream byte produced at time t as K (t). Indicating the highest LFSRA 8-bit, and LFSR LFSRK at time t as: High8 A (t), High8 B (t), and High8 K (t). So the initial state of each record in the high 8-bit are: High8 A (0), High8 B (0), and High8 K (0).

The first byte of the key stream produced by the high functions to apply 8-bit of each stage where K (1) = (L [High8 A (1)] + L [High8 B (1)] + K ( High8 1)) mod 256, where L is the permutation of the box S.

At time t = 2, High8 A (2), and High8 K (2) each have a new unknown bit shifted in them, and High8 B (2) have one or two unknown bits shifted therein. However, we consider that the number of bits shifted in High8 B (2) is dependent on 1 bit of the high byte from LFSRK then the total number of possible states at time t = 2.
If the bit in the high byte says LFSRB to change twice, then 4 values ​​will likely High8 B (2) and there will be two possible values ​​of A (2) for a total of 2 * 4 = 8 possible states High8. Otherwise, if LFSRB moves once, there High8 2 possible values ​​B (2) and two possible values ​​of High8 A (2) for a total of 2 * 2 = 4 possible states. Therefore, there will be a total of 8 +4 = 12 possible states for a time t = 2. In general, if the current state is known at time t, then there will be 12 possible states at time t +1.

It compares all possible states at time t = 2, and compare their string bytes associated with K (2). If no match is found then that our guesses for High8 A (1) and High8 B (1) were wrong. After repeating this process 24 times were obtained internal states of all three shift registers which is consistent with the known keystream. Each iteration requires a keystream byte known, and one byte is required for the initial estimate of the High8 bits.
Table extensions A, B


Testing


The attack is analyzed to find the part of the attacks made by which the initial state can be successful for different key lengths for different procedures that are used, with the initial states to 0 will generate a series for LFSR LFSRB, LFSRA and LFSRK, with segment key s of length N, Z {(i)} where: i = 1


  • Input: The length of the observed keystream sequence, N.
  • Initialization: i = 1, where i is the current attack rate, i also define max, A maximum number of attempted attacks to take place. The LFSR seed initial state index, j is the current B LFSR seed initial state and k is the index K initial state current LFSR seed index.
  • Stopping Criteria: The test procedure is stopped when the number of attacks reaches i max out.
  • Step 1: Generate initial state pseudorandom seeds ASEED I KSEED BSEED me and I for LFSR's, and LFSRK LFSRB, respectively.
  • Step 2: Generate pseudorandom initial states using SEED LFSRA I KSEED BSEED me and I for LFSRA, LFSRB and LFSRK, respectively.
  • Step 3: Generate the string of bytes sequence {Z (i)} N i = 1
  • Step 4: Apply the attack on Z (i)} N i = 1 for the reconstruction of the initial states of the three LFSRs
  • Step 5: If i ≤ i max, Increases i go to step 1.
  • Step 6: Finish the procedure.
  • Output: LFSRA reconstructed initial states, and LFSRK LFSRB


Bibliographies:

jueves, 18 de octubre de 2012

HastyPuddingCipher (HPC)


It is a variable size block block cipher designed by Richard Schroeppel. It has a number of unusual properties for a block of encryption block size and input key length is variable, and including an additional input parameter called the "spice" which is intended to be used as a secondary, not secret key. The figure was the only candidate HastyPudding AES designed exclusively by American cryptographers.

A variable length block cipher:

·         Accepts any size key (primary key) of 0 or more bits.
·         Accepts any size block of plaintext, 0 or more bits
·         A 512-bit key optional secondary (SPICE).

·         The figure is HastyPudding 5 different sub-ciphers:
 HPC Tiny bits 0-35
 HPC-Short bits 36-64
 HPC-Medium 65-128
 HPC-Long 129-512 bits
 513 + HPC-bit Extended

The figure HastyPudding algorithms mostly use 64-bit words internally. Encryption is designed to run on 64-bit machines, which can easily perform simple operations on 64-bit words.

Basic Operations

 

·         Addition
·         Abduction
·          Exclusive OR
·          Shifts

Setup Key Expansion (KX)

·         Each has a subcipher KX (key expansion) table size 256 words, generated from the key
·         Procedures KX installation table:

 (1) Initialization Table KX
 (2) The first 128 words in the table XOR key KX (KX [0] - KX [127])
 (3) Perform function stirring at psudo KX-randomize the table.

·         Continue with step 2 and 3 with the second key 128 words, until all has been key in the matrix KX XOR

Initialization Table KX


• The first three words of the KX table are initialized:

 KX [0] = PI19 + sub-cipher number.
 KX [1] = E19 * the key length.
KX [2] = R220 turn left sub-number cipher bits.

·         Where PI19, E19, R220 are internal "random" numbers. The remaining 253 words of the matrix     are filled with pseudo-random:

KX [i] = KX [i-1] + (KX [i-2] ^ KX [I-3]> KX ^ [i-3] <).

The function of the stirring of the KX table:


• Purpose: pseudo-random KX table, allowing each bit to influence all other bits.
• Eight internal state variables initialized as
               s0 = KX [248], ..., s7 = KX [255]
• Several passes of agitation

A pass agitation


• s0 = ^ (KX [i] ^ KX [(i +83) + 255]) + KX [s0 and 255]
• s1 = s0 +
• ^ s3 s2 =
• s5 - = s4
• ^ = s6 s7
• s3 + = s0>

• ^ s4 = s1 <

• ^ = s3 s5 << (s1, 31)
• s6 + = s2>

• s7 | = s3 s4 +
• s2 - = s5
• s0 - = ^ i s6
• ^ s1 = s5 + PI19
• s2 + = j s7 >>
• s1 s2 ^ =
• s4 - s3 =
• ^ = s5 s6
• s0 + = s7
• KX [i] = s2 + s6 where I = 0 to 255, the KX table index. J is the pass number

Spice

The spice is a secondary key of 512 bits (an array of 8 words of 64 bits), may be completely or partially hidden, or fully open, is expected to be changed often, perhaps each block encryption.



Encryption

 

·         Plain text is copied to encrypt the state variables s0, s1, ... (Up S7, as the block size)
·         Performing intermediate mixture 8 rounds of: mixing the plaintext data with the table matrix KX and spice.
·          Finally, s0 = s0 + KX [Block 8], s1 = s1 + KX [block 9], ... and so on.

Decoded
 

·         Decryption is done by reversing the encryption steps (each step is invertible in encryption)
·         The order of the steps is reversed
·         The individual steps are replaced by their inverses.

Examples:

 s0 = s1 + s0 is reversed - = s1
 ^ s0 = s1 is self-inverse.
 Some special cases need to be addressed.


Performance

The Hasty Pudding figure was claimed to be the fastest AES candidate in a 64-bit architecture, said to be twice as fast as its nearest competitor, DFC, and three times faster than other candidates, and their performance in one 32-bit machine was adequate. In a 32-bit Pentium, Hasty Pudding encryption was rated to 1600 clock cycles, the 10 of the 15 best candidates, the speed of the figure would be significantly affected in a 32-bit machine due to its use of 64 - bit operations, including changes bits.
The encryption key settings Hasty Pudding was rated relatively slow, 120000 cycles on a Pentium. The figure was criticized for his performance in smart cards. Specifically noted the difficulty of maintaining more than 2 KB of RAM for the key table.


 

The C source code

The Key HastyPudding is fundamentally a system of 64-bit encryption, and it plays better on 64-bit, as the Alpha in December is performed reasonably well on 32-bit machines when compiled with a compiler that supports a 64 - bit integer data. This includes GCC, which has a 64-bit "longlong" datostipo. Unfortunately, the ANSI definition does not yet include C "largolargo", so that a solution is used for the reference implementation. The solution defines a structure of 64-bit data U64 (the U is for unsigned) some macros to manipulate the structure. This provides support ANSIimplementación, but at a significant performance penalty. Macros tambiénimpacto the algorithm code readability.
·        
The key size can be any number (integer) of bits.
·         The Key HastyPudding has a 512-bit key secondary SPICE. The spice can be changed in a statement. Concealment of spice is optional.
·         It is estimated that the current security level of 400 bits HastyPudding figure. I am offering a symbolic prize for successful cryptanalytic work.
·          The Key HastyPudding is fast, reaching 247 megabits per second in blocks of 512 bits in a 300MHz Alpha December.
·          The Key HastyPudding is in the public domain and no known patent restrictions.

 

 

Bibliographies

 


 

jueves, 13 de septiembre de 2012


Sokets

Communication between different entities on a network is based on the classic concept Python sockets. Sockets are an abstract concept that refers to the end point of a connection.
The programs use sockets to communicate with other programs, which may be located on different computers.
A socket is defined by the IP address of the machine, the port on which it listens, and the protocol used.
The types and functions needed to work with Python sockets are in the socket module, how could it be otherwise.
Sockets are classified stream sockets (socket.SOCK_STREAM) or datagram sockets (socket.SOCK_DGRAM) depending on whether the service uses TCP, which is connection-oriented, reliable, or UDP, respectively. In this lesson we will cover only stream sockets, which cover 90% of the common needs.

RSA Key Generation

Divide the algorithm into 3 sections: this, key generation, encryption / decryption and signing / verification.
This part aims to generate public and private keys, composed by n one of the two exponents of example (so that the two are canceled), then go to:
First generate two primes with the number of bits we want for encryption, random everything possible, call them p and q, these numbers help us calculate the n and φ:
p = genprime (numero_de_bits)
q = genprime (numero_de_bits)
We get your product, n, and phi (φ) of this using the formula we saw earlier, φ = (p - 1) * (q - 1):
n = p * q
phi = (p - 1) * (q - 1).
































Conclusions

The program is incomplete due to connection problems because it encrypts and decrypts.



http://blog.hackxcrack.es/2011/11/introduccion-la-criptografia-moderna_09.html
http://mundogeek.net/archivos/2008/04/12/sockets-en-python/
http://www.taringa.net/posts/linux/8419721/Sockets-en-python_.html
http://es.wikipedia.org/wiki/RSA

miércoles, 5 de septiembre de 2012


Diffie-Hellman

It should test Manual Hack veryshort a key Diffie-Hellman.

To do this you must play a game where you need to have 3 players which would be: Alice, Bob and Eve. Where rotate each of the players for each of the characters once everyone

Alice chooses a prime "p", a number "g" in the interval (0, p-1) and another number "x" in the interval (0, p-1). So Alice, calculate "X = g ^ x mod p" and send all values ​​except xa Bob. Bob receives the values ​​and choose a number in the interval (0, p-1), and computes "Y = g ^ y mod p", and send the value to Alice, which computes "K = Y ^ x mod p" and Bob computes "K = X ^ y mod p". Alice and Bob should send to Eve values​​: "p, g, X, Y". Eve needs to find the value of "x" or "y" with "X = g ^ x mod p" or "Y = g ^ y mod p", Eve now computes "K = Y ^ x mod p" or "K = X ^ y mod p" and compare this value with that of Alice and Bob "K". If the value of "K" are the same, Eve hacks the Diffie-Hellman protocol

In this case the players Alex as Alice and Marco as Bob framework.

Where they published the following values

p = 17
g = 13
X = 4
Y = 1

Where I had to find the values ​​of: y, x and  k.



Finding missing numbers published the results I got awaiting a response from my partner where I point out if it was right or wrong, and in my case was correct then I can say that hacks the Diffie-Hellman protocol.

jueves, 30 de agosto de 2012

Prueba  aleatoria

 

El objetivo del programa es realizar un test para saber si la clave generada es dificil de romper o de decifrar. 

Para realizar esto debemos saber si esta clave es totalmente aleatoria, por lo cual medimos las frecuencias que se reciben. 

Para lograr esto exiten diferentes puebas pero en este caso usaremos la prueba de "monobit".


Codigo




Algunas pruebas realizadas


Una prueba 




 Mas de una prueba




Concluciones:
Despues de varias pruebas realizadas nos dimos cuenta de que no es totalmente aleatorio ya que no paso la prueba la mayoria de las veces realizada dicha prueba.

Referencias:

http://es.scribd.com/doc/58547826/58/NIST-Test-1-%E2%80%93-Frequency-Monobit-Test

http://www.random.org/statistics/frequency-monobit/