# HG changeset patch # User xuelei # Date 1547666383 28800 # Node ID cb4212fda8e41d2df4d1814c4606217c2e0acd21 # Parent 659b004b6a1bd8c31e766cbdf328d8f8473fd4d7 8216045: The size of key_exchange may be wrong on FFDHE Reviewed-by: jnimeh diff -r 659b004b6a1b -r cb4212fda8e4 src/java.base/share/classes/sun/security/ssl/DHKeyExchange.java --- a/src/java.base/share/classes/sun/security/ssl/DHKeyExchange.java Wed Jan 16 23:56:32 2019 +0530 +++ b/src/java.base/share/classes/sun/security/ssl/DHKeyExchange.java Wed Jan 16 11:19:43 2019 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -220,8 +220,8 @@ public byte[] encode() { // Note: the DH public value is encoded as a big-endian integer // and padded to the left with zeros to the size of p in bytes. - byte[] encoded = publicKey.getY().toByteArray(); - int pSize = KeyUtil.getKeySize(publicKey); + byte[] encoded = Utilities.toByteArray(publicKey.getY()); + int pSize = (KeyUtil.getKeySize(publicKey) + 7) >>> 3; if (pSize > 0 && encoded.length < pSize) { byte[] buffer = new byte[pSize]; System.arraycopy(encoded, 0,