*
*/
+#define OPENSSL_FIPSAPI
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define OPENSSL_FIPSAPI
-#include <openssl/fips.h>
#include "fips_utl.h"
+#include <openssl/fips.h>
typedef struct
{
unsigned char R[16];
} AES_PRNG_MCT;
-static unsigned char aes_128_mct_key[16] =
+__fips_constseg
+static const unsigned char aes_128_mct_key[16] =
{0x9f,0x5b,0x51,0x20,0x0b,0xf3,0x34,0xb5,
0xd8,0x2b,0xe8,0xc3,0x72,0x55,0xc8,0x48};
-static AES_PRNG_MCT aes_128_mct_tv = {
+__fips_constseg
+static const AES_PRNG_MCT aes_128_mct_tv = {
/* DT */
{0x63,0x76,0xbb,0xe5,0x29,0x02,0xba,0x3b,
0x67,0xc9,0x25,0xfa,0x70,0x1f,0x11,0xac},
0xe4,0x57,0x90,0xd5,0xc3,0xfc,0x9b,0x73}
};
-static unsigned char aes_192_mct_key[24] =
+__fips_constseg
+static const unsigned char aes_192_mct_key[24] =
{0xb7,0x6c,0x34,0xd1,0x09,0x67,0xab,0x73,
0x4d,0x5a,0xd5,0x34,0x98,0x16,0x0b,0x91,
0xbc,0x35,0x51,0x16,0x6b,0xae,0x93,0x8a};
-static AES_PRNG_MCT aes_192_mct_tv = {
+__fips_constseg
+static const AES_PRNG_MCT aes_192_mct_tv = {
/* DT */
{0x84,0xce,0x22,0x7d,0x91,0x5a,0xa3,0xc9,
0x84,0x3c,0x0a,0xb3,0xa9,0x63,0x15,0x52},
0xdd,0x86,0x20,0x32,0x8a,0x29,0x6f,0x47}
};
-static unsigned char aes_256_mct_key[32] =
+__fips_constseg
+static const unsigned char aes_256_mct_key[32] =
{0x9b,0x05,0xc8,0x68,0xff,0x47,0xf8,0x3a,
0xa6,0x3a,0xa8,0xcb,0x4e,0x71,0xb2,0xe0,
0xb8,0x7e,0xf1,0x37,0xb6,0xb4,0xf6,0x6d,
0x86,0x32,0xfc,0x1f,0x5e,0x1d,0x1e,0x50};
-static AES_PRNG_MCT aes_256_mct_tv = {
+__fips_constseg
+static const AES_PRNG_MCT aes_256_mct_tv = {
/* DT */
{0x31,0x6e,0x35,0x9a,0xb1,0x44,0xf0,0xee,
0x62,0x6d,0x04,0x46,0xe0,0xa3,0x92,0x4c},
}
-static void run_test(unsigned char *key, int keylen, AES_PRNG_MCT *tv)
+static void run_test(const unsigned char *key, int keylen,
+ const AES_PRNG_MCT *tv)
{
unsigned char buf[16], dt[16];
int i, j;
- FIPS_rand_reset();
- FIPS_rand_test_mode();
- FIPS_rand_set_key(key, keylen);
- FIPS_rand_seed(tv->V, 16);
+ FIPS_x931_reset();
+ FIPS_x931_test_mode();
+ FIPS_x931_set_key(key, keylen);
+ FIPS_x931_seed(tv->V, 16);
memcpy(dt, tv->DT, 16);
for (i = 0; i < 10000; i++)
{
- FIPS_rand_set_dt(dt);
- FIPS_rand_bytes(buf, 16);
+ FIPS_x931_set_dt(dt);
+ FIPS_x931_bytes(buf, 16);
/* Increment DT */
for (j = 15; j >= 0; j--)
{
int main()
{
- fips_set_error_print();
+ fips_algtest_init();
run_test(aes_128_mct_key, 16, &aes_128_mct_tv);
printf("FIPS PRNG test 1 done\n");
run_test(aes_192_mct_key, 24, &aes_192_mct_tv);