Encipher / Decipher

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
jpiquemal
Posts: 54
Joined: 2003-12-07T01:57:19-07:00

Encipher / Decipher

Post by jpiquemal »

Hello
How can i recognize an encipehered image ?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Encipher / Decipher

Post by magick »

How can i recognize an encipehered image ?
Two ways: 1) visually it appears as random data; 2) mathematically measure the randomness of the pixels (if its near random pixels it is most likely enciphered).
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Encipher / Decipher

Post by fmw42 »

Interesting. So how would one tell the difference between an enciphered image and one create with +noise in IM?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Encipher / Decipher

Post by magick »

A noisy image is generally not as random as an enciphered image. The noise is generally added or subtracted relative to the current pixel value. However, in rare cases it could be difficult or impossible to differentiate an image created with random noise from one that is enciphered.
jpiquemal
Posts: 54
Joined: 2003-12-07T01:57:19-07:00

Re: Encipher / Decipher

Post by jpiquemal »

would it be possible to set a parameter in the Image structure, telling that the image is enciphered ?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Encipher / Decipher

Post by magick »

Sure we can set a property but the property will not be saved to most of the image formats since arbitrary metadata is not supported by most image formats. The properties are cipher:type, cipher:mode, and cipher:nonce.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Encipher / Decipher

Post by anthony »

For other following this discussion, You can see examples of enciphered images in IM Examples http://imagemagick.org/Usage/transform/#encipher

This includes some images and the pass-phrase used, so you can try to download and decipher them yourself.

WARNING: this is not considered stable, and as such requires a compile time configuration option. It also may still change, though that is starting to become less likely.

Please try out your encryption ideas and either mail them to me, or to the forum, so that I can test them myself, and add them to IM examples for others.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

Re: Encipher / Decipher

Post by rmabry »

For other following this discussion, You can see examples of enciphered images in IM Examples http://imagemagick.org/Usage/transform/#encipher

This includes some images and the pass-phrase used, so you can try to download and decipher them yourself.

WARNING: this is not considered stable, and as such requires a compile time configuration option. It also may still change, though that is starting to become less likely.

Hey Anthony,

I'm told that -encipher/-decipher are now standard, so when you get a chance, you can remove the caveat from this page:

"The "-encipher" and "-decipher" operators was added to IM v6.3.8-6. However it is currently experimental and requires you to include a "--enable-cipher" option during the build configuration. "

Rick
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Encipher / Decipher

Post by anthony »

magick wrote:Sure we can set a property but the property will not be saved to most of the image formats since arbitrary metadata is not supported by most image formats. The properties are cipher:type, cipher:mode, and cipher:nonce.
Actually you probably would not want an image marked as being enciphered in any case! That is just asking for trouble!!!

I mean you may want to bury your encrypted image in amongst may other encrypted messages or even dummy encrypted images, so as to provide plusable deny ability with regards to 'rubber hose' attacks. EG if torture or legal presures are put to bear you can give the password for the dummy images and say the others are just random 'chaff'. That is useless if the chaff, and encrypted messages are distinguishable from each other.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Encipher / Decipher

Post by anthony »

rmabry wrote:I'm told that -encipher/-decipher are now standard, so when you get a chance, you can remove the caveat from this page:

"The "-encipher" and "-decipher" operators was added to IM v6.3.8-6. However it is currently experimental and requires you to include a "--enable-cipher" option during the build configuration. "
checking...
Yeap it does appear that "--enable-cipher" is no longer needed.

Do you know what version of IM that changed?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

Re: Encipher / Decipher

Post by rmabry »

anthony wrote: Yeap it does appear that "--enable-cipher" is no longer needed.

Do you know what version of IM that changed?
Nope, better ask the boss.

By the way, it's amusing what happens when you use -decipher on an unenciphered image. Not unexpected, of course, since there is no -enciphered flag.

Well, the result is perhaps somewhat kinda just a little unexpected (to me):

convert rose: rose.png
convert logo: -decipher rose.png logojunk.png

But this is ImageMagick 6.4.5 2008-10-24 Q16 on Windows, so I don't know what to expect with 6.8.0.

Time to upgrade again...

Rick
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Encipher / Decipher

Post by anthony »

Cristy reports that it will mow treat an image as a binary string including null characters.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply