List Info

Thread: "ocaml_beginners"::[] problem about ciphering algorithm comparaisons




"ocaml_beginners"::[] problem about ciphering algorithm comparaisons
country flaguser name
United States
2007-05-16 07:03:17

hello,

I'm in a preparation school. And I did a work about ciphering algorithm
comparaisons.
I found Blowfish is slower than AES... maybe something wrong.

Why caml use integer of 31 bits instead of 32 bits integer?
Perhaps it's the raison of my strange mesures.

I stored my code in :

http://www.chez.com/colinjl/pagegael/cryptocaml.html

ps : I used 7zip for compressing data.

+

__._,_.___
.

__,_._,___
Re: "ocaml_beginners"::[] problem about ciphering algorithm comparaisons
country flaguser name
Germany
2007-05-16 09:29:13

On Wednesday 16 May 2007 14:03, Gael Colin wrote:
> Why caml use integer of 31 bits instead of 32 bits integer?
> Perhaps it's the raison of my strange mesures.

>From the tutorial: "OCaml uses one of the bits in an int internally in order
to be able to automatically manage the memory use (garbage collection).
This is why the basic int is 31 bits, not 32 bits (63 bits if you're using
a 64 bit platform). In practice this isn't an issue except in a few
specialised cases. For example if you're counting things in a loop, then
OCaml limits you to counting up to 1 billion instead of 2 billion. This
isn't going to be a problem because if you're counting things close to this
limit in any language, then you ought to be using bignums (the Nat and
Big_int modules in OCaml). However if you need to do things such as
processing 32 bit types (eg. you're writing crypto code or a network
stack), OCaml provides a nativeint type which matches the native integer
type for your platform."

Bye...Frank

__._,_.___
.

__,_._,___
Re: "ocaml_beginners"::[] problem about ciphering algorithm comparaisons
country flaguser name
United Kingdom
2007-05-16 10:09:13

On Wed, May 16, 2007 at 02:03:17PM +0200, Gael Colin wrote:
> hello,
>
> I'm in a preparation school. And I did a work about ciphering algorithm
> comparaisons.
> I found Blowfish is slower than AES... maybe something wrong.
>
> Why caml use integer of 31 bits instead of 32 bits integer?

The bottom bit is used by the garbage collector / runtime to
distinguish between integers (1) and pointers (0). So for an integer
you only get WORDSIZE-1 bits to use. This isn't usually a problem
except in specialised applications like crypto, extracting fields from
binary files and a few others.

> Perhaps it's the raison of my strange mesures.
>
>; I stored my code in :
>
> http://www.chez.com/colinjl/pagegael/cryptocaml.html

I had an extremely brief look at this code and it does look like
you're using 'int' as if it's 32 bits. That isn't going to work
either on a 32 bit machine (int is 31 bits) nor on a 64 bit machine
(int is 63 bits).

You might want to try using the 'int32' or 'int64' types. However
these won't be very fast, and the real solution is probably to use
either strings (as bitsets) or Bigarrays.

Rich.

--
Richard Jones
Red Hat

__._,_.___
.

__,_._,___
Re: "ocaml_beginners"::[] problem about ciphering algorithm comparaisons
country flaguser name
United States
2007-05-16 10:59:34

On Wed, 16 May 2007, Gael Colin wrote:

> hello,
>
> I'm in a preparation school. And I did a work about ciphering algorithm
> comparaisons.
> I found Blowfish is slower than AES... maybe something wrong.

No. That should be right.
Depending on the mode being used (and of course the way you've coded them
up) AES should be faster than blowfish. Especially if you're testing by
encrypting a lot of short messages with a lot of different keys.
Blowfish's key setup takes a very long time.

> Why caml use integer of 31 bits instead of 32 bits integer?
> Perhaps it's the raison of my strange mesures.

They use it for garbage collection, so that integers can be easily told
apart from pointers. And, yes, if you are doing a lot of work with the
Int32 type, you will lose some speed due to the boxed nature of that type.

William D. Neumann

---

"There's just so many extra children, we could just feed the
children to these tigers. We don't need them, we're not doing
anything with them.

Tigers are noble and sleek; children are loud and messy."

-- Neko Case

Life is unfair. Kill yourself or get over it.
-- Black Box Recorder

__._,_.___
.

__,_._,___
"ocaml_beginners"::[] Re: problem about ciphering algorithm comparaisons
country flaguser name
United States
2007-05-16 13:00:41

Thanks a lot Frank Thieme, Richard Jones and William D. Neumann.
Your informations will be a plus for my presantation.

Gael

__._,_.___
.

__,_._,___
[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )