On Thu, 29 Jul 2004, Andy Polyakov wrote:
> > I haven't checked RNG yet.
>
> My suggestion is:
> ...
>
> static inline unsigned int
> padlock_xstore(size_t count,unsigned int edx_in,
> unsigned char *output_addr)
> {
> unsigned int eax_out=0; /* compensate for gcc 2.95 bug */
>
> asm volatile (".byte 0xf3,0x0f,0xa7,0xc0" /* rep xstore */
> : "+a"(eax_out), "+c"(count), "+D"(output_addr)
> : "d" (edx_in)
> );
>
> return eax_out;
> }
>
> ...
>
> static int
> padlock_rand_bytes(unsigned char *output, int count)
> {
> if (count >= 4) {
> padlock_xstore(count&~3, 1, output);
> output += count&~3;
> count %= 4;
> }
> if (count > 0) {
> /* xstore always stores at least 4 bytes - we must avoid
> overwriting the innocent data! */
> volatile unsigned int buf[2];
> padlock_xstore(count, 3, (void *)buf);
> memcpy(output, (void *)buf, count);
> buf[0] = buf[1] = 0;
> }
> return 1;
> }
>
> Note that 3rd argument to padlock_xstore is no longer void ** and second
> argument to more diverse, 1 and 3.
I read somewhere that with edx=3 the RNG gives the "best" random
numbers.
> As for void **. If you really want to
> get %edi value at output, I'd copy it to %eax. But what it would be
> required for?
E.g. if less than requested bytes was served to get the pointer to the
end of the buffer. I don't know if it could ever happen...
Michal Ludvig
--
* A mouse is a device used to point at the xterm you want to type in.
* Personal homepage - http://www.logix.cz/michal
______________________________________________________________________
OpenSSL Project http://www.openssl.org
Development Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]