Commit b4fc36ea authored by Milan Broz's avatar Milan Broz

Make all crypto backend destructors return void.

Nothing in the code actually checks the return values anyway.
parent fb6b4739
......@@ -43,7 +43,7 @@ int crypt_hash_size(const char *name);
int crypt_hash_init(struct crypt_hash **ctx, const char *name);
int crypt_hash_write(struct crypt_hash *ctx, const char *buffer, size_t length);
int crypt_hash_final(struct crypt_hash *ctx, char *buffer, size_t length);
int crypt_hash_destroy(struct crypt_hash *ctx);
void crypt_hash_destroy(struct crypt_hash *ctx);
/* HMAC */
int crypt_hmac_size(const char *name);
......@@ -51,7 +51,7 @@ int crypt_hmac_init(struct crypt_hmac **ctx, const char *name,
const void *buffer, size_t length);
int crypt_hmac_write(struct crypt_hmac *ctx, const char *buffer, size_t length);
int crypt_hmac_final(struct crypt_hmac *ctx, char *buffer, size_t length);
int crypt_hmac_destroy(struct crypt_hmac *ctx);
void crypt_hmac_destroy(struct crypt_hmac *ctx);
/* RNG (if fips parameter set, must provide FIPS compliance) */
enum { CRYPT_RND_NORMAL = 0, CRYPT_RND_KEY = 1, CRYPT_RND_SALT = 2 };
......@@ -101,7 +101,7 @@ uint32_t crypt_crc32(uint32_t seed, const unsigned char *buf, size_t len);
int crypt_cipher_blocksize(const char *name);
int crypt_cipher_init(struct crypt_cipher **ctx, const char *name,
const char *mode, const void *buffer, size_t length);
int crypt_cipher_destroy(struct crypt_cipher *ctx);
void crypt_cipher_destroy(struct crypt_cipher *ctx);
int crypt_cipher_encrypt(struct crypt_cipher *ctx,
const char *in, char *out, size_t length,
const char *iv, size_t iv_length);
......@@ -113,7 +113,7 @@ int crypt_cipher_decrypt(struct crypt_cipher *ctx,
int crypt_storage_init(struct crypt_storage **ctx, uint64_t sector_start,
const char *cipher, const char *cipher_mode,
char *key, size_t key_length);
int crypt_storage_destroy(struct crypt_storage *ctx);
void crypt_storage_destroy(struct crypt_storage *ctx);
int crypt_storage_decrypt(struct crypt_storage *ctx, uint64_t sector,
size_t count, char *buffer);
int crypt_storage_encrypt(struct crypt_storage *ctx, uint64_t sector,
......
......@@ -225,7 +225,7 @@ int crypt_cipher_decrypt(struct crypt_cipher *ctx,
iv, iv_length, ALG_OP_DECRYPT);
}
int crypt_cipher_destroy(struct crypt_cipher *ctx)
void crypt_cipher_destroy(struct crypt_cipher *ctx)
{
if (ctx->tfmfd >= 0)
close(ctx->tfmfd);
......@@ -233,7 +233,6 @@ int crypt_cipher_destroy(struct crypt_cipher *ctx)
close(ctx->opfd);
memset(ctx, 0, sizeof(*ctx));
free(ctx);
return 0;
}
#else /* ENABLE_AF_ALG */
......@@ -249,9 +248,9 @@ int crypt_cipher_init(struct crypt_cipher **ctx, const char *name,
return -ENOTSUP;
}
int crypt_cipher_destroy(struct crypt_cipher *ctx)
void crypt_cipher_destroy(struct crypt_cipher *ctx)
{
return 0;
return;
}
int crypt_cipher_encrypt(struct crypt_cipher *ctx,
......
......@@ -225,12 +225,11 @@ int crypt_hash_final(struct crypt_hash *ctx, char *buffer, size_t length)
return 0;
}
int crypt_hash_destroy(struct crypt_hash *ctx)
void crypt_hash_destroy(struct crypt_hash *ctx)
{
gcry_md_close(ctx->hd);
memset(ctx, 0, sizeof(*ctx));
free(ctx);
return 0;
}
/* HMAC */
......@@ -301,12 +300,11 @@ int crypt_hmac_final(struct crypt_hmac *ctx, char *buffer, size_t length)
return 0;
}
int crypt_hmac_destroy(struct crypt_hmac *ctx)
void crypt_hmac_destroy(struct crypt_hmac *ctx)
{
gcry_md_close(ctx->hd);
memset(ctx, 0, sizeof(*ctx));
free(ctx);
return 0;
}
/* RNG */
......
......@@ -217,7 +217,7 @@ int crypt_hash_final(struct crypt_hash *ctx, char *buffer, size_t length)
return 0;
}
int crypt_hash_destroy(struct crypt_hash *ctx)
void crypt_hash_destroy(struct crypt_hash *ctx)
{
if (ctx->tfmfd >= 0)
close(ctx->tfmfd);
......@@ -225,7 +225,6 @@ int crypt_hash_destroy(struct crypt_hash *ctx)
close(ctx->opfd);
memset(ctx, 0, sizeof(*ctx));
free(ctx);
return 0;
}
/* HMAC */
......@@ -292,7 +291,7 @@ int crypt_hmac_final(struct crypt_hmac *ctx, char *buffer, size_t length)
return 0;
}
int crypt_hmac_destroy(struct crypt_hmac *ctx)
void crypt_hmac_destroy(struct crypt_hmac *ctx)
{
if (ctx->tfmfd >= 0)
close(ctx->tfmfd);
......@@ -300,7 +299,6 @@ int crypt_hmac_destroy(struct crypt_hmac *ctx)
close(ctx->opfd);
memset(ctx, 0, sizeof(*ctx));
free(ctx);
return 0;
}
/* RNG - N/A */
......
......@@ -202,11 +202,10 @@ int crypt_hash_final(struct crypt_hash *ctx, char *buffer, size_t length)
return 0;
}
int crypt_hash_destroy(struct crypt_hash *ctx)
void crypt_hash_destroy(struct crypt_hash *ctx)
{
memset(ctx, 0, sizeof(*ctx));
free(ctx);
return 0;
}
/* HMAC */
......@@ -268,13 +267,12 @@ int crypt_hmac_final(struct crypt_hmac *ctx, char *buffer, size_t length)
return 0;
}
int crypt_hmac_destroy(struct crypt_hmac *ctx)
void crypt_hmac_destroy(struct crypt_hmac *ctx)
{
memset(ctx->key, 0, ctx->key_length);
free(ctx->key);
memset(ctx, 0, sizeof(*ctx));
free(ctx);
return 0;
}
/* RNG - N/A */
......
......@@ -180,12 +180,11 @@ int crypt_hash_final(struct crypt_hash *ctx, char *buffer, size_t length)
return 0;
}
int crypt_hash_destroy(struct crypt_hash *ctx)
void crypt_hash_destroy(struct crypt_hash *ctx)
{
PK11_DestroyContext(ctx->md, PR_TRUE);
memset(ctx, 0, sizeof(*ctx));
free(ctx);
return 0;
}
/* HMAC */
......@@ -282,7 +281,7 @@ int crypt_hmac_final(struct crypt_hmac *ctx, char *buffer, size_t length)
return 0;
}
int crypt_hmac_destroy(struct crypt_hmac *ctx)
void crypt_hmac_destroy(struct crypt_hmac *ctx)
{
if (ctx->key)
PK11_FreeSymKey(ctx->key);
......@@ -292,7 +291,6 @@ int crypt_hmac_destroy(struct crypt_hmac *ctx)
PK11_DestroyContext(ctx->md, PR_TRUE);
memset(ctx, 0, sizeof(*ctx));
free(ctx);
return 0;
}
/* RNG */
......
......@@ -213,12 +213,11 @@ int crypt_hash_final(struct crypt_hash *ctx, char *buffer, size_t length)
return 0;
}
int crypt_hash_destroy(struct crypt_hash *ctx)
void crypt_hash_destroy(struct crypt_hash *ctx)
{
EVP_MD_CTX_free(ctx->md);
memset(ctx, 0, sizeof(*ctx));
free(ctx);
return 0;
}
/* HMAC */
......@@ -288,12 +287,11 @@ int crypt_hmac_final(struct crypt_hmac *ctx, char *buffer, size_t length)
return 0;
}
int crypt_hmac_destroy(struct crypt_hmac *ctx)
void crypt_hmac_destroy(struct crypt_hmac *ctx)
{
HMAC_CTX_free(ctx->md);
memset(ctx, 0, sizeof(*ctx));
free(ctx);
return 0;
}
/* RNG */
......
......@@ -178,7 +178,7 @@ static int crypt_sector_iv_generate(struct crypt_sector_iv *ctx, uint64_t sector
return 0;
}
static int crypt_sector_iv_destroy(struct crypt_sector_iv *ctx)
static void crypt_sector_iv_destroy(struct crypt_sector_iv *ctx)
{
if (ctx->type == IV_ESSIV)
crypt_cipher_destroy(ctx->essiv_cipher);
......@@ -189,7 +189,6 @@ static int crypt_sector_iv_destroy(struct crypt_sector_iv *ctx)
}
memset(ctx, 0, sizeof(*ctx));
return 0;
}
/* Block encryption storage wrappers */
......@@ -285,10 +284,10 @@ int crypt_storage_encrypt(struct crypt_storage *ctx,
return r;
}
int crypt_storage_destroy(struct crypt_storage *ctx)
void crypt_storage_destroy(struct crypt_storage *ctx)
{
if (!ctx)
return 0;
return;
crypt_sector_iv_destroy(&ctx->cipher_iv);
......@@ -297,6 +296,4 @@ int crypt_storage_destroy(struct crypt_storage *ctx)
memset(ctx, 0, sizeof(*ctx));
free(ctx);
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment