DIMA/trial3/ECCtrial.c
2020-07-24 15:09:47 +02:00

64 lines
1.4 KiB
C

#include <stdio.h>
#include <stdlib.h>
#include<mbedtls/config.h>
#include <mbedtls/aes.h>
#include <mbedtls/bignum.h>
#include <mbedtls/ctr_drbg.h>
#include <mbedtls/hmac_drbg.h>
#include <mbedtls/ecdh.h>
#include <mbedtls/ecdsa.h>
#include <mbedtls/ecp.h>
#include <mbedtls/rsa.h>
#include <mbedtls/sha256.h>
#include <mbedtls/md.h>
#include <mbedtls/pk.h>
#include <mbedtls/entropy.h>
//firt generate ECC/RA key.
//check for deterministic consistency
//seed RNGs with CDI
//let's see how it goes
//add entropy source?
//seed RNG
//create ctx
//init
//gen keypair
void main()
{
mbedtls_pk_context key;
mbedtls_entropy_context entropy;
mbedtls_ctr_drbg_context ctr_drbg;
mbedtls_pk_type_t pk_alg = MBEDTLS_PK_ECKEY;
mbedtls_pk_init(&key);
mbedtls_entropy_init( &entropy );
mbedtls_ctr_drbg_init(&ctr_drbg);
int ret = mbedtls_pk_setup(&key, mbedtls_pk_info_from_type(pk_alg));
ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func,
&entropy,
(const unsigned char *) "ecdsa",
strlen(pers)
);
ret = mbedtls_ecp_gen_key(MBEDTLS_ECP_DP_SECP256R,
mbedtls_pk_ec(key),
mbedtls_ctr_drbg_random,
&ctr_drbg
);
printf("done\n\n");
printf("I wonder what the key is\n\n");
printf("key : %s", key)
}