cryptsetup  2.4.3
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.
  Fossies Dox: cryptsetup-2.4.3.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

crypto_gcrypt.c File Reference
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <assert.h>
#include <gcrypt.h>
#include "crypto_backend_internal.h"
Include dependency graph for crypto_gcrypt.c:

Go to the source code of this file.

Data Structures

struct  crypt_hash
 
struct  crypt_hmac
 
struct  crypt_cipher
 
struct  hash_alg
 

Functions

static void crypt_hash_test_whirlpool_bug (void)
 
int crypt_backend_init (bool fips)
 
void crypt_backend_destroy (void)
 
const char * crypt_backend_version (void)
 
uint32_t crypt_backend_flags (void)
 
static const char * crypt_hash_compat_name (const char *name, unsigned int *flags)
 
int crypt_hash_size (const char *name)
 
int crypt_hash_init (struct crypt_hash **ctx, const char *name)
 
static void crypt_hash_restart (struct crypt_hash *ctx)
 
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)
 
void crypt_hash_destroy (struct crypt_hash *ctx)
 
int crypt_hmac_size (const char *name)
 
int crypt_hmac_init (struct crypt_hmac **ctx, const char *name, const void *key, size_t key_length)
 
static void crypt_hmac_restart (struct crypt_hmac *ctx)
 
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)
 
void crypt_hmac_destroy (struct crypt_hmac *ctx)
 
int crypt_backend_rng (char *buffer, size_t length, int quality, int fips)
 
static int pbkdf2 (const char *hash, const char *password, size_t password_length, const char *salt, size_t salt_length, char *key, size_t key_length, uint32_t iterations)
 
int crypt_pbkdf (const char *kdf, const char *hash, const char *password, size_t password_length, const char *salt, size_t salt_length, char *key, size_t key_length, uint32_t iterations, uint32_t memory, uint32_t parallel)
 
static int _cipher_init (gcry_cipher_hd_t *hd, const char *name, const char *mode, const void *buffer, size_t length)
 
int crypt_cipher_init (struct crypt_cipher **ctx, const char *name, const char *mode, const void *key, size_t key_length)
 
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)
 
int crypt_cipher_decrypt (struct crypt_cipher *ctx, const char *in, char *out, size_t length, const char *iv, size_t iv_length)
 
bool crypt_cipher_kernel_only (struct crypt_cipher *ctx)
 
int crypt_bitlk_decrypt_key (const void *key, size_t key_length, const char *in, char *out, size_t length, const char *iv, size_t iv_length, const char *tag, size_t tag_length)
 

Variables

static int crypto_backend_initialised = 0
 
static int crypto_backend_secmem = 1
 
static int crypto_backend_whirlpool_bug = -1
 
static char version [64]
 

Function Documentation

◆ _cipher_init()

static int _cipher_init ( gcry_cipher_hd_t *  hd,
const char *  name,
const char *  mode,
const void *  buffer,
size_t  length 
)
static

Definition at line 410 of file crypto_gcrypt.c.

References crypt_hmac::hd, and name.

Referenced by crypt_cipher_init().

◆ crypt_backend_destroy()

void crypt_backend_destroy ( void  )

Definition at line 140 of file crypto_gcrypt.c.

◆ crypt_backend_flags()

uint32_t crypt_backend_flags ( void  )

Definition at line 153 of file crypto_gcrypt.c.

◆ crypt_backend_init()

int crypt_backend_init ( bool  fips)

Definition at line 97 of file crypto_gcrypt.c.

◆ crypt_backend_rng()

int crypt_backend_rng ( char *  buffer,
size_t  length,
int  quality,
int  fips 
)

Definition at line 350 of file crypto_gcrypt.c.

◆ crypt_backend_version()

const char * crypt_backend_version ( void  )

Definition at line 148 of file crypto_gcrypt.c.

◆ crypt_bitlk_decrypt_key()

int crypt_bitlk_decrypt_key ( const void *  key,
size_t  key_length,
const char *  in,
char *  out,
size_t  length,
const char *  iv,
size_t  iv_length,
const char *  tag,
size_t  tag_length 
)

Definition at line 514 of file crypto_gcrypt.c.

◆ crypt_cipher_decrypt()

int crypt_cipher_decrypt ( struct crypt_cipher ctx,
const char *  in,
char *  out,
size_t  length,
const char *  iv,
size_t  iv_length 
)

Definition at line 493 of file crypto_gcrypt.c.

◆ crypt_cipher_destroy()

void crypt_cipher_destroy ( struct crypt_cipher ctx)

Definition at line 468 of file crypto_gcrypt.c.

◆ crypt_cipher_encrypt()

int crypt_cipher_encrypt ( struct crypt_cipher ctx,
const char *  in,
char *  out,
size_t  length,
const char *  iv,
size_t  iv_length 
)

Definition at line 477 of file crypto_gcrypt.c.

◆ crypt_cipher_init()

int crypt_cipher_init ( struct crypt_cipher **  ctx,
const char *  name,
const char *  mode,
const void *  key,
size_t  key_length 
)

Definition at line 441 of file crypto_gcrypt.c.

◆ crypt_cipher_kernel_only()

bool crypt_cipher_kernel_only ( struct crypt_cipher ctx)

Definition at line 509 of file crypto_gcrypt.c.

◆ crypt_hash_compat_name()

static const char * crypt_hash_compat_name ( const char *  name,
unsigned int *  flags 
)
static

Definition at line 158 of file crypto_gcrypt.c.

References hash_alg::gcrypt_name, hash_algs, name, and NULL.

Referenced by crypt_hash_init(), crypt_hash_size(), crypt_hmac_init(), and pbkdf2().

◆ crypt_hash_destroy()

void crypt_hash_destroy ( struct crypt_hash ctx)

Definition at line 267 of file crypto_gcrypt.c.

Referenced by crypt_hash_test_whirlpool_bug().

◆ crypt_hash_final()

int crypt_hash_final ( struct crypt_hash ctx,
char *  buffer,
size_t  length 
)

Definition at line 250 of file crypto_gcrypt.c.

Referenced by crypt_hash_test_whirlpool_bug().

◆ crypt_hash_init()

int crypt_hash_init ( struct crypt_hash **  ctx,
const char *  name 
)

Definition at line 212 of file crypto_gcrypt.c.

Referenced by crypt_hash_test_whirlpool_bug().

◆ crypt_hash_restart()

static void crypt_hash_restart ( struct crypt_hash ctx)
static

Definition at line 239 of file crypto_gcrypt.c.

References crypt_hash::hd.

Referenced by crypt_hash_final().

◆ crypt_hash_size()

int crypt_hash_size ( const char *  name)

Definition at line 199 of file crypto_gcrypt.c.

Referenced by crypt_hmac_size().

◆ crypt_hash_test_whirlpool_bug()

static void crypt_hash_test_whirlpool_bug ( void  )
static

◆ crypt_hash_write()

int crypt_hash_write ( struct crypt_hash ctx,
const char *  buffer,
size_t  length 
)

Definition at line 244 of file crypto_gcrypt.c.

Referenced by crypt_hash_test_whirlpool_bug().

◆ crypt_hmac_destroy()

void crypt_hmac_destroy ( struct crypt_hmac ctx)

Definition at line 342 of file crypto_gcrypt.c.

◆ crypt_hmac_final()

int crypt_hmac_final ( struct crypt_hmac ctx,
char *  buffer,
size_t  length 
)

Definition at line 325 of file crypto_gcrypt.c.

◆ crypt_hmac_init()

int crypt_hmac_init ( struct crypt_hmac **  ctx,
const char *  name,
const void *  key,
size_t  key_length 
)

Definition at line 280 of file crypto_gcrypt.c.

◆ crypt_hmac_restart()

static void crypt_hmac_restart ( struct crypt_hmac ctx)
static

Definition at line 314 of file crypto_gcrypt.c.

References crypt_hmac::hd.

Referenced by crypt_hmac_final().

◆ crypt_hmac_size()

int crypt_hmac_size ( const char *  name)

Definition at line 275 of file crypto_gcrypt.c.

◆ crypt_hmac_write()

int crypt_hmac_write ( struct crypt_hmac ctx,
const char *  buffer,
size_t  length 
)

Definition at line 319 of file crypto_gcrypt.c.

◆ crypt_pbkdf()

int crypt_pbkdf ( const char *  kdf,
const char *  hash,
const char *  password,
size_t  password_length,
const char *  salt,
size_t  salt_length,
char *  key,
size_t  key_length,
uint32_t  iterations,
uint32_t  memory,
uint32_t  parallel 
)

Definition at line 391 of file crypto_gcrypt.c.

◆ pbkdf2()

static int pbkdf2 ( const char *  hash,
const char *  password,
size_t  password_length,
const char *  salt,
size_t  salt_length,
char *  key,
size_t  key_length,
uint32_t  iterations 
)
static

Variable Documentation

◆ crypto_backend_initialised

int crypto_backend_initialised = 0
static

◆ crypto_backend_secmem

int crypto_backend_secmem = 1
static

Definition at line 30 of file crypto_gcrypt.c.

Referenced by crypt_backend_init().

◆ crypto_backend_whirlpool_bug

int crypto_backend_whirlpool_bug = -1
static

Definition at line 31 of file crypto_gcrypt.c.

Referenced by crypt_backend_init(), and crypt_hash_test_whirlpool_bug().

◆ version