blob: 888118aaa86973892895135eb95770da47608812 [file] [log] [blame]
#include <stdio.h>
#include <string.h>
#include <openssl/ec.h>
#include <openssl/ecdsa.h>
#include <openssl/obj_mac.h>
#include <openssl/jpake.h>
#include <openssl/ecdh.h>
#include <polarssl/ctr_drbg.h>
int entropy(void *closure, unsigned char *outentropy, size_t outsize)
{
unsigned char *entropy;
int rval, idx;
printf("hey, somebody wants entropy: %p, %d\n", outentropy, outsize);
do
{
#ifdef gPlatformGetRandomNumber
rval = (int)gPlatformGetRandomNumber();
#else
rval = rand();
#endif
entropy = (unsigned char *)&rval;
printf("got some sweet entropy: %08x\n", rval);
for (idx = 0; (idx < sizeof(int)) && (outsize > 0); idx++, outsize--)
*outentropy++ = *entropy++;
}
while (outsize > 0);
return 0;
}
ctr_drbg_context *gCTRDRBG_ctx = NULL;
int main(int argc, char ** argv)
{
int retval = 0;
int i;
#ifdef gPlatformSetInputEntropy
gPlatformSetInputEntropy(seed);
#else
time_t tim;
tim = time(NULL);
srand(tim);
#endif
// Force linker references to the necessary top-level functions.
static void *functions[] =
{
(void *)ECDSA_do_sign,
(void *)ECDSA_do_verify,
(void *)JPAKE_STEP1_init,
(void *)JPAKE_STEP1_generate,
(void *)JPAKE_STEP1_process,
(void *)JPAKE_STEP1_release,
(void *)JPAKE_STEP2_init,
(void *)JPAKE_STEP2_generate,
(void *)JPAKE_STEP2_process,
(void *)JPAKE_STEP2_release,
(void *)ECDH_compute_key,
NULL
};
for (i = 0; functions[i] != NULL; i++)
printf("%p\n", functions[i]);
ctr_drbg_context ctx;
#ifdef DEBUG
ctr_drbg_self_test(1);
#endif
retval = ctr_drbg_init(&ctx, entropy, NULL, NULL, 0);
gCTRDRBG_ctx = &ctx;
printf("returning: %d\n", retval);
return retval;
}