8216045: The size of key_exchange may be wrong on FFDHE
Reviewed-by: jnimeh
This commit is contained in:
parent
61f2218ba2
commit
58c0287a18
@ -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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -220,8 +220,8 @@ final class DHKeyExchange {
|
|||||||
public byte[] encode() {
|
public byte[] encode() {
|
||||||
// Note: the DH public value is encoded as a big-endian integer
|
// 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.
|
// and padded to the left with zeros to the size of p in bytes.
|
||||||
byte[] encoded = publicKey.getY().toByteArray();
|
byte[] encoded = Utilities.toByteArray(publicKey.getY());
|
||||||
int pSize = KeyUtil.getKeySize(publicKey);
|
int pSize = (KeyUtil.getKeySize(publicKey) + 7) >>> 3;
|
||||||
if (pSize > 0 && encoded.length < pSize) {
|
if (pSize > 0 && encoded.length < pSize) {
|
||||||
byte[] buffer = new byte[pSize];
|
byte[] buffer = new byte[pSize];
|
||||||
System.arraycopy(encoded, 0,
|
System.arraycopy(encoded, 0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user