Skip to content

Commit

Permalink
Mark SHA1PRNG as deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
sf-sunnymittal committed Dec 10, 2024
1 parent b6f238b commit ab366f5
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

public enum PRNGAlgorithm {

AUTOSELECT("AUTOSELECT", new SingletonRandomFactory(SecurityUtils.getRandomFactory())), SHA1PRNG("SHA1PRNG",
AUTOSELECT("AUTOSELECT", new SingletonRandomFactory(SecurityUtils.getRandomFactory())), SHA1PRNG_DEPRECATED("SHA1PRNG",
SHA1PRGRandomFactory.INSTANCE), NativePRNG("NativePRNG", NativePRNGRandomFactory.INSTANCE), NativePRNGBlocking(
"NativePRNGBlocking", NativeBlockingPRNGRandomFactory.INSTANCE), NativePRNGNonBlocking("NativePRNGNonBlocking",
NativeNonBlockingPRNGFactory.INSTANCE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<sftp:config name="sftp-config">
<sftp:connection username="mule" password="test" host="127.0.0.1" port="${sftp.listener.port}"
workingDir="/app" prngAlgorithm="SHA1PRNG">
workingDir="/app" prngAlgorithm="NativePRNG">
<reconnection >
<reconnect-forever />
</reconnection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<sftp:config name="sftp-config">
<sftp:connection username="mule" password="test" host="127.0.0.1" port="${sftp.listener.port}"
workingDir="/app" prngAlgorithm="SHA1PRNG" identityFile="id_ed25519" passphrase="mulesoft">
workingDir="/app" prngAlgorithm="NativePRNG" identityFile="id_ed25519" passphrase="mulesoft">
<reconnection >
<reconnect-forever />
</reconnection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class SftpClientTestCase {
protected SchedulerService schedulerService;

@InjectMocks
private SftpClient client = new SftpClient(EMPTY, 0, PRNGAlgorithm.SHA1PRNG, schedulerService, true, null, Properties::new);
private SftpClient client = new SftpClient(EMPTY, 0, PRNGAlgorithm.NativePRNG, schedulerService, true, null, Properties::new);

@Test
public void returnNullOnUnexistingFile() throws Exception {
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/org/mule/extension/sftp/SftpTestHarness.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ protected void doAfter() throws Exception {

private SftpClient createDefaultSftpClient() throws IOException, GeneralSecurityException {
SftpClient sftpClient =
new SftpClientFactory().createInstance("localhost", sftpPort.getNumber(), PRNGAlgorithm.SHA1PRNG, schedulerService, null,
new SftpClientFactory().createInstance("localhost", sftpPort.getNumber(), PRNGAlgorithm.NativePRNG, schedulerService,
null,
true, Properties::new);
clientAuthConfigurator.configure(sftpClient);

Expand Down
34 changes: 17 additions & 17 deletions src/test/munit/configurations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,33 @@

<sftp:config name="config">
<sftp:connection username="muletest1" password="muletest1" host="localhost" port="${sftp.server.port}"
workingDir="/" prngAlgorithm="SHA1PRNG">
workingDir="/" prngAlgorithm="NativePRNG">
<pooling-profile exhaustedAction="WHEN_EXHAUSTED_WAIT" maxActive="15" maxIdle="3" maxWait="5000"/>
</sftp:connection>
</sftp:config>

<sftp:config name="file-enabled-config">
<sftp:connection username="muletest1" password="muletest1" host="localhost" port="${sftp.server.port}"
workingDir="/" prngAlgorithm="SHA1PRNG" sshConfigOverride="${app.home}/mule_sshd_config">
workingDir="/" prngAlgorithm="NativePRNG" sshConfigOverride="${app.home}/mule_sshd_config">
<pooling-profile exhaustedAction="WHEN_EXHAUSTED_WAIT" maxActive="7" maxIdle="3" maxWait="5000"/>
</sftp:connection>
</sftp:config>

<sftp:config name="unknown-file-enabled-config">
<sftp:connection username="muletest1" password="muletest1" host="localhost" port="${sftp.server.port}"
workingDir="/" prngAlgorithm="SHA1PRNG" sshConfigOverride="${app.home}/mule_sshd">
workingDir="/" prngAlgorithm="NativePRNG" sshConfigOverride="${app.home}/mule_sshd">
<pooling-profile exhaustedAction="WHEN_EXHAUSTED_WAIT" maxActive="7" maxIdle="3" maxWait="5000"/>
</sftp:connection>
</sftp:config>

<sftp:config name="strict-KEX-enabled-config">
<sftp:connection username="mule" password="test" host="localhost" port="${sftp.listener.port}" prngAlgorithm="SHA1PRNG" kexHeader="true">
<sftp:connection username="mule" password="test" host="localhost" port="${sftp.listener.port}" prngAlgorithm="NativePRNG" kexHeader="true">
<pooling-profile exhaustedAction="WHEN_EXHAUSTED_WAIT" maxActive="7" maxIdle="3" maxWait="5000"/>
</sftp:connection>
</sftp:config>

<sftp:config name="strict-KEX-disabled-config">
<sftp:connection username="mule" password="test" host="localhost" port="${sftp.listener.port}" prngAlgorithm="SHA1PRNG" kexHeader="false">
<sftp:connection username="mule" password="test" host="localhost" port="${sftp.listener.port}" prngAlgorithm="NativePRNG" kexHeader="false">
<pooling-profile exhaustedAction="WHEN_EXHAUSTED_WAIT" maxActive="7" maxIdle="3" maxWait="5000"/>
</sftp:connection>
</sftp:config>
Expand All @@ -52,7 +52,7 @@
host="openssh${sftp.proxy.auth}"
port="2222"
workingDir="/config"
prngAlgorithm="SHA1PRNG"
prngAlgorithm="NativePRNG"
connectionTimeout="200">
<pooling-profile exhaustedAction="WHEN_EXHAUSTED_WAIT" maxActive="7" maxIdle="3" maxWait="5000"/>
<sftp:sftp-proxy-config host="localhost"
Expand All @@ -65,28 +65,28 @@

<sftp:config name="config-invalid-password">
<sftp:connection username="muletest1" password="INVALID" host="localhost" port="${sftp.server.port}"
workingDir="/" prngAlgorithm="SHA1PRNG">
workingDir="/" prngAlgorithm="NativePRNG">
<pooling-profile exhaustedAction="WHEN_EXHAUSTED_WAIT" maxActive="7" maxIdle="3" maxWait="5000"/>
</sftp:connection>
</sftp:config>

<sftp:config name="config-no-username">
<sftp:connection password="INVALID" host="localhost" port="${sftp.server.port}"
workingDir="/" prngAlgorithm="SHA1PRNG">
workingDir="/" prngAlgorithm="NativePRNG">
<pooling-profile exhaustedAction="WHEN_EXHAUSTED_WAIT" maxActive="7" maxIdle="3" maxWait="5000"/>
</sftp:connection>
</sftp:config>

<sftp:config name="config-with-identity-file-not-exists">
<sftp:connection username="muletest1" password="muletest1" host="localhost" port="${sftp.server.port}" identityFile="a-file-that-doesnt-exist"
workingDir="/" prngAlgorithm="SHA1PRNG">
workingDir="/" prngAlgorithm="NativePRNG">
<pooling-profile exhaustedAction="WHEN_EXHAUSTED_WAIT" maxActive="7" maxIdle="3" maxWait="5000"/>
</sftp:connection>
</sftp:config>

<sftp:config name="config-with-reconnection">
<sftp:connection username="muletest1" password="muletest1" host="localhost" port="${sftp.server.port}"
workingDir="/" prngAlgorithm="SHA1PRNG">
workingDir="/" prngAlgorithm="NativePRNG">
<reconnection >
<reconnect count="20" frequency="1000"/>
</reconnection>
Expand All @@ -96,7 +96,7 @@

<sftp:config name="config-without-working-dir">
<sftp:connection username="muletest1" password="muletest1" host="localhost" port="${sftp.server.port}"
prngAlgorithm="SHA1PRNG">
prngAlgorithm="NativePRNG">
<pooling-profile exhaustedAction="WHEN_EXHAUSTED_WAIT" maxActive="7" maxIdle="3" maxWait="5000"/>
</sftp:connection>
</sftp:config>
Expand All @@ -108,26 +108,26 @@

<sftp:config name="config-docker">
<sftp:connection username="mule" password="test" host="localhost" port="${sftp.listener.port}"
workingDir="/config" prngAlgorithm="SHA1PRNG">
workingDir="/config" prngAlgorithm="NativePRNG">
<pooling-profile exhaustedAction="WHEN_EXHAUSTED_WAIT" maxActive="7" maxIdle="3" maxWait="5000"/>
</sftp:connection>
</sftp:config>

<sftp:config name="config-docker-with-home-directory">
<sftp:connection username="mule" password="test" host="localhost" port="${sftp.listener.port}"
workingDir="/config" prngAlgorithm="SHA1PRNG">
workingDir="/config" prngAlgorithm="NativePRNG">
<pooling-profile exhaustedAction="WHEN_EXHAUSTED_WAIT" maxActive="7" maxIdle="3" maxWait="5000"/>
</sftp:connection>
</sftp:config>

<sftp:config name="config-docker-with-private-directory">
<sftp:connection username="mule" password="test" host="localhost" port="${sftp.listener.port}"
workingDir="/" prngAlgorithm="SHA1PRNG">
workingDir="/" prngAlgorithm="NativePRNG">
<pooling-profile exhaustedAction="WHEN_EXHAUSTED_WAIT" maxActive="7" maxIdle="3" maxWait="5000"/>
</sftp:connection>
</sftp:config>
<sftp:config name="config-docker-without-home-directory">
<sftp:connection username="mule" password="test" host="localhost" port="${sftp.listener.port}" prngAlgorithm="SHA1PRNG">
<sftp:connection username="mule" password="test" host="localhost" port="${sftp.listener.port}" prngAlgorithm="NativePRNG">
<reconnection>
<reconnect count="20" frequency="1000"/>
</reconnection>
Expand All @@ -151,14 +151,14 @@

<sftp:config name="config-invalid-folder">
<sftp:connection username="muletest1" password="muletest1" host="localhost" port="${sftp.server.port}"
workingDir="/invalid" prngAlgorithm="SHA1PRNG">
workingDir="/invalid" prngAlgorithm="NativePRNG">
<pooling-profile exhaustedAction="WHEN_EXHAUSTED_WAIT" maxActive="7" maxIdle="3" maxWait="5000"/>
</sftp:connection>
</sftp:config>

<sftp:config name="config-docker-with-id-file">
<sftp:connection username="mule" password="test" host="localhost" port="${sftp.listener.port}"
workingDir="/config" prngAlgorithm="SHA1PRNG"
workingDir="/config" prngAlgorithm="NativePRNG"
identityFile="id_ed25519" passphrase="mulesoft">
<pooling-profile exhaustedAction="WHEN_EXHAUSTED_WAIT" maxActive="7" maxIdle="3" maxWait="5000"/>
</sftp:connection>
Expand Down
4 changes: 2 additions & 2 deletions src/test/munit/proxy/sftp-proxy-socks-test-case.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
host="${sftp.host}"
port="${sftp.port}"
workingDir="/"
prngAlgorithm="SHA1PRNG"
prngAlgorithm="NativePRNG"
connectionTimeout="200">
<sftp:sftp-proxy-config host="localhost"
port="${proxy.port}"
Expand All @@ -55,7 +55,7 @@
host="local-error"
port="${sftp.port}"
workingDir="/"
prngAlgorithm="SHA1PRNG"
prngAlgorithm="NativePRNG"
connectionTimeout="200">
<sftp:sftp-proxy-config host="localhost"
port="${proxy.port}"
Expand Down
4 changes: 2 additions & 2 deletions src/test/munit/sftp-id-file-connection-test-case.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@

<sftp:config name="config-docker-with-id-file-1">
<sftp:connection username="mule" password="test" host="localhost" port="${sftp.listener.port}"
workingDir="/config" prngAlgorithm="SHA1PRNG"
workingDir="/config" prngAlgorithm="NativePRNG"
identityFile="id_ed25519" passphrase="mulesoft">
<pooling-profile exhaustedAction="WHEN_EXHAUSTED_WAIT" maxActive="7" maxIdle="3" maxWait="5000"/>
</sftp:connection>
</sftp:config>

<sftp:config name="config-docker-with-id-file-2">
<sftp:connection username="mule" password="test" host="localhost" port="${sftp.listener.port}"
workingDir="/config" prngAlgorithm="SHA1PRNG"
workingDir="/config" prngAlgorithm="NativePRNG"
identityFile="id_ed25519" passphrase="mulesoft">
<pooling-profile exhaustedAction="WHEN_EXHAUSTED_WAIT" maxActive="7" maxIdle="3" maxWait="5000"/>
</sftp:connection>
Expand Down
4 changes: 2 additions & 2 deletions src/test/munit/sftp-proxy-test-case.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
host="openssh${sftp.proxy.auth}"
port="2222"
workingDir="/config"
prngAlgorithm="SHA1PRNG"
prngAlgorithm="NativePRNG"
connectionTimeout="200">
<sftp:sftp-proxy-config host="localhost"
port="${squid.port.auth}"
Expand All @@ -46,7 +46,7 @@
host="local-error"
port="${sftp.proxy.auth}"
workingDir="/config"
prngAlgorithm="SHA1PRNG"
prngAlgorithm="NativePRNG"
connectionTimeout="200">
<sftp:sftp-proxy-config host="localhost"
port="${squid.port.auth}"
Expand Down
2 changes: 1 addition & 1 deletion src/test/munit/sftp-read-test-case.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

<sftp:config name="config-with-limited-pool">
<sftp:connection username="muletest1" password="muletest1" host="localhost" port="${sftp.server.port}"
workingDir="/" prngAlgorithm="SHA1PRNG">
workingDir="/" prngAlgorithm="NativePRNG">
<pooling-profile exhaustedAction="WHEN_EXHAUSTED_WAIT" maxActive="1" maxIdle="1" maxWait="5000"/>
</sftp:connection>
</sftp:config>
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/sftp-connection-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
http://www.mulesoft.org/schema/mule/sftp http://www.mulesoft.org/schema/mule/sftp/current/mule-sftp.xsd">

<sftp:config name="config">
<sftp:connection username="muletest1" password="muletest1" host="localhost" port="${SFTP_PORT}" workingDir="${workingDir}" prngAlgorithm="SHA1PRNG" >
<sftp:connection username="muletest1" password="muletest1" host="localhost" port="${SFTP_PORT}" workingDir="${workingDir}" prngAlgorithm="NativePRNG" >
<pooling-profile exhaustedAction="WHEN_EXHAUSTED_WAIT" maxActive="3" maxIdle="3" maxWait="1000"/>
</sftp:connection>
</sftp:config>
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/sftp-connection-with-identity-file.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
http://www.mulesoft.org/schema/mule/sftp http://www.mulesoft.org/schema/mule/sftp/current/mule-sftp.xsd">

<sftp:config name="config">
<sftp:connection username="muletest1" password="muletest1" host="localhost" port="${SFTP_PORT}" workingDir="${workingDir}" identityFile="sftp-test-key" prngAlgorithm="SHA1PRNG">
<sftp:connection username="muletest1" password="muletest1" host="localhost" port="${SFTP_PORT}" workingDir="${workingDir}" identityFile="sftp-test-key" prngAlgorithm="NativePRNG">
<pooling-profile exhaustedAction="WHEN_EXHAUSTED_WAIT" maxActive="3" maxIdle="3" maxWait="1000"/>
</sftp:connection>
</sftp:config>
Expand Down
14 changes: 7 additions & 7 deletions src/test/resources/sftp-negative-connectivity-test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@
http://www.mulesoft.org/schema/mule/sftp http://www.mulesoft.org/schema/mule/sftp/current/mule-sftp.xsd">

<sftp:config name="sftpConfigInvalidCredentials">
<sftp:connection username="invalidUser" password="invalidPassword" host="localhost" port="${SFTP_PORT}" workingDir="${workingDir}" prngAlgorithm="SHA1PRNG"/>
<sftp:connection username="invalidUser" password="invalidPassword" host="localhost" port="${SFTP_PORT}" workingDir="${workingDir}" prngAlgorithm="NativePRNG"/>
</sftp:config>

<sftp:config name="sftpConfigConnectionTimeout">
<sftp:connection username="muletest1" password="muletest1" host="google.com" port="${SFTP_PORT}" workingDir="${workingDir}" connectionTimeout="1" connectionTimeoutUnit="MILLISECONDS" prngAlgorithm="SHA1PRNG"/>
<sftp:connection username="muletest1" password="muletest1" host="google.com" port="${SFTP_PORT}" workingDir="${workingDir}" connectionTimeout="1" connectionTimeoutUnit="MILLISECONDS" prngAlgorithm="NativePRNG"/>
</sftp:config>

<sftp:config name="sftpConfigConnectionRefused">
<sftp:connection username="muletest1" password="muletest1" host="localhost" port="8888" workingDir="${workingDir}" prngAlgorithm="SHA1PRNG"/>
<sftp:connection username="muletest1" password="muletest1" host="localhost" port="8888" workingDir="${workingDir}" prngAlgorithm="NativePRNG"/>
</sftp:config>

<sftp:config name="sftpConfigMissingCredentials">
<sftp:connection host="localhost" port="${SFTP_PORT}" workingDir="${workingDir}" prngAlgorithm="SHA1PRNG"/>
<sftp:connection host="localhost" port="${SFTP_PORT}" workingDir="${workingDir}" prngAlgorithm="NativePRNG"/>
</sftp:config>

<sftp:config name="sftpConfigUnknownHost">
<sftp:connection username="anonymous" password="password" host="dsadsadas" port="${SFTP_PORT}" workingDir="${workingDir}" prngAlgorithm="SHA1PRNG"/>
<sftp:connection username="anonymous" password="password" host="dsadsadas" port="${SFTP_PORT}" workingDir="${workingDir}" prngAlgorithm="NativePRNG"/>
</sftp:config>

<sftp:config name="sftpConfigFirstConnection">
<sftp:connection username="limitedUsed" password="limitedUsed" host="localhost" port="${SFTP_PORT}" workingDir="${workingDir}" prngAlgorithm="SHA1PRNG"/>
<sftp:connection username="limitedUsed" password="limitedUsed" host="localhost" port="${SFTP_PORT}" workingDir="${workingDir}" prngAlgorithm="NativePRNG"/>
</sftp:config>

<sftp:config name="sftpConfigServiceUnavailable">
<sftp:connection username="limitedUsed" password="limitedUsed" host="localhost" port="${SFTP_PORT}" workingDir="${workingDir}" prngAlgorithm="SHA1PRNG"/>
<sftp:connection username="limitedUsed" password="limitedUsed" host="localhost" port="${SFTP_PORT}" workingDir="${workingDir}" prngAlgorithm="NativePRNG"/>
</sftp:config>

</mule>

1 comment on commit ab366f5

@sabecasissf
Copy link

Choose a reason for hiding this comment

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

Hi Sunny, since SHA1PRNG is still going to be around while deprecated, wouldn't it be good to leave a few tests using that option as well?

Please sign in to comment.