From 989fbb74d23dfebdf3feb0c0d736f92a6f9d8767 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Thu, 18 Oct 2018 16:36:39 +0200 Subject: mkfs.ubifs: Add crypto helper functions Signed-off-by: David Oberhollenzer Signed-off-by: Richard Weinberger --- ubifs-utils/mkfs.ubifs/crypto.h | 68 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 ubifs-utils/mkfs.ubifs/crypto.h (limited to 'ubifs-utils/mkfs.ubifs/crypto.h') diff --git a/ubifs-utils/mkfs.ubifs/crypto.h b/ubifs-utils/mkfs.ubifs/crypto.h new file mode 100644 index 0000000..4e59700 --- /dev/null +++ b/ubifs-utils/mkfs.ubifs/crypto.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2017 sigma star gmbh + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: David Oberhollenzer + */ + +#ifndef UBIFS_CRYPTO_H +#define UBIFS_CRYPTO_H + +#include +#include +#include +#include + + +struct cipher { + const char *name; + + ssize_t (*encrypt_block)(const void *plaintext, size_t size, + const void *key, uint64_t block_index, + void *ciphertext); + + ssize_t (*encrypt_fname)(const void *plaintext, size_t size, + const void *key, void *ciphertext); +}; + + +int crypto_init(void); + +void crypto_cleanup(void); + +ssize_t encrypt_block_aes128_cbc(const void *plaintext, size_t size, + const void *key, uint64_t block_index, + void *ciphertext); + +ssize_t encrypt_block_aes256_xts(const void *plaintext, size_t size, + const void *key, uint64_t block_index, + void *ciphertext); + +ssize_t encrypt_aes128_cbc_cts(const void *plaintext, size_t size, + const void *key, void *ciphertext); + +ssize_t encrypt_aes256_cbc_cts(const void *plaintext, size_t size, + const void *key, void *ciphertext); + +ssize_t derive_key_aes(const void *deriving_key, const void *source_key, + void *derived_key); + + +struct cipher *get_cipher(const char *name); + +void list_ciphers(FILE *fp); + +#endif /* UBIFS_CRYPTO_H */ + -- cgit v1.2.3