Page 1 of 1

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

Posted: 2008-11-22T16:45:32-07:00
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);
}

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

Posted: 2008-11-22T19:43:30-07:00
by magick
We have patch for the problem you reported. It will be available in the next point release. Thanks.