diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2018-10-18 16:36:39 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2018-11-01 12:31:59 +0100 |
commit | 989fbb74d23dfebdf3feb0c0d736f92a6f9d8767 (patch) | |
tree | 0fbd869bb84b0daeeade284d1d8e19bde4a790b8 /ubifs-utils/mkfs.ubifs/crypto.h | |
parent | 23b99432e59b4ee994888f7bd8ef1f77bb424756 (diff) |
mkfs.ubifs: Add crypto helper functions
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'ubifs-utils/mkfs.ubifs/crypto.h')
-rw-r--r-- | ubifs-utils/mkfs.ubifs/crypto.h | 68 |
1 files changed, 68 insertions, 0 deletions
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 <david.oberhollenzer@sigma-star.at> + */ + +#ifndef UBIFS_CRYPTO_H +#define UBIFS_CRYPTO_H + +#include <sys/types.h> +#include <stddef.h> +#include <stdint.h> +#include <stdio.h> + + +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 */ + |