Blowfish usage?

lisp

    Next

  • 1. Scheme vs LISP
    Hi LISP coders ! Here is a simple question : what's the basic difference(s) between Scheme and LISP ? This non odd subject was surely treated somewhere, maybe in a Scheme introduction ? A link would be enough. Unless three lines are sufficient... Thanks for advance ! Fabrice
  • 2. newbie clos problem
    hello, i am trying to learn about clos. i made a defclass like this: (defclass person () ((name :accessor name :initarg name))) now i just want to make-instance an instance with a name. nothing i try seems to work. please help.

Blowfish usage?

Postby Petter Gustad » Mon, 13 Nov 2006 23:16:45 GMT

Is there a manual somehwere on the net which describes how to use the
blowfish package? 

Petter
-- 
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

Re: Blowfish usage?

Postby Petter Gustad » Tue, 14 Nov 2006 09:40:36 GMT

Petter Gustad < XXXX@XXXXX.COM > writes:


Seems pretty simple when you realize that the buffer is used in place:


(let ((key (blowfish:make-blowfish-key "key"))
      (buf (blowfish:make-blowfish-buffer :left 42 :right 24)))
   (blowfish:blowfish-encrypt buf key)
   (format t "~D ~D~%" (blowfish:buffer-left buf) (blowfish:buffer-right buf))
   (blowfish:blowfish-decrypt buf key)
   (format t "~D ~D~%" (blowfish:buffer-left buf) (blowfish:buffer-right buf)))

360593495 17929674
42 24


Petter        
-- 
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

Re: Blowfish usage?

Postby boating12345 » Tue, 14 Nov 2006 16:32:30 GMT

Hi Petter

You know I was watching this thread because i'd tried to use the b/f
library too! Must wonder back to it and work out how to encrypt /
decript as well!

Paul.
 http://www.**--****.com/ 






Similar Threads:

1.Clarion 55PE and Blowfish Encryption

Has anyone implimented blowfish encryption via template or source?
I have the C source code but thought I'd ask before I start to convert 
it to Clarion.

Any help would be appreciated.

By the way it doesn't have to be blowfish, any similar encryption would do.

Thanks

2.Blowfish Encryption

I store blowfish encryption in a text field. You convert the encrypted
version into hex. Gary James has a nice set of tools for Blowfish. I
modified one of his methods to make a static sized packet.

On 29 Jan 2008 15:27:08 -0500, "Lynn Howard" <pingme@newsgroup> wrote:

>I've selected another approach not requiring decryption.
---------------------------------------
 Paul Blais -  Hayes, Virginia

3.Blowfish's weakness?

Hello,

Consider I have MESSAGE, encrypted using blowfish encryption using
KEY.

However, during data transmission, one bit in the MESSAGE was flipped
incorrectly.

I found if I have the KEY, I can still decrypt the MESSAGE into
SOURCE, of course some original data are wrong but most data are still
correct.


Is this normal in Blowfish?

If I want not able to decrypt the MESSAGE if a single bit was changed
during transmission, what encryption I should use?

Thanks.

4.blowfish decryption

I am including a sample of the "C" coding that I am using to decode a
file.  The file was encrypted with a component name Cryptocx in the
windows platform.  I need to be able to decrypt the file and poarse
the resulting string into my program.  I am using Openssl version
0.9.6.  The windows component states that it is using a 448 Bit
keysize and that it automatically base64 encodes the resulting output.

for my information, does the 448 bit key size mean that the key is 14
chars long?

Does anybody see anything wrong with this code?  When i try to execute
it I get garbage to the screen as output.

#include <stdlib.h>
#include <string.h>
#include <openssl/blowfish.h>
        #include <openssl/bio.h>
        #include <openssl/evp.h>
#include <openssl/sha.h>
#include <openssl/hmac.h>
#include <openssl/buffer.h>

/*        BIO_METHOD *   BIO_f_base64(void); */


void decrypt(char *inbuf, char *outbuf, int blklen, char *key)
{
  int counter = 0;
  char iv[8];
  BF_KEY keyStruct;

  memset(iv, 0, 8);
  BF_set_key(&keyStruct, strlen(key), key);
  BF_cfb64_encrypt(inbuf, outbuf, blklen, &keyStruct,
                   iv, &counter, BF_DECRYPT);
}

void encrypt(char *inbuf, char *outbuf, int blklen, char *key)
{
  int counter = 0;
  char iv[8];
  BF_KEY keyStruct;

  memset(iv, 0, 8);
  BF_set_key(&keyStruct, strlen(key), key);
  BF_cfb64_encrypt(inbuf, outbuf, blklen, &keyStruct,
                   iv, &counter, BF_ENCRYPT);
}

void readfile( char * buf ) {
  FILE * inf ;
  inf = fopen( "locale.txt", "rb" ) ;
printf( "\n\r before read of file \n\r" ) ;

   fread(buf, sizeof(buf), 1024, inf) ;
printf( "\n\r after  read of file \n\r" ) ;

  fclose( inf ) ;
}

void decodebio( unsigned char *encbuf, unsigned char * decbuf, int
destbuf ) {


/*       Read Base64 encoded data from standard input and write the
       decoded data to standard output: */

BIO *b64, *bio ;
long i ;
char buffer[512] ;
memset(decbuf, 0, 1024) ;

b64 = BIO_new(BIO_f_base64() ) ;
bio = BIO_new(BIO_s_mem()) ;
bio = BIO_push(b64, bio) ;

i=BIO_write(bio, encbuf, strlen(encbuf)) ;
printf( "enc bio i = %d data is %s\n\r", i, encbuf) ;
//i = BIO_ctrl_pending(bio);
i = BIO_read(bio, decbuf, 1024) ;

printf( "the old buffer size is %d %d %s\n\r", i, strlen(decbuf),
decbuf) ;

BIO_set_mem_eof_return(bio,0) ;
BIO_free_all(bio) ;
//printf( "the resulting data is Length %d  size %d text %s \n\r" ,
strlen(decbuf), sizeof(decbuf), decbuf) ;
}
int main(int argc, char **argv)
{
  char *plain ;
  unsigned char filebuf[1024] ;
  unsigned char decodebuf[1024] ;
  unsigned char *res ;
  char *enc;
  char *dec;
  int len;

  char *key1 = "The Password\0"  ;
  char *key2 = "The Password\0" ;


  memset(filebuf, 0, 1024) ;
  memset(decodebuf, 0, 1024) ;
  readfile( filebuf );

//strcat( filebuf, "\0") ;
printf( "after reading file size %d %s\n\r", strlen(filebuf),
filebuf ) ;
printf( "before decoding file size %d %s\n\r", sizeof(decodebuf),
decodebuf ) ;
decodebio( filebuf, decodebuf, sizeof(decodebuf) ) ;

  len = strlen( decodebuf ) ;

  enc = malloc(len+1);
  enc[len] = '\0';
  dec = malloc(len+1);
  dec[len] = '\0';

  decrypt(decodebuf, dec, len, key2);

  printf("key1:      '%s'\n", key1);
  printf("ley2:      '%s'\n", key2);

  printf("decrypted: '%s'\n", dec);


}

This is the data from the file.  You mighe be able to make use of it.

+i??97?x8HU'?-u	Z,;K>?)U?
?I#*0T)?$hO
Gp0A
??A%E9X\M|j?x.???
?ck?>vw0x-#U&?P?
T_?>P?T€6:o

5.Blowfish, and a question about DEFCONSTANT

Many thanks to Christopher Rhodes for patches which
greatly improve the performance of the included code
on SBCL.  On SBCL v 0.8.6 on my laptop, these patches
improved the runtime almost a factor of two.

I have a question, however, either about the behaviour
of DEFCONSTANT, or that of SBCL.

When loading blowfish into SBCL, I get the following
error:
|   The constant BLOWFISH::+INITIAL-P-ARRAY+ is being redefined (from
|   #(608135816 2242054355 320440878 57701188 2752067618 698298832 137296536
|     3964562569 1160258022 953160567 3193202383 887688300 3232508343 3380367581
|     1065670069 3041331479 2450970073 2306472731)
|   to
|   #(608135816 2242054355 320440878 57701188 2752067618 698298832 137296536
|     3964562569 1160258022 953160567 3193202383 887688300 3232508343 3380367581
|     1065670069 3041331479 2450970073 2306472731))
|      [Condition of type DEFCONSTANT-UNEQL]
|
|   Restarts:
|     0: [CONTINUE] Go ahead and change the value.
|     1: [ABORT] Keep the old value.
|     2: [ABORT] Return to SLIME toplevel.
|     3: [ABORT] Reduce debugger level (leaving debugger, returning to toplevel).
|     4: [TOPLEVEL] Restart at toplevel READ/EVAL/PRINT loop.
|

The offending snippets of code are:

(eval-when (:compile-toplevel :load-toplevel :execute)

  (defun make-blowfish-array (entries)
    "Constructs a specialized BLOWFISH array."
    (dolist (entry entries)
      (assert (typep entry 'unsigned-byte-32)
              nil
              "The supplied number ~A does not fit in 32 bits." entry))
    (make-array (length entries)
                :element-type 'unsigned-byte-32
                :initial-contents entries))
) ; eval-when

(defconstant +initial-p-array+
  (make-blowfish-array
   '(#x243f6a88 #x85a308d3 #x13198a2e #x03707344 #xa4093822 #x299f31d0
     #x082efa98 #xec4e6c89 #x452821e6 #x38d01377 #xbe5466cf #x34e90c6c
     #xc0ac29b7 #xc97c50dd #x3f84d5b5 #xb5470917 #x9216d5d9 #x8979fb1b)))


Now, my understanding is that the eval-when makes the definition
of MAKE-BLOWFISH-ARRAY known at compile time, so it can be _called_
at compile time, and splice in the actual results of the array into
the defconstant.

Neither Lispworks nor CMUCL raises this error.

So who's right, and why?






-- 
It would be difficult to construe        Larry Wall, in  article
this as a feature.			 < XXXX@XXXXX.COM >

6. blowfish with files

7. encrypt data file - was blowfish with files

8. LOGOUT-COMMIT usage



Return to lisp

 

Who is online

Users browsing this forum: No registered users and 81 guest