Commit 6e286940 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull crypto fixes from Herbert Xu:

 - Fix IPsec ESN regression in authencesn

 - Fix hmac setkey failure in eip93

 - Guard against IV changing in algif_aead

 - Fix async completion handling in krb5enc

 - Fix fallback async completion in acomp

 - Fix handling of MAY_BACKLOG requests in pcrypt

 - Fix issues with firmware-returned values in ccp

* tag 'v7.1-p2' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
  crypto: krb5enc - fix async decrypt skipping hash verification
  crypto: algif_aead - snapshot IV for async AEAD requests
  crypto: acomp - fix wrong pointer stored by acomp_save_req()
  crypto: ccp - copy IV using skcipher ivsize
  crypto: ccp: Don't attempt to copy ID to userspace if PSP command failed
  crypto: ccp: Don't attempt to copy PDH cert to userspace if PSP command failed
  crypto: ccp: Don't attempt to copy CSR to userspace if PSP command failed
  crypto: pcrypt - Fix handling of MAY_BACKLOG requests
  crypto: sa2ul - Fix AEAD fallback algorithm names
  crypto: authencesn - Fix src offset when decrypting in-place
  crypto: eip93 - fix hmac setkey algo selection
parents 292a2bcd 3bfbf5f0
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -169,15 +169,13 @@ static void acomp_save_req(struct acomp_req *req, crypto_completion_t cplt)
	state->compl = req->base.complete;
	state->data = req->base.data;
	req->base.complete = cplt;
	req->base.data = state;
	req->base.data = req;
}

static void acomp_restore_req(struct acomp_req *req)
{
	struct acomp_req_chain *state = req->base.data;

	req->base.complete = state->compl;
	req->base.data = state->data;
	req->base.complete = req->chain.compl;
	req->base.data = req->chain.data;
}

static void acomp_reqchain_virt(struct acomp_req *req)
+8 −2
Original line number Diff line number Diff line
@@ -72,8 +72,10 @@ static int _aead_recvmsg(struct socket *sock, struct msghdr *msg,
	struct af_alg_ctx *ctx = ask->private;
	struct crypto_aead *tfm = pask->private;
	unsigned int as = crypto_aead_authsize(tfm);
	unsigned int ivsize = crypto_aead_ivsize(tfm);
	struct af_alg_async_req *areq;
	struct scatterlist *rsgl_src, *tsgl_src = NULL;
	void *iv;
	int err = 0;
	size_t used = 0;		/* [in]  TX bufs to be en/decrypted */
	size_t outlen = 0;		/* [out] RX bufs produced by kernel */
@@ -125,10 +127,14 @@ static int _aead_recvmsg(struct socket *sock, struct msghdr *msg,

	/* Allocate cipher request for current operation. */
	areq = af_alg_alloc_areq(sk, sizeof(struct af_alg_async_req) +
				     crypto_aead_reqsize(tfm));
				     crypto_aead_reqsize(tfm) + ivsize);
	if (IS_ERR(areq))
		return PTR_ERR(areq);

	iv = (u8 *)aead_request_ctx(&areq->cra_u.aead_req) +
	     crypto_aead_reqsize(tfm);
	memcpy(iv, ctx->iv, ivsize);

	/* convert iovecs of output buffers into RX SGL */
	err = af_alg_get_rsgl(sk, msg, flags, areq, outlen, &usedpages);
	if (err)
@@ -187,7 +193,7 @@ static int _aead_recvmsg(struct socket *sock, struct msghdr *msg,

	/* Initialize the crypto operation */
	aead_request_set_crypt(&areq->cra_u.aead_req, tsgl_src,
			       areq->first_rsgl.sgl.sgt.sgl, used, ctx->iv);
			       areq->first_rsgl.sgl.sgt.sgl, used, iv);
	aead_request_set_ad(&areq->cra_u.aead_req, ctx->aead_assoclen);
	aead_request_set_tfm(&areq->cra_u.aead_req, tfm);

+4 −2
Original line number Diff line number Diff line
@@ -228,9 +228,11 @@ static int crypto_authenc_esn_decrypt_tail(struct aead_request *req,

decrypt:

	if (src != dst)
		src = scatterwalk_ffwd(areq_ctx->src, src, assoclen);
	dst = scatterwalk_ffwd(areq_ctx->dst, dst, assoclen);
	if (req->src == req->dst)
		src = dst;
	else
		src = scatterwalk_ffwd(areq_ctx->src, src, assoclen);

	skcipher_request_set_tfm(skreq, ctx->enc);
	skcipher_request_set_callback(skreq, flags,
+31 −21
Original line number Diff line number Diff line
@@ -39,12 +39,6 @@ struct krb5enc_request_ctx {
	char tail[];
};

static void krb5enc_request_complete(struct aead_request *req, int err)
{
	if (err != -EINPROGRESS)
		aead_request_complete(req, err);
}

/**
 * crypto_krb5enc_extractkeys - Extract Ke and Ki keys from the key blob.
 * @keys: Where to put the key sizes and pointers
@@ -127,7 +121,7 @@ static void krb5enc_encrypt_done(void *data, int err)
{
	struct aead_request *req = data;

	krb5enc_request_complete(req, err);
	aead_request_complete(req, err);
}

/*
@@ -188,13 +182,15 @@ static void krb5enc_encrypt_ahash_done(void *data, int err)
	struct ahash_request *ahreq = (void *)(areq_ctx->tail + ictx->reqoff);

	if (err)
		return krb5enc_request_complete(req, err);
		goto out;

	krb5enc_insert_checksum(req, ahreq->result);

	err = krb5enc_dispatch_encrypt(req,
				       aead_request_flags(req) & ~CRYPTO_TFM_REQ_MAY_SLEEP);
	if (err != -EINPROGRESS)
	err = krb5enc_dispatch_encrypt(req, 0);
	if (err == -EINPROGRESS)
		return;

out:
	aead_request_complete(req, err);
}

@@ -265,17 +261,16 @@ static void krb5enc_decrypt_hash_done(void *data, int err)
{
	struct aead_request *req = data;

	if (err)
		return krb5enc_request_complete(req, err);

	if (!err)
		err = krb5enc_verify_hash(req);
	krb5enc_request_complete(req, err);
	aead_request_complete(req, err);
}

/*
 * Dispatch the hashing of the plaintext after we've done the decryption.
 */
static int krb5enc_dispatch_decrypt_hash(struct aead_request *req)
static int krb5enc_dispatch_decrypt_hash(struct aead_request *req,
					 unsigned int flags)
{
	struct crypto_aead *krb5enc = crypto_aead_reqtfm(req);
	struct aead_instance *inst = aead_alg_instance(krb5enc);
@@ -291,7 +286,7 @@ static int krb5enc_dispatch_decrypt_hash(struct aead_request *req)
	ahash_request_set_tfm(ahreq, auth);
	ahash_request_set_crypt(ahreq, req->dst, hash,
				req->assoclen + req->cryptlen - authsize);
	ahash_request_set_callback(ahreq, aead_request_flags(req),
	ahash_request_set_callback(ahreq, flags,
				   krb5enc_decrypt_hash_done, req);

	err = crypto_ahash_digest(ahreq);
@@ -301,6 +296,21 @@ static int krb5enc_dispatch_decrypt_hash(struct aead_request *req)
	return krb5enc_verify_hash(req);
}

static void krb5enc_decrypt_done(void *data, int err)
{
	struct aead_request *req = data;

	if (err)
		goto out;

	err = krb5enc_dispatch_decrypt_hash(req, 0);
	if (err == -EINPROGRESS)
		return;

out:
	aead_request_complete(req, err);
}

/*
 * Dispatch the decryption of the ciphertext.
 */
@@ -324,7 +334,7 @@ static int krb5enc_dispatch_decrypt(struct aead_request *req)

	skcipher_request_set_tfm(skreq, ctx->enc);
	skcipher_request_set_callback(skreq, aead_request_flags(req),
				      req->base.complete, req->base.data);
				      krb5enc_decrypt_done, req);
	skcipher_request_set_crypt(skreq, src, dst,
				   req->cryptlen - authsize, req->iv);

@@ -339,7 +349,7 @@ static int krb5enc_decrypt(struct aead_request *req)
	if (err < 0)
		return err;

	return krb5enc_dispatch_decrypt_hash(req);
	return krb5enc_dispatch_decrypt_hash(req, aead_request_flags(req));
}

static int krb5enc_init_tfm(struct crypto_aead *tfm)
+5 −2
Original line number Diff line number Diff line
@@ -69,6 +69,9 @@ static void pcrypt_aead_done(void *data, int err)
	struct pcrypt_request *preq = aead_request_ctx(req);
	struct padata_priv *padata = pcrypt_request_padata(preq);

	if (err == -EINPROGRESS)
		return;

	padata->info = err;

	padata_do_serial(padata);
@@ -82,7 +85,7 @@ static void pcrypt_aead_enc(struct padata_priv *padata)

	ret = crypto_aead_encrypt(req);

	if (ret == -EINPROGRESS)
	if (ret == -EINPROGRESS || ret == -EBUSY)
		return;

	padata->info = ret;
@@ -133,7 +136,7 @@ static void pcrypt_aead_dec(struct padata_priv *padata)

	ret = crypto_aead_decrypt(req);

	if (ret == -EINPROGRESS)
	if (ret == -EINPROGRESS || ret == -EBUSY)
		return;

	padata->info = ret;
Loading