Deutsch   English   Français   Italiano  
<vlf3nv$18h0m$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>
Newsgroups: sci.crypt
Subject: Re: xorpng
Date: Sun, 5 Jan 2025 15:14:07 -0800
Organization: A noiseless patient Spider
Lines: 559
Message-ID: <vlf3nv$18h0m$1@dont-email.me>
References: <vl243l$3jkpe$1@paganini.bofh.team> <vlc891$k8s5$2@dont-email.me>
 <vlc8om$k8s5$3@dont-email.me> <vlc9d8$irra$1@paganini.bofh.team>
 <vlcahc$ks00$1@dont-email.me> <vlcbki$j00g$1@paganini.bofh.team>
 <vlccrh$lb6a$1@dont-email.me> <vlchr0$j921$1@paganini.bofh.team>
 <vlcivh$md8n$2@dont-email.me> <vlcjan$oal1$2@paganini.bofh.team>
 <vld86b$tdna$1@dont-email.me> <vldj6q$pqvr$2@paganini.bofh.team>
 <vldk3q$psnq$1@paganini.bofh.team> <vlecdg$13phn$2@dont-email.me>
 <vlenpl$rjtu$1@paganini.bofh.team> <vles9r$16v92$2@dont-email.me>
 <vlesgd$rrnh$1@paganini.bofh.team> <vlf27d$17vsk$5@dont-email.me>
 <vlf2cd$17vsk$6@dont-email.me> <vlf3ae$s6de$1@paganini.bofh.team>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 06 Jan 2025 00:14:09 +0100 (CET)
Injection-Info: dont-email.me; posting-host="4f498e3dd7b2f539b15c36783567d08a";
	logging-data="1328150"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18ZO5BMEhv9uSRgxCp2VQF89PWwOzLxMbU="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:8lzGvSlS6mx57DgOReKbufuyghI=
In-Reply-To: <vlf3ae$s6de$1@paganini.bofh.team>
Content-Language: en-US
Bytes: 15890

On 1/5/2025 3:06 PM, Stefan Claas wrote:
> Chris M. Thomasson wrote:
>> On 1/5/2025 2:48 PM, Chris M. Thomasson wrote:
>>> On 1/5/2025 1:10 PM, Stefan Claas wrote:
>>>> Rich wrote:
>>>>> Stefan Claas <pollux@tilde.club> wrote:
>>>>>> Rich wrote:
>>>>>>> Stefan Claas <pollux@tilde.club> wrote:
>>>>>>>> Stefan Claas wrote:
>>>>>>>>> Rich wrote:
>>>>>>>>>> Stefan Claas <pollux@tilde.club> wrote:
>>>>>>>>>>> Rich wrote:
>>>>>>>>>>>
>>>>>>>>>>>> If instead you mean some kind of "special, PNG aware,
>>>>>>>>>>>> encryptor that only encrypted the bitmap data of a PNG",
>>>>>>>>>>>> but left the file as otherwise a proper PNG image
>>>>>>>>>>>> structure, then that is slightly tricky (and an algorithm
>>>>>>>>>>>> that is only useful for PNG's alone).
>>>>>>>>>>>
>>>>>>>>>>> Yes, this is what I mean.
>>>>>>>>>>
>>>>>>>>>> Which brings up the question of: why?
>>>>>>>>>>
>>>>>>>>>> Why go to the trouble to create an encryptor that is
>>>>>>>>>> specalized for just encrypting the internal bitmap data within
>>>>>>>>>> a PNG, leaving the rest as a PNG file, when a generic "byte
>>>>>>>>>> stream" encryptor will encrypt the entire PNG with no extra
>>>>>>>>>> effort?
>>>>>>>>>
>>>>>>>>> To make more content as allowed postable on social media, like
>>>>>>>>> X.
>>>>>>>>
>>>>>>>> I.e, first you put data with file2png in a .png and then encrypt
>>>>>>>> it to finally post it.  I can do this now with my xorpic program,
>>>>>>>> but I thought a solution with AES-GCM or XChaCha20+ploy1305 is
>>>>>>>> better.
>>>>>>>
>>>>>>> The "path" I outlined in my previous post, where you utilize the
>>>>>>> netpbm image format as your 'intermediary' would allow you to use
>>>>>>> any generic encryption routine you like, while also allowing you to
>>>>>>> convert the encrypted binary data to/from an image format of your
>>>>>>> choice (well, your choice within the set of other formats for which
>>>>>>> NetPBM has to/from converters available).
>>>>>>>
>>>>>>> This frees you from having to understand the internal structure of
>>>>>>> the various image formats.  You just work with the netpbm format (a
>>>>>>> raw binary bit/pixel block) for the encrypt/decrypt/padding
>>>>>>> operations, and delegate all the "image format" complexity to the
>>>>>>> netpbm library.
>>>>>>
>>>>>> Thank you!  My ppmenc tool works nicely, here are the test images:
>>>>>>
>>>>>> https://jmp.sh/HZM9ML9f
>>>>>>
>>>>>> The big problem I face when converting the encryypted image to .png
>>>>>> and back a diff shows a difference and the decryption fails.
>>>>>>
>>>>>> Maybe someone can figure out what to do, so that a converted .ppm can
>>>>>> be posted online , for viewers/readers and then can be converted back
>>>>>> to the original .ppm, which shows no difference.
>>>>>
>>>>> We can't read your mind over Usenet so can you show how you converted
>>>>> the encrypted image to a png and back.
>>>>>
>>>>
>>>> I used Gimp with compression set to 0 and the netbmp tools.
>>>>
>>>
>>> You should write your own program for it. The Gimp altered some bytes,
>>> right?
>>
>> Fwiw, the Cairo lib is fairly nice, well, to me at least... I use it a
>> lot for my 2d work. it allows you to gain access to the raw underlying
>> buffer. So, I can create PNG's with payloads that are intact.
> 
> Ok, here is the deal ... I have file2png (Go and Python3) which converts
> any (encrypted) payload to valid noise .png images and back. I have xorpng
> in Go which can create .png keys of random noise (crypto/rand) and xor
> then .png images with them, to create encrypted noise images. I have ppmenc
> in Go which encrypts ppm (P6) images to noise images. What I can not work
> out is to convert a ppm to .png and back to the *original* .ppm (P6) file,
> because .png with programs used or the Go library alter the conversion,
> back to .ppm (P6). I tried many things and always failed.
> 
> *Please* try to write a .ppm (P6) to .png converter (and back) in C(++)
> and see if you can get the *original* data back. The sci.crypt community
> and me of course would appreciate your help very much!
> 

I can, but I am busy with other things. I wrote a PPM reader a long time 
ago. decades. Just parse the PPM (P6) format. Here is a program I wrote 
in C that stores PPM's as a series of slices for a 3d volumetric object. 
The ct_canvas_save_ppm creates a PPM. The fun part is that the image 
stack is a volumetric object that can even be made into a hologram.


_______________________


/*
     A Simple 2d Plane For Owen, with proper aspect ratios!
     Color adder, single channel
     By: Chris M. Thomasson
*_____________________________________________________________*/


#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <complex.h>
#include <tgmath.h>
#include <stdbool.h>


#define CT_WIDTH 1920
#define CT_HEIGHT 1080
#define CT_N 10000000



struct ct_rgb
{
     unsigned char r;
     unsigned char g;
     unsigned char b;
};


struct ct_canvas
{
     unsigned long width;
     unsigned long height;
     //unsigned char* buf;
     struct ct_rgb* buf;
};

bool
ct_canvas_create(
     struct ct_canvas* const self,
     unsigned long width,
     unsigned long height
){
     size_t size = width * height * sizeof(*self->buf);

     self->buf = calloc(1, size);

     if (self->buf)
     {
         self->width = width;
         self->height = height;

         return true;
     }

     return false;
}

void
ct_canvas_destroy(
     struct ct_canvas const* const self
){
     free(self->buf);
}

bool
ct_canvas_save_ppm(
     struct ct_canvas const* const self,
     char const* fname
){
     FILE* fout = fopen(fname, "wb");
========== REMAINDER OF ARTICLE TRUNCATED ==========