Commit 6d297945 authored by Milan Broz's avatar Milan Broz

Key parameter is always const in cipher and storage backend.

parent dee38e9c
......@@ -22,6 +22,7 @@
#define _CRYPTO_BACKEND_H
#include <stdint.h>
#include <stddef.h>
#include <string.h>
struct crypt_device;
......@@ -100,7 +101,7 @@ uint32_t crypt_crc32(uint32_t seed, const unsigned char *buf, size_t len);
/* ciphers */
int crypt_cipher_blocksize(const char *name);
int crypt_cipher_init(struct crypt_cipher **ctx, const char *name,
const char *mode, const void *buffer, size_t length);
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,
......@@ -112,7 +113,7 @@ int crypt_cipher_decrypt(struct crypt_cipher *ctx,
/* storage encryption wrappers */
int crypt_storage_init(struct crypt_storage **ctx, uint64_t sector_start,
const char *cipher, const char *cipher_mode,
char *key, size_t key_length);
const void *key, size_t key_length);
void crypt_storage_destroy(struct crypt_storage *ctx);
int crypt_storage_decrypt(struct crypt_storage *ctx, uint64_t sector,
size_t count, char *buffer);
......
......@@ -96,7 +96,7 @@ int crypt_cipher_blocksize(const char *name)
* (but cannot check specificaly for skcipher API)
*/
int crypt_cipher_init(struct crypt_cipher **ctx, const char *name,
const char *mode, const void *buffer, size_t length)
const char *mode, const void *key, size_t key_length)
{
struct crypt_cipher *h;
struct sockaddr_alg sa = {
......@@ -124,9 +124,9 @@ int crypt_cipher_init(struct crypt_cipher **ctx, const char *name,
}
if (!strcmp(name, "cipher_null"))
length = 0;
key_length = 0;
if (setsockopt(h->tfmfd, SOL_ALG, ALG_SET_KEY, buffer, length) < 0) {
if (setsockopt(h->tfmfd, SOL_ALG, ALG_SET_KEY, key, key_length) < 0) {
crypt_cipher_destroy(h);
return -EINVAL;
}
......
......@@ -56,7 +56,7 @@ static int int_log2(unsigned int x)
static int crypt_sector_iv_init(struct crypt_sector_iv *ctx,
const char *cipher_name, const char *mode_name,
const char *iv_name, char *key, size_t key_length)
const char *iv_name, const void *key, size_t key_length)
{
memset(ctx, 0, sizeof(*ctx));
......@@ -197,7 +197,7 @@ int crypt_storage_init(struct crypt_storage **ctx,
uint64_t sector_start,
const char *cipher,
const char *cipher_mode,
char *key, size_t key_length)
const void *key, size_t key_length)
{
struct crypt_storage *s;
char mode_name[64];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment