Encipher/DecipherImage doesn't round-trip in 6.4.6-0

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
rmagick
Posts: 245
Joined: 2006-03-16T17:30:48-07:00
Location: Durham, NC, USA

Encipher/DecipherImage doesn't round-trip in 6.4.6-0

Post by rmagick »

The following program enciphers an image, then deciphers it. In 6.4.5-8, the deciphered image has the same signature as the original image. In 6.4.6-0 the signatures are different.

The input image is Image as usual.

Code: Select all

/*

Tim Hunter, cyclists@nc.rr.com

gcc `Magick-config --cflags --cppflags` test_encipher.c `Magick-config --ldflags --libs` -o test_encipher
*/


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <magick/MagickCore.h>

int main(int argc,char **argv)
{
    ImageInfo *info;
    Image *image, *enc;
    const char *image_sig, *enc_sig;
    ExceptionInfo exception;
    MagickBooleanType okay;


    InitializeMagick(argv[0]);

    puts(GetMagickVersion(NULL));

    GetExceptionInfo(&exception);

    info = CloneImageInfo(NULL);
    strcpy(info->filename, "Flower_Hat.jpg");
    image = ReadImage(info, &exception);
    if (exception.severity != UndefinedException)
    {
        printf("ReadImage: %s: %s", exception.reason, exception.description);
        exit(1);
    }

    enc = CloneImage(image, 0, 0, MagickTrue, &exception);
    okay = EncipherImage(enc, "passphrase", &exception);
    if (!okay)
    {
        exit(1);
    }
    okay = DecipherImage(enc, "passphrase", &exception);
    if (!okay)
    {
        exit(1);
    }

    SignatureImage(image);
    SignatureImage(enc);

    image_sig = GetImageProperty(image, "signature");
    enc_sig = GetImageProperty(enc, "signature");

    printf("Image: %64s\n", image_sig);
    printf("Enc:   %64s\n", enc_sig);

    DestroyExceptionInfo(&exception);
    DestroyImageInfo(info);
    DestroyImage(image);
    DestroyImage(enc);
    DestroyMagick();

    exit(0);
}
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Encipher/DecipherImage doesn't round-trip in 6.4.6-0

Post by magick »

We have patch for the problem you reported. It will be available in the next point release. Thanks.
Post Reply