mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-28 03:00:09 +01:00
* Pad luks header to 512 sector size. We need read/write in whole sector anyway and space is unused (wiped in luksFormat) so there is no need for read/seek/write exercise. * Rework read/write blockwise to not split operation to many pieces. thanks to Sebastian Andrzej Siewior: The buffer has to be aligned due to the O_DIRECT in open(). Currently a small blocksize buffer is allocated and everything is read in multiple reads and copied back to the original buffer. In my case AFEKSize gets computed to 64000 which results in 125 reads with 512 bytes each. This patch changes this behavior to a single operation where the majority is read()/write() plus an optional fixup in case the request is not modulo block size. * Use posix_memalign and check for alignment if available. Othewise use old align functions. Add autoconf to detect posix_memalign. git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@74 36d66b0a-2a48-0410-832c-cd162a569da5
78 lines
2.1 KiB
C
78 lines
2.1 KiB
C
#ifndef INTERNAL_H
|
|
#define INTERNAL_H
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
# include "config.h"
|
|
#endif
|
|
|
|
#include <stdint.h>
|
|
#include <stdarg.h>
|
|
#include <unistd.h>
|
|
|
|
#define SECTOR_SHIFT 9
|
|
#define SECTOR_SIZE (1 << SECTOR_SHIFT)
|
|
#define DEFAULT_ALIGNMENT 4096
|
|
|
|
/* private struct crypt_options flags */
|
|
|
|
#define CRYPT_FLAG_FREE_DEVICE (1 << 24)
|
|
#define CRYPT_FLAG_FREE_CIPHER (1 << 25)
|
|
|
|
#define CRYPT_FLAG_PRIVATE_MASK ((unsigned int)-1 << 24)
|
|
|
|
struct hash_type {
|
|
char *name;
|
|
void *private;
|
|
int (*fn)(void *data, int size, char *key,
|
|
int sizep, const char *passphrase);
|
|
};
|
|
|
|
struct hash_backend {
|
|
const char *name;
|
|
struct hash_type * (*get_hashes)(void);
|
|
void (*free_hashes)(struct hash_type *hashes);
|
|
};
|
|
|
|
struct setup_backend {
|
|
const char *name;
|
|
int (*init)(void);
|
|
void (*exit)(void);
|
|
int (*create)(int reload, struct crypt_options *options,
|
|
const char *key, const char *uuid);
|
|
int (*status)(int details, struct crypt_options *options,
|
|
char **key);
|
|
int (*remove)(int force, struct crypt_options *options);
|
|
|
|
const char * (*dir)(void);
|
|
};
|
|
|
|
void set_error_va(const char *fmt, va_list va);
|
|
void set_error(const char *fmt, ...);
|
|
const char *get_error(void);
|
|
void *safe_alloc(size_t size);
|
|
void safe_free(void *data);
|
|
void *safe_realloc(void *data, size_t size);
|
|
char *safe_strdup(const char *s);
|
|
|
|
struct hash_backend *get_hash_backend(const char *name);
|
|
void put_hash_backend(struct hash_backend *backend);
|
|
int hash(const char *backend_name, const char *hash_name,
|
|
char *result, size_t size,
|
|
const char *passphrase, size_t sizep);
|
|
|
|
struct setup_backend *get_setup_backend(const char *name);
|
|
void put_setup_backend(struct setup_backend *backend);
|
|
|
|
void hexprint(char *d, int n);
|
|
|
|
int sector_size_for_device(const char *device);
|
|
ssize_t write_blockwise(int fd, const void *buf, size_t count);
|
|
ssize_t read_blockwise(int fd, void *_buf, size_t count);
|
|
ssize_t write_lseek_blockwise(int fd, const char *buf, size_t count, off_t offset);
|
|
|
|
|
|
int get_key(char *prompt, char **key, unsigned int *passLen, int key_size,
|
|
const char *key_file, int passphrase_fd, int timeout, int how2verify);
|
|
|
|
#endif /* INTERNAL_H */
|