[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: scrypt has three different implementations of crypto_scrypt(), ref, sse, and nosse. What do they mean?
- To: danielw@emaildoge.com, scrypt@tarsnap.com
- Subject: Re: scrypt has three different implementations of crypto_scrypt(), ref, sse, and nosse. What do they mean?
- From: Colin Percival <cperciva@tarsnap.com>
- Date: Sun, 23 Nov 2014 12:30:00 -0800
- In-reply-to: <f84347ca945af4c6d54de4895416abc5.squirrel@lelantoss7bcnwbv.onion>
- References: <f84347ca945af4c6d54de4895416abc5.squirrel@lelantoss7bcnwbv.onion>
On 11/23/14 07:31, danielw@emaildoge.com wrote:
> If you look into the scrypt codebase, you will find three files:
>
> crypto_scrypt-nosse.c
> crypto_scrypt-sse.c
> crypto_scrypt-ref.c
>
> All of them implement the same function crypto_scrypt() in different ways.
Yes. -ref is the reference code (easy to understand, follows the algorithm
in the paper precisely), while -nosse is optimized and -sse is optimized
and uses SSE cpu features.
> * All of them give the same output for the same input. (For the data I
> tried, at least.)
I'd certainly hope so!
> * The ref implementation makes the algorithm use approximately 128*N*r
> bytes of memory.
>
> * The sse and nosse implementations use much less memory. They seem to
> disregard the parameters for determining memory usage entirely.
They're using mmap instead of malloc. Whatever tool you're using for
measuring memory usage is broken.
> 3. Finally, a C question: I was able to put all three .c files into my
> project and compile without errors. I find this strange. I was expecting
> to get a "duplicate symbols" error from my linker because crypto_scrypt()
> is implemented in all three files. So my question is, why don't I get any
> errors?
I don't know what's wrong with your linker. But you don't want to do that
anyway. Pick either -nosse or -sse based on which CPU you'll be running on.
(Or use an #ifdef to include both and select at compile-time.)
--
Colin Percival
Security Officer Emeritus, FreeBSD | The power to serve
Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid