8281628: KeyAgreement : generateSecret intermittently not resetting

Reviewed-by: valeriep
This commit is contained in:
Weijun Wang 2022-03-03 00:39:39 +00:00
parent b6c35ae44a
commit 1485883c9e
2 changed files with 77 additions and 1 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -344,6 +344,8 @@ extends KeyAgreementSpi {
} else {
// Array too short, pad it w/ leading 0s
if (secret.length < expectedLen) {
Arrays.fill(sharedSecret, offset,
offset + (expectedLen - secret.length), (byte)0);
System.arraycopy(secret, 0, sharedSecret,
offset + (expectedLen - secret.length),
secret.length);