diff options
author | Yunhong Jiang <yunhong.jiang@intel.com> | 2015-08-04 12:17:53 -0700 |
---|---|---|
committer | Yunhong Jiang <yunhong.jiang@intel.com> | 2015-08-04 15:44:42 -0700 |
commit | 9ca8dbcc65cfc63d6f5ef3312a33184e1d726e00 (patch) | |
tree | 1c9cafbcd35f783a87880a10f85d1a060db1a563 /kernel/drivers/staging/skein/threefish_api.c | |
parent | 98260f3884f4a202f9ca5eabed40b1354c489b29 (diff) |
Add the rt linux 4.1.3-rt3 as base
Import the rt linux 4.1.3-rt3 as OPNFV kvm base.
It's from git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git linux-4.1.y-rt and
the base is:
commit 0917f823c59692d751951bf5ea699a2d1e2f26a2
Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Sat Jul 25 12:13:34 2015 +0200
Prepare v4.1.3-rt3
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
We lose all the git history this way and it's not good. We
should apply another opnfv project repo in future.
Change-Id: I87543d81c9df70d99c5001fbdf646b202c19f423
Signed-off-by: Yunhong Jiang <yunhong.jiang@intel.com>
Diffstat (limited to 'kernel/drivers/staging/skein/threefish_api.c')
-rw-r--r-- | kernel/drivers/staging/skein/threefish_api.c | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/kernel/drivers/staging/skein/threefish_api.c b/kernel/drivers/staging/skein/threefish_api.c new file mode 100644 index 000000000..2b649abb7 --- /dev/null +++ b/kernel/drivers/staging/skein/threefish_api.c @@ -0,0 +1,77 @@ +#include <linux/string.h> +#include "threefish_api.h" + +void threefish_set_key(struct threefish_key *key_ctx, + enum threefish_size state_size, + u64 *key_data, u64 *tweak) +{ + int key_words = state_size / 64; + int i; + u64 parity = KEY_SCHEDULE_CONST; + + key_ctx->tweak[0] = tweak[0]; + key_ctx->tweak[1] = tweak[1]; + key_ctx->tweak[2] = tweak[0] ^ tweak[1]; + + for (i = 0; i < key_words; i++) { + key_ctx->key[i] = key_data[i]; + parity ^= key_data[i]; + } + key_ctx->key[i] = parity; + key_ctx->state_size = state_size; +} + +void threefish_encrypt_block_bytes(struct threefish_key *key_ctx, u8 *in, + u8 *out) +{ + u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ + u64 cipher[SKEIN_MAX_STATE_WORDS]; + + skein_get64_lsb_first(plain, in, key_ctx->state_size / 64); + threefish_encrypt_block_words(key_ctx, plain, cipher); + skein_put64_lsb_first(out, cipher, key_ctx->state_size / 8); +} + +void threefish_encrypt_block_words(struct threefish_key *key_ctx, u64 *in, + u64 *out) +{ + switch (key_ctx->state_size) { + case THREEFISH_256: + threefish_encrypt_256(key_ctx, in, out); + break; + case THREEFISH_512: + threefish_encrypt_512(key_ctx, in, out); + break; + case THREEFISH_1024: + threefish_encrypt_1024(key_ctx, in, out); + break; + } +} + +void threefish_decrypt_block_bytes(struct threefish_key *key_ctx, u8 *in, + u8 *out) +{ + u64 plain[SKEIN_MAX_STATE_WORDS]; /* max number of words*/ + u64 cipher[SKEIN_MAX_STATE_WORDS]; + + skein_get64_lsb_first(cipher, in, key_ctx->state_size / 64); + threefish_decrypt_block_words(key_ctx, cipher, plain); + skein_put64_lsb_first(out, plain, key_ctx->state_size / 8); +} + +void threefish_decrypt_block_words(struct threefish_key *key_ctx, u64 *in, + u64 *out) +{ + switch (key_ctx->state_size) { + case THREEFISH_256: + threefish_decrypt_256(key_ctx, in, out); + break; + case THREEFISH_512: + threefish_decrypt_512(key_ctx, in, out); + break; + case THREEFISH_1024: + threefish_decrypt_1024(key_ctx, in, out); + break; + } +} + |