8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 6855671
27 * @summary DerOutputStream encodes negative integer incorrectly
28 */
29 import sun.security.util.DerOutputStream;
30
31 public class NegInt {
32
33 public static void main(String[] args) throws Exception {
34 DerOutputStream out;
35 out = new DerOutputStream();
36 out.putInteger(-128);
37 if(out.toByteArray().length != 3) {
38 throw new Exception("-128 encode error");
39 }
40 out = new DerOutputStream();
41 out.putInteger(-129);
42 if(out.toByteArray().length != 4) {
43 throw new Exception("-129 encode error");
44 }
45 }
46 }
|
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 6855671
27 * @summary DerOutputStream encodes negative integer incorrectly
28 * @modules java.base/sun.security.util
29 */
30 import sun.security.util.DerOutputStream;
31
32 public class NegInt {
33
34 public static void main(String[] args) throws Exception {
35 DerOutputStream out;
36 out = new DerOutputStream();
37 out.putInteger(-128);
38 if(out.toByteArray().length != 3) {
39 throw new Exception("-128 encode error");
40 }
41 out = new DerOutputStream();
42 out.putInteger(-129);
43 if(out.toByteArray().length != 4) {
44 throw new Exception("-129 encode error");
45 }
46 }
47 }
|