-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
crypto: speck - export common helpers
Export the Speck constants and transform context and the ->setkey(), ->encrypt(), and ->decrypt() functions so that they can be reused by the ARM NEON implementation of Speck-XTS. The generic key expansion code will be reused because it is not performance-critical and is not vectorizable, while the generic encryption and decryption functions are needed as fallbacks and for the XTS tweak encryption. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
- Loading branch information
Eric Biggers
authored and
Herbert Xu
committed
Feb 22, 2018
1 parent
da7a0ab
commit c8c3641
Showing
2 changed files
with
111 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* | ||
* Common values for the Speck algorithm | ||
*/ | ||
|
||
#ifndef _CRYPTO_SPECK_H | ||
#define _CRYPTO_SPECK_H | ||
|
||
#include <linux/types.h> | ||
|
||
/* Speck128 */ | ||
|
||
#define SPECK128_BLOCK_SIZE 16 | ||
|
||
#define SPECK128_128_KEY_SIZE 16 | ||
#define SPECK128_128_NROUNDS 32 | ||
|
||
#define SPECK128_192_KEY_SIZE 24 | ||
#define SPECK128_192_NROUNDS 33 | ||
|
||
#define SPECK128_256_KEY_SIZE 32 | ||
#define SPECK128_256_NROUNDS 34 | ||
|
||
struct speck128_tfm_ctx { | ||
u64 round_keys[SPECK128_256_NROUNDS]; | ||
int nrounds; | ||
}; | ||
|
||
void crypto_speck128_encrypt(const struct speck128_tfm_ctx *ctx, | ||
u8 *out, const u8 *in); | ||
|
||
void crypto_speck128_decrypt(const struct speck128_tfm_ctx *ctx, | ||
u8 *out, const u8 *in); | ||
|
||
int crypto_speck128_setkey(struct speck128_tfm_ctx *ctx, const u8 *key, | ||
unsigned int keysize); | ||
|
||
/* Speck64 */ | ||
|
||
#define SPECK64_BLOCK_SIZE 8 | ||
|
||
#define SPECK64_96_KEY_SIZE 12 | ||
#define SPECK64_96_NROUNDS 26 | ||
|
||
#define SPECK64_128_KEY_SIZE 16 | ||
#define SPECK64_128_NROUNDS 27 | ||
|
||
struct speck64_tfm_ctx { | ||
u32 round_keys[SPECK64_128_NROUNDS]; | ||
int nrounds; | ||
}; | ||
|
||
void crypto_speck64_encrypt(const struct speck64_tfm_ctx *ctx, | ||
u8 *out, const u8 *in); | ||
|
||
void crypto_speck64_decrypt(const struct speck64_tfm_ctx *ctx, | ||
u8 *out, const u8 *in); | ||
|
||
int crypto_speck64_setkey(struct speck64_tfm_ctx *ctx, const u8 *key, | ||
unsigned int keysize); | ||
|
||
#endif /* _CRYPTO_SPECK_H */ |