Exemplo n.º 1
0
static void *prism2_wep_init(int keyidx)
{
	struct prism2_wep_data *priv;

	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
	if (!priv)
		return NULL;
	priv->key_idx = keyidx;

	priv->tx_tfm = crypto_alloc_sync_skcipher("ecb(arc4)", 0, 0);
	if (IS_ERR(priv->tx_tfm))
		goto free_priv;
	priv->rx_tfm = crypto_alloc_sync_skcipher("ecb(arc4)", 0, 0);
	if (IS_ERR(priv->rx_tfm))
		goto free_tx;

	/* start WEP IV from a random value */
	get_random_bytes(&priv->iv, 4);

	return priv;
free_tx:
	crypto_free_sync_skcipher(priv->tx_tfm);
free_priv:
	kfree(priv);
	return NULL;
}
Exemplo n.º 2
0
static int qce_ablkcipher_init(struct crypto_tfm *tfm)
{
	struct qce_cipher_ctx *ctx = crypto_tfm_ctx(tfm);

	memset(ctx, 0, sizeof(*ctx));
	tfm->crt_ablkcipher.reqsize = sizeof(struct qce_cipher_reqctx);

	ctx->fallback = crypto_alloc_sync_skcipher(crypto_tfm_alg_name(tfm),
						   0, CRYPTO_ALG_NEED_FALLBACK);
	return PTR_ERR_OR_ZERO(ctx->fallback);
}
Exemplo n.º 3
0
static int p8_aes_ctr_init(struct crypto_tfm *tfm)
{
	const char *alg = crypto_tfm_alg_name(tfm);
	struct crypto_sync_skcipher *fallback;
	struct p8_aes_ctr_ctx *ctx = crypto_tfm_ctx(tfm);

	fallback = crypto_alloc_sync_skcipher(alg, 0,
					      CRYPTO_ALG_NEED_FALLBACK);
	if (IS_ERR(fallback)) {
		printk(KERN_ERR
		       "Failed to allocate transformation for '%s': %ld\n",
		       alg, PTR_ERR(fallback));
		return PTR_ERR(fallback);
	}

	crypto_sync_skcipher_set_flags(
		fallback,
		crypto_skcipher_get_flags((struct crypto_skcipher *)tfm));
	ctx->fallback = fallback;

	return 0;
}