eet: initialize emile on demand.

This commit is contained in:
Cedric BAIL 2015-03-17 08:50:05 +01:00 committed by Cedric BAIL
parent 2913e8c64e
commit 97c703cdaf
1 changed files with 16 additions and 0 deletions

View File

@ -90,6 +90,8 @@ eet_identity_open(const char *certificate_file,
gnutls_datum_t load_file = { NULL, 0 };
char pass[1024];
if (!emile_cipher_init()) return NULL;
/* Init */
if (!(key = malloc(sizeof(Eet_Key))))
goto on_error;
@ -189,6 +191,8 @@ on_error:
EVP_PKEY *pkey = NULL;
X509 *cert = NULL;
if (!emile_cipher_init()) return NULL;
/* Load the X509 certificate in memory. */
fp = fopen(certificate_file, "r");
if (!fp)
@ -244,6 +248,8 @@ on_error:
EAPI void
eet_identity_close(Eet_Key *key)
{
if (!emile_cipher_init()) return ;
#ifdef HAVE_SIGNATURE
if (!key || (key->references > 0))
return;
@ -286,6 +292,8 @@ eet_identity_print(Eet_Key *key,
if (!key)
return;
if (!emile_cipher_init()) return ;
if (key->private_key)
{
if (gnutls_x509_privkey_export_rsa_raw(key->private_key,
@ -354,6 +362,8 @@ on_error:
if (!key)
return;
if (!emile_cipher_init()) return ;
rsa = EVP_PKEY_get1_RSA(key->private_key);
if (rsa)
{
@ -473,6 +483,8 @@ eet_identity_sign(FILE *fp,
if (!fp || !key || !key->certificate || !key->private_key)
return EET_ERROR_BAD_OBJECT;
if (!emile_cipher_init()) return EET_ERROR_NOT_IMPLEMENTED;
/* Get the file size. */
fd = fileno(fp);
if (fd < 0)
@ -639,6 +651,8 @@ eet_identity_check(const void *data_base,
if (signature_length < sizeof(int) * 3)
return NULL;
if (!emile_cipher_init()) return NULL;
/* Get the header */
memcpy(&magic, header, sizeof(int));
memcpy(&sign_len, header+1, sizeof(int));
@ -801,6 +815,8 @@ eet_identity_certificate_print(const unsigned char *certificate,
return;
}
if (!emile_cipher_init()) return ;
# ifdef HAVE_GNUTLS
gnutls_datum_t datum;
gnutls_x509_crt_t cert;