"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/crypto_backend/crypto_nettle.c" between
cryptsetup-2.3.6.tar.xz and cryptsetup-2.4.0.tar.xz

About: cryptsetup is a utility used to conveniently setup disk encryption based on the dm-crypt kernel module. These include plain dm-crypt volumes, LUKS volumes, loop-AES and TrueCrypt compatible format.

crypto_nettle.c  (cryptsetup-2.3.6.tar.xz):crypto_nettle.c  (cryptsetup-2.4.0.tar.xz)
skipping to change at line 303 skipping to change at line 303
const void *key, size_t key_length) const void *key, size_t key_length)
{ {
struct crypt_hmac *h; struct crypt_hmac *h;
h = malloc(sizeof(*h)); h = malloc(sizeof(*h));
if (!h) if (!h)
return -ENOMEM; return -ENOMEM;
memset(ctx, 0, sizeof(*ctx)); memset(ctx, 0, sizeof(*ctx));
h->hash = _get_alg(name); h->hash = _get_alg(name);
if (!h->hash) if (!h->hash) {
goto bad; free(h);
return -EINVAL;
}
h->key = malloc(key_length); h->key = malloc(key_length);
if (!h->key) if (!h->key) {
goto bad; free(h);
return -ENOMEM;
}
memcpy(h->key, key, key_length); memcpy(h->key, key, key_length);
h->key_length = key_length; h->key_length = key_length;
h->hash->init(&h->nettle_ctx); h->hash->init(&h->nettle_ctx);
h->hash->hmac_set_key(&h->nettle_ctx, h->key_length, h->key); h->hash->hmac_set_key(&h->nettle_ctx, h->key_length, h->key);
*ctx = h; *ctx = h;
return 0; return 0;
bad:
free(h);
return -EINVAL;
} }
static void crypt_hmac_restart(struct crypt_hmac *ctx) static void crypt_hmac_restart(struct crypt_hmac *ctx)
{ {
ctx->hash->hmac_set_key(&ctx->nettle_ctx, ctx->key_length, ctx->key); ctx->hash->hmac_set_key(&ctx->nettle_ctx, ctx->key_length, ctx->key);
} }
int crypt_hmac_write(struct crypt_hmac *ctx, const char *buffer, size_t length) int crypt_hmac_write(struct crypt_hmac *ctx, const char *buffer, size_t length)
{ {
ctx->hash->hmac_update(&ctx->nettle_ctx, length, (const uint8_t *)buffer) ; ctx->hash->hmac_update(&ctx->nettle_ctx, length, (const uint8_t *)buffer) ;
skipping to change at line 353 skipping to change at line 354
void crypt_hmac_destroy(struct crypt_hmac *ctx) void crypt_hmac_destroy(struct crypt_hmac *ctx)
{ {
memset(ctx->key, 0, ctx->key_length); memset(ctx->key, 0, ctx->key_length);
free(ctx->key); free(ctx->key);
memset(ctx, 0, sizeof(*ctx)); memset(ctx, 0, sizeof(*ctx));
free(ctx); free(ctx);
} }
/* RNG - N/A */ /* RNG - N/A */
int crypt_backend_rng(char *buffer, size_t length, int quality, int fips) int crypt_backend_rng(char *buffer __attribute__((unused)),
size_t length __attribute__((unused)),
int quality __attribute__((unused)),
int fips __attribute__((unused)))
{ {
return -EINVAL; return -EINVAL;
} }
/* PBKDF */ /* PBKDF */
int crypt_pbkdf(const char *kdf, const char *hash, int crypt_pbkdf(const char *kdf, const char *hash,
const char *password, size_t password_length, const char *password, size_t password_length,
const char *salt, size_t salt_length, const char *salt, size_t salt_length,
char *key, size_t key_length, char *key, size_t key_length,
uint32_t iterations, uint32_t memory, uint32_t parallel) uint32_t iterations, uint32_t memory, uint32_t parallel)
skipping to change at line 431 skipping to change at line 435
return crypt_cipher_encrypt_kernel(&ctx->ck, in, out, length, iv, iv_leng th); return crypt_cipher_encrypt_kernel(&ctx->ck, in, out, length, iv, iv_leng th);
} }
int crypt_cipher_decrypt(struct crypt_cipher *ctx, int crypt_cipher_decrypt(struct crypt_cipher *ctx,
const char *in, char *out, size_t length, const char *in, char *out, size_t length,
const char *iv, size_t iv_length) const char *iv, size_t iv_length)
{ {
return crypt_cipher_decrypt_kernel(&ctx->ck, in, out, length, iv, iv_leng th); return crypt_cipher_decrypt_kernel(&ctx->ck, in, out, length, iv, iv_leng th);
} }
bool crypt_cipher_kernel_only(struct crypt_cipher *ctx) bool crypt_cipher_kernel_only(struct crypt_cipher *ctx __attribute__((unused)))
{ {
return true; return true;
} }
int crypt_bitlk_decrypt_key(const void *key, size_t key_length, int crypt_bitlk_decrypt_key(const void *key, size_t key_length,
const char *in, char *out, size_t length, const char *in, char *out, size_t length,
const char *iv, size_t iv_length, const char *iv, size_t iv_length,
const char *tag, size_t tag_length) const char *tag, size_t tag_length)
{ {
return crypt_bitlk_decrypt_key_kernel(key, key_length, in, out, length, return crypt_bitlk_decrypt_key_kernel(key, key_length, in, out, length,
 End of changes. 5 change blocks. 
9 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)