Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 14d4cc08 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull /dev/random updates from Ted Ts'o:
 "This adds a memzero_explicit() call which is guaranteed not to be
  optimized away by GCC.  This is important when we are wiping
  cryptographically sensitive material"

* tag 'random_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/random:
  crypto: memzero_explicit - make sure to clear out sensitive data
  random: add and use memzero_explicit() for clearing data
parents 1c45d9a9 7185ad26
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -202,7 +202,8 @@ static int cts_cbc_decrypt(struct crypto_cts_ctx *ctx,
	/* 5. Append the tail (BB - Ln) bytes of Xn (tmp) to Cn to create En */
	memcpy(s + bsize + lastn, tmp + lastn, bsize - lastn);
	/* 6. Decrypt En to create Pn-1 */
	memset(iv, 0, sizeof(iv));
	memzero_explicit(iv, sizeof(iv));

	sg_set_buf(&sgsrc[0], s + bsize, bsize);
	sg_set_buf(&sgdst[0], d, bsize);
	err = crypto_blkcipher_decrypt_iv(&lcldesc, sgdst, sgsrc, bsize);
+1 −1
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ int crypto_sha1_update(struct shash_desc *desc, const u8 *data,
			src = data + done;
		} while (done + SHA1_BLOCK_SIZE <= len);

		memset(temp, 0, sizeof(temp));
		memzero_explicit(temp, sizeof(temp));
		partial = 0;
	}
	memcpy(sctx->buffer + partial, src, len - done);
+2 −3
Original line number Diff line number Diff line
@@ -211,10 +211,9 @@ static void sha256_transform(u32 *state, const u8 *input)

	/* clear any sensitive info... */
	a = b = c = d = e = f = g = h = t1 = t2 = 0;
	memset(W, 0, 64 * sizeof(u32));
	memzero_explicit(W, 64 * sizeof(u32));
}


static int sha224_init(struct shash_desc *desc)
{
	struct sha256_state *sctx = shash_desc_ctx(desc);
@@ -317,7 +316,7 @@ static int sha224_final(struct shash_desc *desc, u8 *hash)
	sha256_final(desc, D);

	memcpy(hash, D, SHA224_DIGEST_SIZE);
	memset(D, 0, SHA256_DIGEST_SIZE);
	memzero_explicit(D, SHA256_DIGEST_SIZE);

	return 0;
}
+1 −1
Original line number Diff line number Diff line
@@ -239,7 +239,7 @@ static int sha384_final(struct shash_desc *desc, u8 *hash)
	sha512_final(desc, D);

	memcpy(hash, D, 48);
	memset(D, 0, 64);
	memzero_explicit(D, 64);

	return 0;
}
+2 −2
Original line number Diff line number Diff line
@@ -612,7 +612,7 @@ static int tgr160_final(struct shash_desc *desc, u8 * out)

	tgr192_final(desc, D);
	memcpy(out, D, TGR160_DIGEST_SIZE);
	memset(D, 0, TGR192_DIGEST_SIZE);
	memzero_explicit(D, TGR192_DIGEST_SIZE);

	return 0;
}
@@ -623,7 +623,7 @@ static int tgr128_final(struct shash_desc *desc, u8 * out)

	tgr192_final(desc, D);
	memcpy(out, D, TGR128_DIGEST_SIZE);
	memset(D, 0, TGR192_DIGEST_SIZE);
	memzero_explicit(D, TGR192_DIGEST_SIZE);

	return 0;
}
Loading