0
$\begingroup$

Are there known attacks on AES that uses a 16-bit key? Assuming the data can be 95MB size, and that I can request the same data over and over.

For example, can someone explain to me how this code vulnerable? I know my around C, but can’t seems to find anything here. Usual CRIME attack won’t work.

#include <string.h>
#define MAX_SIZE 100000000
#define MAX_NAME_LENGTH 1000

unsigned char shared_key[16]={0x01,0x23,0x45,0x67,0x89,
0xab,0xcd,0xef,0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef};

char directory_location[50]="../../server_directory/";
char *file_to_string (char *output_string,
FILE *input_file, int *length);

FILE *compress(char *input);

FILE *encrypt(unsigned char *key, FILE *input);

void application_send (FILE *output);

int get_file (char *name, unsigned int name_length)
{

FILE *input, *compressed_file, *encrypted_file;

int file_length;

char uncompressed[MAX_SIZE];

char file_string[MAX_SIZE];

char filename [MAX_NAME_LENGTH];

if (name_length >= MAX_NAME_LENGTH-50)

return -1;

strcpy(filename,directory_location);

strcat(filename,name);

input = fopen(filename,"r");

if (input == NULL)

return -1;

file_to_string (file_string, input, &file_length);

memcpy(uncompressed,name,name_length);

memcpy(uncompressed+name_length,file_string,file_length);

compressed_file = fopen("compressed","w");


if (compressed_file == NULL)

return -1;

encrypted_file = fopen("encrypted","w");

if (encrypted_file == NULL)

return -1;

compressed_file = compress (uncompressed);

encrypted_file = encrypt (shared_key, compressed_file);

application_send (encrypted_file);

return 0;
}
$\endgroup$
3
  • 18
    $\begingroup$ 16-bit or 16-byte key? Brute force on 16 bits can be done very quickly. $\endgroup$
    – Raoul722
    Commented May 6, 2016 at 12:50
  • 1
    $\begingroup$ That's a 16 byte key. Static keys are usually not OK though. I think the addition of the code makes this question off topic - especially when the original question is about a 16 bit key. $\endgroup$
    – Maarten Bodewes
    Commented May 10, 2016 at 15:36
  • $\begingroup$ Meanwhile, I have to agree with the mod-tickets that keep coming up in relation to this question. To be honest, I‘ve reached a point where I’m totally at loss what exactly you’re trying to ask. First you ask about a 16 bit key. Then you edit things and add code showing a 16 byte key, now also asking if the code is vulnerable (which boils down to an off-topic “code review” thing which is off-topic here). It would be cool if you could edit your question in a way so that we can understand what exactly you are trying to ask. As soon as the question starts making sense, I’ll gladly reopen it. $\endgroup$
    – e-sushi
    Commented May 10, 2016 at 18:54

1 Answer 1

13
$\begingroup$

There is no such thing as a 16 bit AES key. AES is a block cipher with a block size of 128 bits and a key size of 128, 192 or 256 bits. As a block cipher, AES can only encrypt 16 bytes (128) bits at a time. AES in itsef is not (CPA) secure as repetition of the plaintext would lead to repetitions of the ciphertext.

To encrypt larger amounts of data, AES needs to be used as primitive in a block cipher mode of operation. Although block cipher mode of operations of course depend on the (high) security of AES, they have their own security boundaries. ECB is not secure at all, CBC needs a randomized IV, CTR needs a unique nonce and has limitations on the size of the input.

The practicalities of establishing the mode and parameters such as the IV depend on the protocol. You would have to examine the protocol, mode and cipher to establish if your use case is secure or not. This would also depend on the attacks you're willing to allow. For instance, just using AES in CBC mode of operation does not protect against man-in-the-middle attacks at all.

$\endgroup$
0

Not the answer you're looking for? Browse other questions tagged or ask your own question.