blob: c487478df0f696955d91b836dd77d67fcc86688c [file] [log] [blame]
/*
* Copyright (C) 2018 Samsung Electronics Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Functions related to blk-crypt(for inline encryption) handling
*
* NOTE :
* blk-crypt implementation depends on a inline encryption hardware.
*
*/
#ifndef _BLK_CRYPT_H
#define _BLK_CRYPT_H
#include <linux/types.h>
struct bio;
struct block_device;
typedef void blk_crypt_t;
#define BLK_CRYPT_MODE_INLINE_PRIVATE (127)
struct blk_crypt_algorithm_cbs {
void *(*alloc)(void);
void (*free)(void *data);
unsigned char *(*get_key)(void *);
int (*set_key)(void *, const char *, int, void *);
};
extern bool blk_crypt_encrypted(const struct bio *bio);
extern bool blk_crypt_mergeable(const struct bio *a, const struct bio *b);
extern void *blk_crypt_alg_register(struct block_device *, const char *, const unsigned int,
const struct blk_crypt_algorithm_cbs *);
extern int blk_crypt_alg_unregister(void *);
extern blk_crypt_t *blk_crypt_get_context(struct block_device *, const char *);
extern void blk_crypt_put_context(blk_crypt_t *);
extern void *blk_crypt_get_data(blk_crypt_t *);
extern unsigned char *blk_crypt_get_key(blk_crypt_t *);
extern int blk_crypt_set_key(blk_crypt_t *, u8 *raw_key, u32 keysize, void *priv);
#endif /* _BLK_CRYPT_H */