Skip to content

Fails to decrypt this example #235

@tttony

Description

@tttony

Version: commit 2385675
VS 2017
Windows 7 x64 (for testing)

The decryption result in bytes/string is:

46 a9 dc 7b 96 19 b8 61 8c df a2 1c 94 c7 8e c1 54 68 69 73 20  F©Ü{–.¸aŒß¢.”ÇŽÁThis 
69 73 20 70 61 74 72 69 63 6b 21 54 68 69 73 20 69 73 20 70 61  is patrick!This is pa
74 72 69 63 6b 21 54 68 69 73 20 69 73 20 70 61 74 72 69 63 6b  trick!This is patrick
21 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ! 

The expected string result should be:

This is patrick!This is patrick!This is patrick!This is patrick!

Here is the code example:

#include <stdio.h>

#define CBC 1
#define CTR 1
#define ECB 1

#include <string.h>

#include "../aes.h"

int main()
{
    struct AES_ctx ctx;

    char input[] = "This is patrick!This is patrick!This is patrick!This is patrick!";
    size_t inlen = strlen(input);

    char copyin[256] = { 0 };
    strcpy(copyin, input);

    char key[] = "gmufm6nfjcylr4pf";
    char iv[] = "ThisFuckinIvHere";

    AES_init_ctx_iv(&ctx, key, iv);
    AES_CBC_encrypt_buffer(&ctx, copyin, inlen);
    AES_CBC_decrypt_buffer(&ctx, copyin, inlen);

    printf("CBC decrypt: ");
    if (0 == memcmp(input, copyin, inlen)) {
        printf("SUCCESS!\n");
        return 0;
    }
    printf("FAILURE!\n");
    return 1;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions