i have a series of encrypted text , they encrypted by aes 256 bit cbc mode
for every encrypted text there is an iv that i have them also
and i know its algorithm is aes 256 bit cbc mode
i can generate new encrypted values that i know what is plain text, but the iv would be different
i have something else named mac that i don't know what it is, it is 64 character in hex format
by the way i know the algorithm is for one of laravel plugins named elocryptfive
can i do any attack on it to find key or decrypt values?
Related
I was trying to come up with AES encryption scheme for my project. Basically I want the user to crypt data using just a 32 byte key to decrypt a file of crypted data, since remembering and storing vi for every block seems very cumbersome. I know of many encryption programs that use just a key for encryption and nothing else. How do i go about this problem?
My current scheme looks something like this:
Block:
16 bytes vi,
up to 1 048 576 bytes of data (1MB)
Encryption:
Input 32 byte key
First vi is randomly generated 16
bytes that get encrypted with AES ECB (initial key)
1MB of data is encrypted using CTR (initial key, the block vi)
Any further block follows the same logic
Decryption:
Input 32 byte key
Decrypt first 16 bytes using ECB
Decrypt the first block of data using CTR (initial key, the block vi)
Any further block follows the same logic
Is this good enough security wise? I think it should work since vi for every block is random, and since vi itself is encrypted using ECB it works pretty much like one time pad, correct?
I have a version of AES algorithm with 128bits in plaintext, now i want to change this version to 32bits in plaintext . How can i do this, please ?
That's part of my code when i send data to core AES, i send 128bits to encrypt and i check if the result is true.
apb_write(x"e2bec16b",AES_CMD_ADDR_DATAIN_0);
apb_write(x"969f402e",AES_CMD_ADDR_DATAIN_1);
apb_write(x"117e3de9",AES_CMD_ADDR_DATAIN_2);
apb_write(x"2a179373",AES_CMD_ADDR_DATAIN_3);
apb_write(x"80000005",AES_CMD_ADDR_CONTROL); --confige AES with mode (CBC)
apb_write(x"acab4976",AES_CMD_ADDR_DATAOUT_0);
apb_write(x"46b21981",AES_CMD_ADDR_DATAOUT_1);
apb_write(x"9b8ee9ce",AES_CMD_ADDR_DATAOUT_2);
apb_write(x"7d19e912",AES_CMD_ADDR_DATAOUT_3);
The question : how i can send just 32bits and check , after, send 32bits and check ....?
how i can do this ?
AES is as far as I know only defined for blocks of 128 bits.
If you want to encrypt blocks of 32 bits, you'd need to pad your plain text (with for example 0's) until you reach 128 bits. Then, if you want to decrypt it, just decrypt it normally and after the decryption chop off the last (or first, depending which side you padded) 96 (128 - 32) bits.
I'm writing a python script to encrypt/decrypt strings with RSA. I have no problems with the algorithm itself, but I don't understand how to use it correctly.
I mean, there is no point in encrypting every each symbol in a string separately. Because same symbols will give us same ciphers (like Caesar cipher). So I think I should divide the whole message into blocks of same length.
But it makes it difficult to decrypt the message. Because after you encrypt the blocks, the length of each block could change. So when decrypting, you don't know where a certaing blocks starts and where it ends.
For example, when I encrypt "stronger" with RSA I get:
5716225862
I divided the original message into 4 blocks of 4 symbols. But after encrypting I get a message of 10 symbols. And that's the problem.
Hope, you understand what I mean. Sorry for my bad English.
Simply said, RSA is not for directly encrypting plain text, it is used for encrypting a symmetric key (AES, for instance), and this is with this symmetric key that you will encrypt (and further decrypt) your plain text.
Since the plain text may have any size, it is encrypted using AES with a stream cipher (for instance AES-256-GCM) or a block cipher (for instance AES-256-CBC).
With AES, same symbols will not give same ciphers, since you have to choose a new random IV (initialization vector) each time you encrypt your plain text.
So, you need to use a 2-steps encryption scheme: use RSA to encrypt a symmetric key, and use this symmetric key to encrypt your plain text.
My device doesn't support full 3DES (EDE). How can I emulate one using standard DES? Encryption mode is CBC.
You start by picking three independent DES keys which are not related to each other in any way.
You will want to put DES into ECB mode, not CBC mode. You also need to ensure that each encryption and decryption operation is done only on 64-bit blocks and nothing more or less. Padding schemes and the likes will cause a vulnerability in the implementation and will lead to the discovery of the block content via brute force faster than a brute force against each key.
Using the first key, encrypt your plaintext. Using the second key, decrypt that value. Using the third key, encrypt the value for your full block. It looks like this:
Encrypt(k3, Decrypt(k2, Encrypt(k1, plaintext)))
Decryption is the other way around and looks like this:
Decrypt(k1, Encrypt(k2, Decrypt(k3, ciphertext)))
When you encrypt your blocks with 3DES you then need to apply your mode of operation like CBC or CTR and apply padding if needed.
Be careful.
Block mode encryption
What you do is that you split the key of size 128 bit (16 byte) or 168 bit (24 byte) in two or three pieces respectively. So for a 16 byte key K you would have two keys Ka and Kb, and for a 24 byte key you would have Ka, Kb and Kc. DES ABC keys have an effective strength of about 112 bits, DES ABA keys have an effective strength of about 80 bits.
To encrypt a single block of 8 bytes (the block size of both DES and 3DES) you would perform the following cryptographic operation: Cn = E(Ka, D(Kb, E(Kc, Mn))) where Mn is the n'th block of the plain text message and Cn the n'th block of the cipher text. If you don't have a Kc then you may use Ka (DES ABC key vs DES ABA key).
For this you need a single block DES encrypt, which is identical to a single block encrypt in ECB mode, or a single block encrypt with CBC and an IV consisting of 8 bytes valued 00h.
CBC
So that's the block encryption sorted, now you need some kind of encryption mode and padding mode. I'll explain CBC mode encryption here, ECB should not be used for encryption non-random data.
With CBC mode encryption you XOR a vector to the plain text. The vector is normally just the output of the last DESede encrypted block. As you don't have any preceding cipher text, you need to create the first vector yourself using random data. This vector is called the initialization vector or IV. See wikipedia for a clear picture.
Padding
Block cipher modes only allow full blocks of plain text to be encrypted. So you would need some kind of padding scheme. Although there are many padding modes, PKCS#5 padding is used most of the time. You should pad the plain text like this: pad with bytes valued 0Xh, where X is the number of padding bytes required to create a full block. X should be between 1 and 8: in other words, PKCS#5 padding is always used; this makes it possible to distinquish the padding bytes from the plain text.
If you use padding in an online protocol then you need to protect against padding oracle attacks. In this case it is highly recommended to use some form of integrity checks, e.g. by adding a HMAC over the cipher text using a separate key.
3DES is just DES used three times on the plaintext:
ciphertext = E_K3(D_K2(E_K1(plaintext)))
plaintext = D_K1(E_K2(D_K3(ciphertext)))
E_Kn = Encryption with Key number n.
D_Kn = Decryption with Key number n.
So you can easily "emulate" 3DES with just DES.
In CBC mode you'll need an IV to start with and then XOR the next plaintext block with the previous ciphertext block. If your device doesn't support CBC then this too is easily "emulated".
Do I have provide AES key + IV for someone to be able to decrypt encrypted data?
Does that increase key length from 128 bit to 256 bits?
Yes, both the key and the IV are needed to decrypt something. Generally, the key should be exchanged using a secure channel or key exchange mechanism. The IV can be transmitted along with the encrypted data in plain text. An IV should ideally be used only once. The main motivation behind using a changing IV is that encrypting the same thing twice should not result in the same ciphertext both times, because this can allow an attacker to draw conclusions about the data encrypted.