/*
 * 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 */
