Re: Extremely poor performance crunching random numbers under PIV-FC5

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



BankHacker wrote:

Please, could you tell me how to use the structure correctly? Thanks.

Any hint to continue will be appreciate.

Looks like initstate_r() is a big secret and the whole deal is poorly documented.

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=6273

Here is my guess at the meaning of it all that appears to work:

    #include <stdio.h>
    #include <stdlib.h>
    #include <fcntl.h>

    int nRandom;
    struct random_data randomdataState;
    char szBufferState[1024];


    int main(int argc, char ** argv) {
        int n;

        int fd=open("/dev/urandom", O_RDONLY);
        if(fd<1) { perror("unable to open /dev/urandom"); return 1; }

        read(fd, szBufferState, sizeof(szBufferState));
        close(fd);

initstate_r(*((int *)szBufferState), (szBufferState+sizeof(int)), sizeof(szBufferState)-sizeof(int), &randomdataState);

        for(n=0;n<2048;n++) {
                random_r(&randomdataState, &nRandom);
                printf("%d\n", nRandom);
        }

        return (0);
    }

-Andy

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux