Skip to content

Commit

Permalink
crypto: salsa20 - Revert "crypto: salsa20 - export generic helpers"
Browse files Browse the repository at this point in the history
This reverts commit eb772f3, as now the
x86 Salsa20 implementation has been removed and the generic helpers are
no longer needed outside of salsa20_generic.c.

We could keep this just in case someone else wants to add a new
optimized Salsa20 implementation.  But given that we have ChaCha20 now
too, I think it's unlikely.  And this can always be reverted back.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
ebiggers authored and herbertx committed May 30, 2018
1 parent b7b73cd commit 015a037
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 34 deletions.
20 changes: 13 additions & 7 deletions crypto/salsa20_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,17 @@

#include <asm/unaligned.h>
#include <crypto/internal/skcipher.h>
#include <crypto/salsa20.h>
#include <linux/module.h>

#define SALSA20_IV_SIZE 8
#define SALSA20_MIN_KEY_SIZE 16
#define SALSA20_MAX_KEY_SIZE 32
#define SALSA20_BLOCK_SIZE 64

struct salsa20_ctx {
u32 initial_state[16];
};

static void salsa20_block(u32 *state, __le32 *stream)
{
u32 x[16];
Expand Down Expand Up @@ -93,16 +101,15 @@ static void salsa20_docrypt(u32 *state, u8 *dst, const u8 *src,
}
}

void crypto_salsa20_init(u32 *state, const struct salsa20_ctx *ctx,
static void salsa20_init(u32 *state, const struct salsa20_ctx *ctx,
const u8 *iv)
{
memcpy(state, ctx->initial_state, sizeof(ctx->initial_state));
state[6] = get_unaligned_le32(iv + 0);
state[7] = get_unaligned_le32(iv + 4);
}
EXPORT_SYMBOL_GPL(crypto_salsa20_init);

int crypto_salsa20_setkey(struct crypto_skcipher *tfm, const u8 *key,
static int salsa20_setkey(struct crypto_skcipher *tfm, const u8 *key,
unsigned int keysize)
{
static const char sigma[16] = "expand 32-byte k";
Expand Down Expand Up @@ -143,7 +150,6 @@ int crypto_salsa20_setkey(struct crypto_skcipher *tfm, const u8 *key,

return 0;
}
EXPORT_SYMBOL_GPL(crypto_salsa20_setkey);

static int salsa20_crypt(struct skcipher_request *req)
{
Expand All @@ -155,7 +161,7 @@ static int salsa20_crypt(struct skcipher_request *req)

err = skcipher_walk_virt(&walk, req, true);

crypto_salsa20_init(state, ctx, walk.iv);
salsa20_init(state, ctx, walk.iv);

while (walk.nbytes > 0) {
unsigned int nbytes = walk.nbytes;
Expand Down Expand Up @@ -183,7 +189,7 @@ static struct skcipher_alg alg = {
.max_keysize = SALSA20_MAX_KEY_SIZE,
.ivsize = SALSA20_IV_SIZE,
.chunksize = SALSA20_BLOCK_SIZE,
.setkey = crypto_salsa20_setkey,
.setkey = salsa20_setkey,
.encrypt = salsa20_crypt,
.decrypt = salsa20_crypt,
};
Expand Down
27 changes: 0 additions & 27 deletions include/crypto/salsa20.h

This file was deleted.

0 comments on commit 015a037

Please sign in to comment.