96 comments today, 96 of them spam. 382978 comments overall, 382047 of them spam. See recent comments. RSS feed of all comments.
ImageMagick book
MythTV book
|
 |
|
 |
|
Tue, 10 Sep 2002
|
|
|
|
|
 |
|
 |
|
The code from this page can be found in my online CVS server here.
posted at: 07:00 | path: /des | permanent link to this entry
There are no comments on this post which have survived moderation. 69 posts have been culled and 102 blocked. Be the first to make a non-spam comment here, please!
|
|
|
|
|
 |
|
 |
|
Sun, 24 Mar 2002
|
|
|
|
|
 |
|
 |
|
/******************************************************************************
desex.c, an example of how to use the openssl DES implementation... Data
is input on stdin, and the enrypted information is output to stdout. Prompts
appear on stderr...
This is an example of the Electronic Code Book mode, which is predictable
for known input, and is not recommended.
Copyright (c) Michael Still 2001
Released under the terms of the GNU GPL
******************************************************************************/
#include
#include
int main(int argc, char *argv[]){
des_cblock key, input, output;
des_key_schedule sched;
int c, i;
fprintf(stderr, "Setting up the DES library...\n");
des_string_to_key("Mary had a little lamb, it's fleece as white as snow. Everywhere that Mary went, the lamb would surely go...", &key);
fprintf(stderr, "Schedualling the key...\n");
switch(des_set_key_checked(&key, sched)){
case -1:
fprintf(stderr, "Bad parity\n");
_exit(42);
break;
case -2:
fprintf(stderr, "Key is weak\n");
_exit(42);
break;
}
fprintf(stderr, "Start typing and hit ctrl-d to finish...\n");
i = 0;
while((c = fgetc(stdin)) != EOF){
input[i] = c;
i++;
if(i == 8){
des_ecb_encrypt(&input, &output, sched, DES_ENCRYPT);
fprintf(stdout, "%c%c%c%c%c%c%c%c", output[0], output[1], output[2],
output[3], output[4], output[5], output[6], output[7]);
i = 0;
}
}
}
posted at: 04:00 | path: /des | permanent link to this entry
There are no comments on this post which have survived moderation. 103 posts have been culled and 270 blocked. Be the first to make a non-spam comment here, please!
|
|
|
|
|
 |
|
 |
|
This page contains some DES example code I wrote in reaction to a crypto tutorial I attended a while ago. I finally got around to putting the code online...
The basic point of the code is it shows you how to use the DES calls within openssl. It also shows how the electronic code book for of DES is a bad choice for vaguely predictable data such as images.
A visual demonstration of this is these two images. The one on the right is an encrypted version of the one on the left... The vertical flip of the image is because of the way libtiff reads colour images, and to be honest isn't worth fixing for this example.
posted at: 04:00 | path: /des | permanent link to this entry
There are no comments on this post which have survived moderation. 33 posts have been culled and 32 blocked. Be the first to make a non-spam comment here, please!
|
|
|
|
|
 |
|
 |
|
/******************************************************************************
desex.c, an example of how to use the openssl DES implementation... Data
is input on stdin, and the enrypted information is output to stdout. Prompts
appear on stderr...
This is an example of the Electronic Code Book mode, which is predictable
for known input, and is not recommended.
Copyright (c) Michael Still 2001
Released under the terms of the GNU GPL
******************************************************************************/
#include
#include
int main(int argc, char *argv[]){
des_cblock key, input, output;
des_key_schedule sched;
int c, i;
fprintf(stderr, "Setting up the DES library...\n");
des_string_to_key("Mary had a little lamb, it's fleece as white as snow. Everywhere that Mary went, the lamb would surely go...", &key);
fprintf(stderr, "Schedualling the key...\n");
switch(des_set_key_checked(&key, sched)){
case -1:
fprintf(stderr, "Bad parity\n");
_exit(42);
break;
case -2:
fprintf(stderr, "Key is weak\n");
_exit(42);
break;
}
fprintf(stderr, "Start typing and hit ctrl-d to finish...\n");
i = 0;
while((c = fgetc(stdin)) != EOF){
input[i] = c;
i++;
if(i == 8){
des_ecb_encrypt(&input, &output, sched, DES_DECRYPT);
fprintf(stdout, "%c%c%c%c%c%c%c%c", output[0], output[1], output[2],
output[3], output[4], output[5], output[6], output[7]);
i = 0;
}
}
}
posted at: 04:00 | path: /des | permanent link to this entry
There are no comments on this post which have survived moderation. 52 posts have been culled and 79 blocked. Be the first to make a non-spam comment here, please!
|
|
|
|
|
|