Exemplo n.º 1
0
EP_CRYPTO_KEY *
ep_crypto_key_create(int keytype, int keylen, int keyexp, const char *curve)
{
	EVP_PKEY *key;
	EP_STAT estat;

	key = EVP_PKEY_new();
	if (key == NULL)
		return _ep_crypto_error("Cannot create new keypair");

	switch (keytype)
	{
#if _EP_CRYPTO_INCLUDE_RSA
	  case EP_CRYPTO_KEYTYPE_RSA:
		estat = generate_rsa_key(key, keylen, keyexp);
		break;
#endif

#if _EP_CRYPTO_INCLUDE_DSA
	  case EP_CRYPTO_KEYTYPE_DSA:
		estat = generate_dsa_key(key, keylen);
		break;
#endif

#if _EP_CRYPTO_INCLUDE_DH
	  case EP_CRYPTO_KEYTYPE_DH:
		estat = generate_dh_key(key, ...);
		break;
#endif

#if _EP_CRYPTO_INCLUDE_EC
	  case EP_CRYPTO_KEYTYPE_EC:
		estat = generate_ec_key(key, curve);
		break;
#endif

	  default:
		return _ep_crypto_error("unrecognized key type %d", keytype);
	}
	if (EP_STAT_ISOK(estat))
		return key;
	EVP_PKEY_free(key);
	return NULL;
}
Exemplo n.º 2
0
int main() {
  keys k;
  generate_rsa_key(&k);

  return 0;
}