8217344: Make comparison overflow-aware in ECDHKeyAgreement.engineGenerateSecret()
Reviewed-by: apetcher
This commit is contained in:
parent
8859f7ec1e
commit
db89805fe0
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2019, 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
|
||||
@ -178,7 +178,7 @@ public final class ECDHKeyAgreement extends KeyAgreementSpi {
|
||||
@Override
|
||||
protected int engineGenerateSecret(byte[] sharedSecret, int
|
||||
offset) throws IllegalStateException, ShortBufferException {
|
||||
if (offset + secretLen > sharedSecret.length) {
|
||||
if (secretLen > sharedSecret.length - offset) {
|
||||
throw new ShortBufferException("Need " + secretLen
|
||||
+ " bytes, only " + (sharedSecret.length - offset)
|
||||
+ " available");
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2019, 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
|
||||
@ -163,7 +163,7 @@ abstract class ECDSASignature extends SignatureSpi {
|
||||
if (len <= 0) {
|
||||
return;
|
||||
}
|
||||
if (offset + len >= precomputedDigest.length) {
|
||||
if (len >= precomputedDigest.length - offset) {
|
||||
offset = RAW_ECDSA_MAX + 1;
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user