Skip to content

Commit

Permalink
8247895: SHA1PRNGReseed.java is calling setSeed(0)
Browse files Browse the repository at this point in the history
Backport-of: 5a51d70
  • Loading branch information
GoeLin committed Jun 27, 2023
1 parent e986452 commit dccbde7
Showing 1 changed file with 4 additions and 4 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2021, 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
Expand Down Expand Up @@ -28,14 +28,14 @@

/**
* @test
* @bug 8154523
* @bug 8154523 8247895
* @summary SHA1PRNG output should change after setSeed
*/
public class SHA1PRNGReseed {

public static void main(String[] args) throws Exception {
SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
sr.setSeed(0);
sr.setSeed(1);
sr.nextInt();

ByteArrayOutputStream bout = new ByteArrayOutputStream();
Expand All @@ -45,7 +45,7 @@ public static void main(String[] args) throws Exception {
new ByteArrayInputStream(bout.toByteArray())).readObject();

int i1 = sr.nextInt();
sr2.setSeed(1);
sr2.setSeed(2);
int i2 = sr2.nextInt();

if (i1 == i2) {
Expand Down

1 comment on commit dccbde7

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.