[[fi.c]]

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

fi.c [2015/02/12 15:25] (current)
madan created
Line 1: Line 1:
 +==== FIPS 140.2 using Openssl 1.0.2 initialization for a C/C++ program ====
 +<​code>​
 +int main(int argc, char **argv) {
 +        unsigned char buf[BUFLEN+1] = {0};
 +        int i;
 +        int mode = 0;
 +        int numSamples = 10000000;
 +        int numZeros = 0;
 +
 +        RAND_init_fips();​
 +        // printf("​%d\n",​ FIPS_mode());​
 +        // printf("​Set:​ %d\n", FIPS_mode_set(1));​
 +        mode = FIPS_mode_set(1);​
 +        printf("​Mode:​ %d\n", mode);
 +        for (i=0; i<​numSamples;​ i++) {
 +                buf[0] = buf[BUFLEN] = 0;
 +                RAND_bytes(buf,​ BUFLEN);
 +                if (containsZero(buf,​ BUFLEN)) {
 +                        // printf("​%d:​ ", i);
 +                        // dumpBuffer(buf,​ BUFLEN);
 +                        numZeros++;
 +                }
 +        }
 +        printf("​%d %d\n", numSamples, numZeros);
 +        return 0;
 +}
 +</​code>​
 +
 +----
 +  * [[cplusplus|Back to c++]]
  
fi.c.txt ยท Last modified: 2015/02/12 15:25 by madan
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0