├── README.md ├── .github ├── CODEOWNERS └── workflows │ ├── pull_request_ubuntu_build.yml │ └── push_ubuntu_build.yml ├── .gitignore ├── issue_template.md ├── jsch ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── jcraft │ └── jsch │ ├── Random.java │ ├── DHGEX256.java │ ├── PBKDF.java │ ├── DHEC256.java │ ├── DHEC384.java │ ├── DHEC521.java │ ├── jce │ ├── SignatureECDSA256.java │ ├── SignatureECDSA384.java │ ├── SignatureECDSA521.java │ ├── ECDH256.java │ ├── ECDH384.java │ ├── ECDH521.java │ ├── HMACMD5.java │ ├── HMACSHA1.java │ ├── HMACSHA256.java │ ├── HMACSHA512.java │ ├── HMACMD596.java │ ├── HMACSHA196.java │ ├── SHA384.java │ ├── SHA512.java │ ├── MD5.java │ ├── SHA1.java │ ├── SHA256.java │ ├── PBKDF.java │ ├── KeyPairGenDSA.java │ ├── ARCFOUR.java │ ├── HMAC.java │ ├── ARCFOUR128.java │ ├── ARCFOUR256.java │ ├── AES192CBC.java │ ├── AES192CTR.java │ ├── AES256CBC.java │ ├── AES256CTR.java │ ├── AES128CBC.java │ ├── AES128CTR.java │ ├── BlowfishCBC.java │ ├── KeyPairGenRSA.java │ ├── SignatureRSA.java │ └── Random.java │ ├── KeyPairGenECDSA.java │ ├── SignatureECDSA.java │ ├── SignatureRSA.java │ ├── HASH.java │ ├── KeyPairGenDSA.java │ ├── Signature.java │ ├── ForwardedTCPIPDaemon.java │ ├── ServerSocketFactory.java │ ├── SignatureDSA.java │ ├── ECDH.java │ ├── UIKeyboardInteractive.java │ ├── MAC.java │ ├── KeyPairGenRSA.java │ ├── UserInfo.java │ ├── Compression.java │ ├── SftpProgressMonitor.java │ ├── Proxy.java │ ├── GSSContext.java │ ├── Cipher.java │ ├── SocketFactory.java │ ├── JSchAuthCancelException.java │ ├── DH.java │ ├── JSchPartialAuthException.java │ ├── CipherNone.java │ ├── JSchException.java │ ├── jcraft │ ├── HMACMD5.java │ ├── HMACMD596.java │ ├── HMACSHA1.java │ └── HMACSHA196.java │ ├── SftpException.java │ ├── RequestSftp.java │ ├── RequestSignal.java │ ├── Logger.java │ ├── RequestShell.java │ ├── RequestEnv.java │ ├── RequestAgentForwarding.java │ ├── ConfigRepository.java │ ├── RequestSubsystem.java │ ├── RequestExec.java │ ├── UserAuth.java │ ├── ChannelShell.java │ ├── Request.java │ ├── RequestX11.java │ ├── RequestWindowChange.java │ ├── RequestPtyReq.java │ ├── ChannelExec.java │ ├── Identity.java │ └── ChannelSubsystem.java ├── LICENSE.txt ├── examples ├── ChangePassphrase.java └── KeyGen.java ├── pull_request_template.md └── orbit └── pom.xml /README.md: -------------------------------------------------------------------------------- 1 | # wso2-jsch 2 | WSO2 JSCh (Java Secure Channel) 3 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Lines starting with '#' are comments. 2 | # Each line is a file pattern followed by one or more owners. 3 | 4 | # See: https://help.github.com/articles/about-codeowners/ 5 | 6 | # These owners will be the default owners for everything in the repo. 7 | * @chanikag 8 | -------------------------------------------------------------------------------- /.github/workflows/pull_request_ubuntu_build.yml: -------------------------------------------------------------------------------- 1 | name: CI - Pull request - Ubuntu 2 | 3 | on: 4 | pull_request: 5 | branches: [ "main" ] 6 | 7 | jobs: 8 | build: 9 | 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/checkout@v4 14 | - name: Set up JDK 11 15 | uses: actions/setup-java@v4 16 | with: 17 | java-version: '11' 18 | distribution: 'temurin' 19 | cache: maven 20 | - name: Build with Maven 21 | run: mvn clean install 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | 25 | # ignore Intellij-IDEA files 26 | *.iml 27 | *.ipr 28 | *.iws 29 | *.classpath 30 | *.settings 31 | *.project 32 | *.idea 33 | 34 | # ignore target directories 35 | target/ 36 | -------------------------------------------------------------------------------- /.github/workflows/push_ubuntu_build.yml: -------------------------------------------------------------------------------- 1 | name: CI - Push request - Ubuntu 2 | 3 | on: 4 | push: 5 | branches: [ "main" ] 6 | 7 | jobs: 8 | build: 9 | 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/checkout@v4 14 | - name: Set up JDK 11 15 | uses: actions/setup-java@v4 16 | with: 17 | java-version: '11' 18 | distribution: 'temurin' 19 | cache: maven 20 | - name: Build with Maven 21 | run: mvn clean install 22 | - name: Upload test coverage to Codecov 23 | uses: codecov/codecov-action@v4.0.1 24 | with: 25 | flags: unit_tests 26 | token: ${{ secrets.CODECOV_TOKEN }} 27 | -------------------------------------------------------------------------------- /issue_template.md: -------------------------------------------------------------------------------- 1 | **Description:** 2 | 3 | 4 | **Suggested Labels:** 5 | 6 | 7 | **Suggested Assignees:** 8 | 9 | 10 | **Affected Product Version:** 11 | 12 | **OS, DB, other environment details and versions:** 13 | 14 | **Steps to reproduce:** 15 | 16 | 17 | **Related Issues:** 18 | -------------------------------------------------------------------------------- /jsch/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.wso2.com.jcraft 4 | jsch-project 5 | 0.1.55-wso2v5-SNAPSHOT 6 | ../pom.xml 7 | 8 | 4.0.0 9 | org.wso2.com.jcraft 10 | jsch 11 | jar 12 | 0.1.55-wso2v5-SNAPSHOT 13 | JSch 14 | 15 | 16 | 17 | com.jcraft 18 | jzlib 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | JSch 0.0.* was released under the GNU LGPL license. Later, we have switched 2 | over to a BSD-style license. 3 | 4 | ------------------------------------------------------------------------------ 5 | Copyright (c) 2002-2015 Atsuhiko Yamanaka, JCraft,Inc. 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, 12 | this list of conditions and the following disclaimer. 13 | 14 | 2. Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in 16 | the documentation and/or other materials provided with the distribution. 17 | 18 | 3. The names of the authors may not be used to endorse or promote products 19 | derived from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 22 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 23 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 24 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 27 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/Random.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public interface Random{ 33 | void fill(byte[] foo, int start, int len); 34 | } 35 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/DHGEX256.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public class DHGEX256 extends DHGEX { 33 | DHGEX256(){ 34 | hash="sha-256"; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/PBKDF.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2013-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public interface PBKDF { 33 | byte[] getKey(byte[] pass, byte[] salt, int iteration, int size); 34 | } 35 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/DHEC256.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2015-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public class DHEC256 extends DHECN { 33 | public DHEC256(){ 34 | sha_name="sha-256"; 35 | key_size=256; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/DHEC384.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2015-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public class DHEC384 extends DHECN { 33 | public DHEC384(){ 34 | sha_name="sha-384"; 35 | key_size=384; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/DHEC521.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2015-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public class DHEC521 extends DHECN { 33 | public DHEC521(){ 34 | sha_name="sha-512"; 35 | key_size=521; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/SignatureECDSA256.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2015-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | public class SignatureECDSA256 extends SignatureECDSAN { 33 | String getName() { 34 | return "ecdsa-sha2-nistp256"; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/SignatureECDSA384.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2015-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | public class SignatureECDSA384 extends SignatureECDSAN { 33 | String getName() { 34 | return "ecdsa-sha2-nistp384"; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/SignatureECDSA521.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2015-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | public class SignatureECDSA521 extends SignatureECDSAN { 33 | String getName() { 34 | return "ecdsa-sha2-nistp521"; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/KeyPairGenECDSA.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2015-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public interface KeyPairGenECDSA{ 33 | void init(int key_size) throws Exception; 34 | byte[] getD(); 35 | byte[] getR(); 36 | byte[] getS(); 37 | } 38 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/ECDH256.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2015-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | public class ECDH256 extends ECDHN implements com.jcraft.jsch.ECDH { 33 | public void init() throws Exception { 34 | super.init(256); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/ECDH384.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2015-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | public class ECDH384 extends ECDHN implements com.jcraft.jsch.ECDH { 33 | public void init() throws Exception { 34 | super.init(384); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/ECDH521.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2015-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | public class ECDH521 extends ECDHN implements com.jcraft.jsch.ECDH { 33 | public void init() throws Exception { 34 | super.init(521); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/HMACMD5.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | public class HMACMD5 extends HMAC { 33 | public HMACMD5(){ 34 | name = "hmac-md5"; 35 | bsize = 16; 36 | algorithm = "HmacMD5"; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/HMACSHA1.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | public class HMACSHA1 extends HMAC { 33 | public HMACSHA1(){ 34 | name = "hmac-sha1"; 35 | bsize = 20; 36 | algorithm = "HmacSHA1"; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/SignatureECDSA.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2015-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public interface SignatureECDSA extends Signature { 33 | void setPubKey(byte[] r, byte[] s) throws Exception; 34 | void setPrvKey(byte[] s) throws Exception; 35 | } 36 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/SignatureRSA.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public interface SignatureRSA extends Signature { 33 | void setPubKey(byte[] e, byte[] n) throws Exception; 34 | void setPrvKey(byte[] d, byte[] n) throws Exception; 35 | } 36 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/HMACSHA256.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2012-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | public class HMACSHA256 extends HMAC { 33 | public HMACSHA256(){ 34 | name = "hmac-sha2-256"; 35 | bsize = 32; 36 | algorithm = "HmacSHA256"; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/HMACSHA512.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2012-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | public class HMACSHA512 extends HMAC { 33 | public HMACSHA512(){ 34 | name = "hmac-sha2-512"; 35 | bsize = 64; 36 | algorithm = "HmacSHA512"; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/HASH.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public interface HASH{ 33 | void init() throws Exception; 34 | int getBlockSize(); 35 | void update(byte[] foo, int start, int len) throws Exception; 36 | byte[] digest() throws Exception; 37 | } 38 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/KeyPairGenDSA.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public interface KeyPairGenDSA{ 33 | void init(int key_size) throws Exception; 34 | byte[] getX(); 35 | byte[] getY(); 36 | byte[] getP(); 37 | byte[] getQ(); 38 | byte[] getG(); 39 | } 40 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/Signature.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2012-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public interface Signature{ 33 | void init() throws Exception; 34 | void update(byte[] H) throws Exception; 35 | boolean verify(byte[] sig) throws Exception; 36 | byte[] sign() throws Exception; 37 | } 38 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/ForwardedTCPIPDaemon.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | import java.io.*; 32 | 33 | public interface ForwardedTCPIPDaemon extends Runnable{ 34 | void setChannel(ChannelForwardedTCPIP channel, InputStream in, OutputStream out); 35 | void setArg(Object[] arg); 36 | } 37 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/ServerSocketFactory.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | import java.net.*; 33 | import java.io.*; 34 | 35 | public interface ServerSocketFactory{ 36 | public ServerSocket createServerSocket(int port, int backlog, InetAddress bindAddr) throws IOException; 37 | } 38 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/SignatureDSA.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public interface SignatureDSA extends Signature { 33 | void setPubKey(byte[] y, byte[] p, byte[] q, byte[] g) throws Exception; 34 | void setPrvKey(byte[] x, byte[] p, byte[] q, byte[] g) throws Exception; 35 | } 36 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/ECDH.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2015-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public interface ECDH { 33 | void init(int size) throws Exception; 34 | byte[] getSecret(byte[] r, byte[] s) throws Exception; 35 | byte[] getQ() throws Exception; 36 | boolean validate(byte[] r, byte[] s) throws Exception; 37 | } 38 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/UIKeyboardInteractive.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public interface UIKeyboardInteractive{ 33 | String[] promptKeyboardInteractive(String destination, 34 | String name, 35 | String instruction, 36 | String[] prompt, 37 | boolean[] echo); 38 | } 39 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/MAC.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public interface MAC{ 33 | String getName(); 34 | int getBlockSize(); 35 | void init(byte[] key) throws Exception; 36 | void update(byte[] foo, int start, int len); 37 | void update(int foo); 38 | void doFinal(byte[] buf, int offset); 39 | } 40 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/KeyPairGenRSA.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public interface KeyPairGenRSA{ 33 | void init(int key_size) throws Exception; 34 | byte[] getD(); 35 | byte[] getE(); 36 | byte[] getN(); 37 | 38 | byte[] getC(); 39 | byte[] getEP(); 40 | byte[] getEQ(); 41 | byte[] getP(); 42 | byte[] getQ(); 43 | } 44 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/UserInfo.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public interface UserInfo{ 33 | String getPassphrase(); 34 | String getPassword(); 35 | boolean promptPassword(String message); 36 | boolean promptPassphrase(String message); 37 | boolean promptYesNo(String message); 38 | void showMessage(String message); 39 | } 40 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/Compression.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public interface Compression{ 33 | static public final int INFLATER=0; 34 | static public final int DEFLATER=1; 35 | void init(int type, int level); 36 | byte[] compress(byte[] buf, int start, int[] len); 37 | byte[] uncompress(byte[] buf, int start, int[] len); 38 | } 39 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/SftpProgressMonitor.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public interface SftpProgressMonitor{ 33 | public static final int PUT=0; 34 | public static final int GET=1; 35 | public static final long UNKNOWN_SIZE = -1L; 36 | void init(int op, String src, String dest, long max); 37 | boolean count(long count); 38 | void end(); 39 | } 40 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/Proxy.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | import java.io.*; 33 | import java.net.Socket; 34 | public interface Proxy{ 35 | void connect(SocketFactory socket_factory, String host, int port, int timeout) throws Exception; 36 | InputStream getInputStream(); 37 | OutputStream getOutputStream(); 38 | Socket getSocket(); 39 | void close(); 40 | } 41 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/GSSContext.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2004-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public interface GSSContext{ 33 | public void create(String user, String host) throws JSchException; 34 | public boolean isEstablished(); 35 | public byte[] init(byte[] token, int s, int l) throws JSchException; 36 | public byte[] getMIC(byte[] message, int s, int l); 37 | public void dispose(); 38 | } 39 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/Cipher.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public interface Cipher{ 33 | static int ENCRYPT_MODE=0; 34 | static int DECRYPT_MODE=1; 35 | int getIVSize(); 36 | int getBlockSize(); 37 | void init(int mode, byte[] key, byte[] iv) throws Exception; 38 | void update(byte[] foo, int s1, int len, byte[] bar, int s2) throws Exception; 39 | boolean isCBC(); 40 | } 41 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/SocketFactory.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | import java.net.*; 33 | import java.io.*; 34 | 35 | public interface SocketFactory{ 36 | public Socket createSocket(String host, int port)throws IOException, 37 | UnknownHostException; 38 | public InputStream getInputStream(Socket socket)throws IOException; 39 | public OutputStream getOutputStream(Socket socket)throws IOException; 40 | } 41 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/JSchAuthCancelException.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | class JSchAuthCancelException extends JSchException{ 33 | //private static final long serialVersionUID=3204965907117900987L; 34 | String method; 35 | JSchAuthCancelException () { 36 | super(); 37 | } 38 | JSchAuthCancelException (String s) { 39 | super(s); 40 | this.method=s; 41 | } 42 | public String getMethod(){ 43 | return method; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/DH.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public interface DH{ 33 | void init() throws Exception; 34 | void setP(byte[] p); 35 | void setG(byte[] g); 36 | byte[] getE() throws Exception; 37 | void setF(byte[] f); 38 | byte[] getK() throws Exception; 39 | 40 | // checkRange() will check if e and f are in [1,p-1] 41 | // as defined at https://tools.ietf.org/html/rfc4253#section-8 42 | void checkRange() throws Exception; 43 | } 44 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/HMACMD596.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | public class HMACMD596 extends HMACMD5 { 33 | public HMACMD596(){ 34 | name="hmac-md5-96"; 35 | } 36 | 37 | public int getBlockSize(){ 38 | return 12; 39 | }; 40 | 41 | private final byte[] _buf16 = new byte[16]; 42 | public void doFinal(byte[] buf, int offset){ 43 | super.doFinal(_buf16, 0); 44 | System.arraycopy(_buf16, 0, buf, offset, 12); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/HMACSHA196.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | public class HMACSHA196 extends HMACSHA1 { 33 | 34 | public HMACSHA196(){ 35 | name = "hmac-sha1-96"; 36 | } 37 | 38 | public int getBlockSize(){ 39 | return 12; 40 | }; 41 | 42 | private final byte[] _buf20 = new byte[20]; 43 | public void doFinal(byte[] buf, int offset){ 44 | super.doFinal(_buf20, 0); 45 | System.arraycopy(_buf20, 0, buf, offset, 12); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/JSchPartialAuthException.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | class JSchPartialAuthException extends JSchException{ 33 | //private static final long serialVersionUID=-378849862323360367L; 34 | String methods; 35 | public JSchPartialAuthException () { 36 | super(); 37 | } 38 | public JSchPartialAuthException (String s) { 39 | super(s); 40 | this.methods=s; 41 | } 42 | public String getMethods(){ 43 | return methods; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/CipherNone.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public class CipherNone implements Cipher{ 33 | private static final int ivsize=8; 34 | private static final int bsize=16; 35 | public int getIVSize(){return ivsize;} 36 | public int getBlockSize(){return bsize;} 37 | public void init(int mode, byte[] key, byte[] iv) throws Exception{ 38 | } 39 | public void update(byte[] foo, int s1, int len, byte[] bar, int s2) throws Exception{ 40 | } 41 | public boolean isCBC(){return false; } 42 | } 43 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/JSchException.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public class JSchException extends Exception{ 33 | //private static final long serialVersionUID=-1319309923966731989L; 34 | private Throwable cause=null; 35 | public JSchException () { 36 | super(); 37 | } 38 | public JSchException (String s) { 39 | super(s); 40 | } 41 | public JSchException (String s, Throwable e) { 42 | super(s); 43 | this.cause=e; 44 | } 45 | public Throwable getCause(){ 46 | return this.cause; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jcraft/HMACMD5.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2006-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jcraft; 31 | 32 | import com.jcraft.jsch.MAC; 33 | import java.security.*; 34 | 35 | public class HMACMD5 extends HMAC implements MAC{ 36 | private static final String name="hmac-md5"; 37 | 38 | public HMACMD5(){ 39 | super(); 40 | MessageDigest md=null; 41 | try{ md=MessageDigest.getInstance("MD5"); } 42 | catch(Exception e){ 43 | System.err.println(e); 44 | } 45 | setH(md); 46 | } 47 | 48 | public String getName(){ 49 | return name; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jcraft/HMACMD596.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2006-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jcraft; 31 | 32 | public class HMACMD596 extends HMACMD5{ 33 | 34 | private static final String name="hmac-md5-96"; 35 | private static final int BSIZE=12; 36 | 37 | public int getBlockSize(){return BSIZE;}; 38 | 39 | private final byte[] _buf16=new byte[16]; 40 | public void doFinal(byte[] buf, int offset){ 41 | super.doFinal(_buf16, 0); 42 | System.arraycopy(_buf16, 0, buf, offset, BSIZE); 43 | } 44 | 45 | public String getName(){ 46 | return name; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jcraft/HMACSHA1.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2006-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jcraft; 31 | 32 | import com.jcraft.jsch.MAC; 33 | import java.security.*; 34 | 35 | public class HMACSHA1 extends HMAC implements MAC{ 36 | private static final String name="hmac-sha1"; 37 | 38 | public HMACSHA1(){ 39 | super(); 40 | MessageDigest md=null; 41 | try{ md=MessageDigest.getInstance("SHA-1"); } 42 | catch(Exception e){ 43 | System.err.println(e); 44 | } 45 | setH(md); 46 | } 47 | 48 | public String getName(){ 49 | return name; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jcraft/HMACSHA196.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2006-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jcraft; 31 | 32 | public class HMACSHA196 extends HMACSHA1{ 33 | 34 | private static final String name="hmac-sha1-96"; 35 | private static final int BSIZE=12; 36 | 37 | public int getBlockSize(){return BSIZE;}; 38 | 39 | private final byte[] _buf16=new byte[20]; 40 | public void doFinal(byte[] buf, int offset){ 41 | super.doFinal(_buf16, 0); 42 | System.arraycopy(_buf16, 0, buf, offset, BSIZE); 43 | } 44 | 45 | public String getName(){ 46 | return name; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/SHA384.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2015-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | import java.security.*; 33 | 34 | public class SHA384 implements com.jcraft.jsch.HASH { 35 | MessageDigest md; 36 | public int getBlockSize(){return 48;} 37 | public void init() throws Exception { 38 | try{ md=MessageDigest.getInstance("SHA-384"); } 39 | catch(Exception e){ 40 | System.err.println(e); 41 | } 42 | } 43 | public void update(byte[] foo, int start, int len) throws Exception { 44 | md.update(foo, start, len); 45 | } 46 | public byte[] digest() throws Exception { 47 | return md.digest(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/SHA512.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2015-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | import java.security.*; 33 | 34 | public class SHA512 implements com.jcraft.jsch.HASH { 35 | MessageDigest md; 36 | public int getBlockSize(){return 64;} 37 | public void init() throws Exception { 38 | try{ md=MessageDigest.getInstance("SHA-512"); } 39 | catch(Exception e){ 40 | System.err.println(e); 41 | } 42 | } 43 | public void update(byte[] foo, int start, int len) throws Exception { 44 | md.update(foo, start, len); 45 | } 46 | public byte[] digest() throws Exception { 47 | return md.digest(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/MD5.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | import com.jcraft.jsch.HASH; 33 | 34 | import java.security.*; 35 | 36 | public class MD5 implements HASH{ 37 | MessageDigest md; 38 | public int getBlockSize(){return 16;} 39 | public void init() throws Exception{ 40 | try{ md=MessageDigest.getInstance("MD5"); } 41 | catch(Exception e){ 42 | System.err.println(e); 43 | } 44 | } 45 | public void update(byte[] foo, int start, int len) throws Exception{ 46 | md.update(foo, start, len); 47 | } 48 | public byte[] digest() throws Exception{ 49 | return md.digest(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/SHA1.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | import com.jcraft.jsch.HASH; 33 | 34 | import java.security.*; 35 | 36 | public class SHA1 implements HASH{ 37 | MessageDigest md; 38 | public int getBlockSize(){return 20;} 39 | public void init() throws Exception{ 40 | try{ md=MessageDigest.getInstance("SHA-1"); } 41 | catch(Exception e){ 42 | System.err.println(e); 43 | } 44 | } 45 | public void update(byte[] foo, int start, int len) throws Exception{ 46 | md.update(foo, start, len); 47 | } 48 | public byte[] digest() throws Exception{ 49 | return md.digest(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/SHA256.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | import com.jcraft.jsch.HASH; 33 | 34 | import java.security.*; 35 | 36 | public class SHA256 implements HASH { 37 | MessageDigest md; 38 | public int getBlockSize(){return 32;} 39 | public void init() throws Exception { 40 | try{ md=MessageDigest.getInstance("SHA-256"); } 41 | catch(Exception e){ 42 | System.err.println(e); 43 | } 44 | } 45 | public void update(byte[] foo, int start, int len) throws Exception { 46 | md.update(foo, start, len); 47 | } 48 | public byte[] digest() throws Exception { 49 | return md.digest(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/SftpException.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public class SftpException extends Exception{ 33 | //private static final long serialVersionUID=-5616888495583253811L; 34 | public int id; 35 | private Throwable cause=null; 36 | public SftpException (int id, String message) { 37 | super(message); 38 | this.id=id; 39 | } 40 | public SftpException (int id, String message, Throwable e) { 41 | super(message); 42 | this.id=id; 43 | this.cause=e; 44 | } 45 | public String toString(){ 46 | return id+": "+getMessage(); 47 | } 48 | public Throwable getCause(){ 49 | return this.cause; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/RequestSftp.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public class RequestSftp extends Request{ 33 | RequestSftp(){ 34 | setReply(true); 35 | } 36 | public void request(Session session, Channel channel) throws Exception{ 37 | super.request(session, channel); 38 | 39 | Buffer buf=new Buffer(); 40 | Packet packet=new Packet(buf); 41 | packet.reset(); 42 | buf.putByte((byte)Session.SSH_MSG_CHANNEL_REQUEST); 43 | buf.putInt(channel.getRecipient()); 44 | buf.putString(Util.str2byte("subsystem")); 45 | buf.putByte((byte)(waitForReply() ? 1 : 0)); 46 | buf.putString(Util.str2byte("sftp")); 47 | write(packet); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/RequestSignal.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | class RequestSignal extends Request{ 33 | private String signal="KILL"; 34 | public void setSignal(String foo){ signal=foo; } 35 | public void request(Session session, Channel channel) throws Exception{ 36 | super.request(session, channel); 37 | 38 | Buffer buf=new Buffer(); 39 | Packet packet=new Packet(buf); 40 | 41 | packet.reset(); 42 | buf.putByte((byte) Session.SSH_MSG_CHANNEL_REQUEST); 43 | buf.putInt(channel.getRecipient()); 44 | buf.putString(Util.str2byte("signal")); 45 | buf.putByte((byte)(waitForReply() ? 1 : 0)); 46 | buf.putString(Util.str2byte(signal)); 47 | write(packet); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/Logger.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2006-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public interface Logger{ 33 | 34 | public final int DEBUG=0; 35 | public final int INFO=1; 36 | public final int WARN=2; 37 | public final int ERROR=3; 38 | public final int FATAL=4; 39 | 40 | public boolean isEnabled(int level); 41 | 42 | public void log(int level, String message); 43 | 44 | /* 45 | public final Logger SIMPLE_LOGGER=new Logger(){ 46 | public boolean isEnabled(int level){return true;} 47 | public void log(int level, String message){System.err.println(message);} 48 | }; 49 | final Logger DEVNULL=new Logger(){ 50 | public boolean isEnabled(int level){return false;} 51 | public void log(int level, String message){} 52 | }; 53 | */ 54 | } 55 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/RequestShell.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | class RequestShell extends Request{ 33 | public void request(Session session, Channel channel) throws Exception{ 34 | super.request(session, channel); 35 | 36 | Buffer buf=new Buffer(); 37 | Packet packet=new Packet(buf); 38 | 39 | // send 40 | // byte SSH_MSG_CHANNEL_REQUEST(98) 41 | // uint32 recipient channel 42 | // string request type // "shell" 43 | // boolean want reply // 0 44 | packet.reset(); 45 | buf.putByte((byte) Session.SSH_MSG_CHANNEL_REQUEST); 46 | buf.putInt(channel.getRecipient()); 47 | buf.putString(Util.str2byte("shell")); 48 | buf.putByte((byte)(waitForReply() ? 1 : 0)); 49 | write(packet); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/RequestEnv.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | class RequestEnv extends Request{ 33 | byte[] name=new byte[0]; 34 | byte[] value=new byte[0]; 35 | void setEnv(byte[] name, byte[] value){ 36 | this.name=name; 37 | this.value=value; 38 | } 39 | public void request(Session session, Channel channel) throws Exception{ 40 | super.request(session, channel); 41 | 42 | Buffer buf=new Buffer(); 43 | Packet packet=new Packet(buf); 44 | 45 | packet.reset(); 46 | buf.putByte((byte) Session.SSH_MSG_CHANNEL_REQUEST); 47 | buf.putInt(channel.getRecipient()); 48 | buf.putString(Util.str2byte("env")); 49 | buf.putByte((byte)(waitForReply() ? 1 : 0)); 50 | buf.putString(name); 51 | buf.putString(value); 52 | write(packet); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /examples/ChangePassphrase.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /** 3 | * This program will demonstrate to change the passphrase for a 4 | * private key file instead of creating a new private key. 5 | * $ CLASSPATH=.:../build javac ChangePassphrase.java 6 | * $ CLASSPATH=.:../build java ChangePassphrase private-key 7 | * A passphrase will be prompted if the given private-key has been 8 | * encrypted. After successfully loading the content of the 9 | * private-key, the new passphrase will be prompted and the given 10 | * private-key will be re-encrypted with that new passphrase. 11 | * 12 | */ 13 | import com.jcraft.jsch.*; 14 | import javax.swing.*; 15 | 16 | class ChangePassphrase{ 17 | public static void main(String[] arg){ 18 | if(arg.length!=1){ 19 | System.err.println("usage: java ChangePassphrase private_key"); 20 | System.exit(-1); 21 | } 22 | 23 | JSch jsch=new JSch(); 24 | 25 | String pkey=arg[0]; 26 | 27 | try{ 28 | KeyPair kpair=KeyPair.load(jsch, pkey); 29 | 30 | System.out.println(pkey+" has "+(kpair.isEncrypted()?"been ":"not been ")+"encrypted"); 31 | 32 | String passphrase=""; 33 | while(kpair.isEncrypted()){ 34 | JTextField passphraseField=(JTextField)new JPasswordField(20); 35 | Object[] ob={passphraseField}; 36 | int result=JOptionPane.showConfirmDialog(null, ob, 37 | "Enter passphrase for "+pkey, 38 | JOptionPane.OK_CANCEL_OPTION); 39 | if(result!=JOptionPane.OK_OPTION){ 40 | System.exit(-1); 41 | } 42 | passphrase=passphraseField.getText(); 43 | if(!kpair.decrypt(passphrase)){ 44 | System.out.println("failed to decrypt "+pkey); 45 | } 46 | else{ 47 | System.out.println(pkey+" is decrypted."); 48 | } 49 | } 50 | 51 | passphrase=""; 52 | 53 | JTextField passphraseField=(JTextField)new JPasswordField(20); 54 | Object[] ob={passphraseField}; 55 | int result=JOptionPane.showConfirmDialog(null, ob, 56 | "Enter new passphrase for "+pkey+ 57 | " (empty for no passphrase)", 58 | JOptionPane.OK_CANCEL_OPTION); 59 | if(result!=JOptionPane.OK_OPTION){ 60 | System.exit(-1); 61 | } 62 | passphrase=passphraseField.getText(); 63 | 64 | kpair.setPassphrase(passphrase); 65 | kpair.writePrivateKey(pkey); 66 | kpair.dispose(); 67 | } 68 | catch(Exception e){ 69 | System.out.println(e); 70 | } 71 | System.exit(0); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/RequestAgentForwarding.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2006-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | class RequestAgentForwarding extends Request{ 33 | public void request(Session session, Channel channel) throws Exception{ 34 | super.request(session, channel); 35 | 36 | setReply(false); 37 | 38 | Buffer buf=new Buffer(); 39 | Packet packet=new Packet(buf); 40 | 41 | // byte SSH_MSG_CHANNEL_REQUEST(98) 42 | // uint32 recipient channel 43 | // string request type // "auth-agent-req@openssh.com" 44 | // boolean want reply // 0 45 | packet.reset(); 46 | buf.putByte((byte) Session.SSH_MSG_CHANNEL_REQUEST); 47 | buf.putInt(channel.getRecipient()); 48 | buf.putString(Util.str2byte("auth-agent-req@openssh.com")); 49 | buf.putByte((byte)(waitForReply() ? 1 : 0)); 50 | write(packet); 51 | session.agent_forwarding=true; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/ConfigRepository.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2013-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public interface ConfigRepository { 33 | 34 | public Config getConfig(String host); 35 | 36 | public interface Config { 37 | public String getHostname(); 38 | public String getUser(); 39 | public int getPort(); 40 | public String getValue(String key); 41 | public String[] getValues(String key); 42 | } 43 | 44 | static final Config defaultConfig = new Config() { 45 | public String getHostname() {return null;} 46 | public String getUser() {return null;} 47 | public int getPort() {return -1;} 48 | public String getValue(String key) {return null;} 49 | public String[] getValues(String key) {return null;} 50 | }; 51 | 52 | static final ConfigRepository nullConfig = new ConfigRepository(){ 53 | public Config getConfig(String host) { return defaultConfig; } 54 | }; 55 | } 56 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/RequestSubsystem.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2005-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public class RequestSubsystem extends Request{ 33 | private String subsystem=null; 34 | public void request(Session session, Channel channel, String subsystem, boolean want_reply) throws Exception{ 35 | setReply(want_reply); 36 | this.subsystem=subsystem; 37 | this.request(session, channel); 38 | } 39 | public void request(Session session, Channel channel) throws Exception{ 40 | super.request(session, channel); 41 | 42 | Buffer buf=new Buffer(); 43 | Packet packet=new Packet(buf); 44 | 45 | packet.reset(); 46 | buf.putByte((byte)Session.SSH_MSG_CHANNEL_REQUEST); 47 | buf.putInt(channel.getRecipient()); 48 | buf.putString(Util.str2byte("subsystem")); 49 | buf.putByte((byte)(waitForReply() ? 1 : 0)); 50 | buf.putString(Util.str2byte(subsystem)); 51 | write(packet); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/PBKDF.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2013-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | import javax.crypto.spec.PBEKeySpec; 33 | import javax.crypto.SecretKeyFactory; 34 | import java.security.spec.InvalidKeySpecException; 35 | import java.security.NoSuchAlgorithmException; 36 | 37 | public class PBKDF implements com.jcraft.jsch.PBKDF{ 38 | public byte[] getKey(byte[] _pass, byte[] salt, int iterations, int size){ 39 | char[] pass=new char[_pass.length]; 40 | for(int i = 0; i < _pass.length; i++){ 41 | pass[i]=(char)(_pass[i]&0xff); 42 | } 43 | try { 44 | PBEKeySpec spec = 45 | new PBEKeySpec(pass, salt, iterations, size*8); 46 | SecretKeyFactory skf = 47 | SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"); 48 | byte[] key = skf.generateSecret(spec).getEncoded(); 49 | return key; 50 | } 51 | catch(InvalidKeySpecException e){ 52 | } 53 | catch(NoSuchAlgorithmException e){ 54 | } 55 | return null; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/RequestExec.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | class RequestExec extends Request{ 33 | private byte[] command=new byte[0]; 34 | RequestExec(byte[] command){ 35 | this.command=command; 36 | } 37 | public void request(Session session, Channel channel) throws Exception{ 38 | super.request(session, channel); 39 | 40 | Buffer buf=new Buffer(); 41 | Packet packet=new Packet(buf); 42 | 43 | // send 44 | // byte SSH_MSG_CHANNEL_REQUEST(98) 45 | // uint32 recipient channel 46 | // string request type // "exec" 47 | // boolean want reply // 0 48 | // string command 49 | packet.reset(); 50 | buf.putByte((byte) Session.SSH_MSG_CHANNEL_REQUEST); 51 | buf.putInt(channel.getRecipient()); 52 | buf.putString(Util.str2byte("exec")); 53 | buf.putByte((byte)(waitForReply() ? 1 : 0)); 54 | buf.checkFreeSize(4+command.length); 55 | buf.putString(command); 56 | write(packet); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/UserAuth.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public abstract class UserAuth{ 33 | protected static final int SSH_MSG_USERAUTH_REQUEST= 50; 34 | protected static final int SSH_MSG_USERAUTH_FAILURE= 51; 35 | protected static final int SSH_MSG_USERAUTH_SUCCESS= 52; 36 | protected static final int SSH_MSG_USERAUTH_BANNER= 53; 37 | protected static final int SSH_MSG_USERAUTH_INFO_REQUEST= 60; 38 | protected static final int SSH_MSG_USERAUTH_INFO_RESPONSE= 61; 39 | protected static final int SSH_MSG_USERAUTH_PK_OK= 60; 40 | 41 | protected UserInfo userinfo; 42 | protected Packet packet; 43 | protected Buffer buf; 44 | protected String username; 45 | 46 | public boolean start(Session session) throws Exception{ 47 | this.userinfo=session.getUserInfo(); 48 | this.packet=session.packet; 49 | this.buf=packet.getBuffer(); 50 | this.username=session.getUserName(); 51 | return true; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/ChannelShell.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public class ChannelShell extends ChannelSession{ 33 | 34 | ChannelShell(){ 35 | super(); 36 | pty=true; 37 | } 38 | 39 | public void start() throws JSchException{ 40 | Session _session=getSession(); 41 | try{ 42 | sendRequests(); 43 | 44 | Request request=new RequestShell(); 45 | request.request(_session, this); 46 | } 47 | catch(Exception e){ 48 | if(e instanceof JSchException) throw (JSchException)e; 49 | if(e instanceof Throwable) 50 | throw new JSchException("ChannelShell", (Throwable)e); 51 | throw new JSchException("ChannelShell"); 52 | } 53 | 54 | if(io.in!=null){ 55 | thread=new Thread(this); 56 | thread.setName("Shell for "+_session.host); 57 | if(_session.daemon_thread){ 58 | thread.setDaemon(_session.daemon_thread); 59 | } 60 | thread.start(); 61 | } 62 | } 63 | 64 | void init() throws JSchException { 65 | io.setInputStream(getSession().in); 66 | io.setOutputStream(getSession().out); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## Purpose 2 | > Describe the problems, issues, or needs driving this feature/fix and include links to related issues in the following format: Resolves issue1, issue2, etc. 3 | 4 | ## Goals 5 | > Describe the solutions that this feature/fix will introduce to resolve the problems described above 6 | 7 | ## Approach 8 | > Describe how you are implementing the solutions. Include an animated GIF or screenshot if the change affects the UI (email documentation@wso2.com to review all UI text). Include a link to a Markdown file or Google doc if the feature write-up is too long to paste here. 9 | 10 | ## User stories 11 | > Summary of user stories addressed by this change> 12 | 13 | ## Release note 14 | > Brief description of the new feature or bug fix as it will appear in the release notes 15 | 16 | ## Documentation 17 | > Link(s) to product documentation that addresses the changes of this PR. If no doc impact, enter “N/A” plus brief explanation of why there’s no doc impact 18 | 19 | ## Training 20 | > Link to the PR for changes to the training content in https://github.com/wso2/WSO2-Training, if applicable 21 | 22 | ## Certification 23 | > Type “Sent” when you have provided new/updated certification questions, plus four answers for each question (correct answer highlighted in bold), based on this change. Certification questions/answers should be sent to certification@wso2.com and NOT pasted in this PR. If there is no impact on certification exams, type “N/A” and explain why. 24 | 25 | ## Marketing 26 | > Link to drafts of marketing content that will describe and promote this feature, including product page changes, technical articles, blog posts, videos, etc., if applicable 27 | 28 | ## Automation tests 29 | - Unit tests 30 | > Code coverage information 31 | - Integration tests 32 | > Details about the test cases and coverage 33 | 34 | ## Security checks 35 | - Followed secure coding standards in http://wso2.com/technical-reports/wso2-secure-engineering-guidelines? yes/no 36 | - Ran FindSecurityBugs plugin and verified report? yes/no 37 | - Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets? yes/no 38 | 39 | ## Samples 40 | > Provide high-level details about the samples related to this feature 41 | 42 | ## Related PRs 43 | > List any other related PRs 44 | 45 | ## Migrations (if applicable) 46 | > Describe migration steps and platforms on which migration has been tested 47 | 48 | ## Test environment 49 | > List all JDK versions, operating systems, databases, and browser/versions on which this feature/fix was tested 50 | 51 | ## Learning 52 | > Describe the research phase and any blog posts, patterns, libraries, or add-ons you used to solve the problem. -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/KeyPairGenDSA.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | import java.security.*; 33 | import java.security.interfaces.*; 34 | 35 | public class KeyPairGenDSA implements com.jcraft.jsch.KeyPairGenDSA{ 36 | byte[] x; // private 37 | byte[] y; // public 38 | byte[] p; 39 | byte[] q; 40 | byte[] g; 41 | 42 | public void init(int key_size) throws Exception{ 43 | KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA"); 44 | keyGen.initialize(key_size, new SecureRandom()); 45 | KeyPair pair = keyGen.generateKeyPair(); 46 | PublicKey pubKey=pair.getPublic(); 47 | PrivateKey prvKey=pair.getPrivate(); 48 | 49 | x=((DSAPrivateKey)prvKey).getX().toByteArray(); 50 | y=((DSAPublicKey)pubKey).getY().toByteArray(); 51 | 52 | DSAParams params=((DSAKey)prvKey).getParams(); 53 | p=params.getP().toByteArray(); 54 | q=params.getQ().toByteArray(); 55 | g=params.getG().toByteArray(); 56 | } 57 | public byte[] getX(){return x;} 58 | public byte[] getY(){return y;} 59 | public byte[] getP(){return p;} 60 | public byte[] getQ(){return q;} 61 | public byte[] getG(){return g;} 62 | } 63 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/Request.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | abstract class Request{ 33 | private boolean reply=false; 34 | private Session session=null; 35 | private Channel channel=null; 36 | void request(Session session, Channel channel) throws Exception{ 37 | this.session=session; 38 | this.channel=channel; 39 | if(channel.connectTimeout>0){ 40 | setReply(true); 41 | } 42 | } 43 | boolean waitForReply(){ return reply; } 44 | void setReply(boolean reply){ this.reply=reply; } 45 | void write(Packet packet) throws Exception{ 46 | if(reply){ 47 | channel.reply=-1; 48 | } 49 | session.write(packet); 50 | if(reply){ 51 | long start=System.currentTimeMillis(); 52 | long timeout=channel.connectTimeout; 53 | while(channel.isConnected() && channel.reply==-1){ 54 | try{Thread.sleep(10);} 55 | catch(Exception ee){ 56 | } 57 | if(timeout>0L && 58 | (System.currentTimeMillis()-start)>timeout){ 59 | channel.reply=0; 60 | throw new JSchException("channel request: timeout"); 61 | } 62 | } 63 | 64 | if(channel.reply==0){ 65 | throw new JSchException("failed to send channel request"); 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/RequestX11.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | class RequestX11 extends Request{ 33 | public void setCookie(String cookie){ 34 | ChannelX11.cookie=Util.str2byte(cookie); 35 | } 36 | public void request(Session session, Channel channel) throws Exception{ 37 | super.request(session, channel); 38 | 39 | Buffer buf=new Buffer(); 40 | Packet packet=new Packet(buf); 41 | 42 | // byte SSH_MSG_CHANNEL_REQUEST(98) 43 | // uint32 recipient channel 44 | // string request type // "x11-req" 45 | // boolean want reply // 0 46 | // boolean single connection 47 | // string x11 authentication protocol // "MIT-MAGIC-COOKIE-1". 48 | // string x11 authentication cookie 49 | // uint32 x11 screen number 50 | packet.reset(); 51 | buf.putByte((byte) Session.SSH_MSG_CHANNEL_REQUEST); 52 | buf.putInt(channel.getRecipient()); 53 | buf.putString(Util.str2byte("x11-req")); 54 | buf.putByte((byte)(waitForReply() ? 1 : 0)); 55 | buf.putByte((byte)0); 56 | buf.putString(Util.str2byte("MIT-MAGIC-COOKIE-1")); 57 | buf.putString(ChannelX11.getFakedCookie(session)); 58 | buf.putInt(0); 59 | write(packet); 60 | 61 | session.x11_forwarding=true; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/RequestWindowChange.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | class RequestWindowChange extends Request{ 33 | int width_columns=80; 34 | int height_rows=24; 35 | int width_pixels=640; 36 | int height_pixels=480; 37 | void setSize(int col, int row, int wp, int hp){ 38 | this.width_columns=col; 39 | this.height_rows=row; 40 | this.width_pixels=wp; 41 | this.height_pixels=hp; 42 | } 43 | public void request(Session session, Channel channel) throws Exception{ 44 | super.request(session, channel); 45 | 46 | Buffer buf=new Buffer(); 47 | Packet packet=new Packet(buf); 48 | 49 | //byte SSH_MSG_CHANNEL_REQUEST 50 | //uint32 recipient_channel 51 | //string "window-change" 52 | //boolean FALSE 53 | //uint32 terminal width, columns 54 | //uint32 terminal height, rows 55 | //uint32 terminal width, pixels 56 | //uint32 terminal height, pixels 57 | packet.reset(); 58 | buf.putByte((byte) Session.SSH_MSG_CHANNEL_REQUEST); 59 | buf.putInt(channel.getRecipient()); 60 | buf.putString(Util.str2byte("window-change")); 61 | buf.putByte((byte)(waitForReply() ? 1 : 0)); 62 | buf.putInt(width_columns); 63 | buf.putInt(height_rows); 64 | buf.putInt(width_pixels); 65 | buf.putInt(height_pixels); 66 | write(packet); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/RequestPtyReq.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | class RequestPtyReq extends Request{ 33 | private String ttype="vt100"; 34 | private int tcol=80; 35 | private int trow=24; 36 | private int twp=640; 37 | private int thp=480; 38 | 39 | private byte[] terminal_mode=Util.empty; 40 | 41 | void setCode(String cookie){ 42 | } 43 | 44 | void setTType(String ttype){ 45 | this.ttype=ttype; 46 | } 47 | 48 | void setTerminalMode(byte[] terminal_mode){ 49 | this.terminal_mode=terminal_mode; 50 | } 51 | 52 | void setTSize(int tcol, int trow, int twp, int thp){ 53 | this.tcol=tcol; 54 | this.trow=trow; 55 | this.twp=twp; 56 | this.thp=thp; 57 | } 58 | 59 | public void request(Session session, Channel channel) throws Exception{ 60 | super.request(session, channel); 61 | 62 | Buffer buf=new Buffer(); 63 | Packet packet=new Packet(buf); 64 | 65 | packet.reset(); 66 | buf.putByte((byte) Session.SSH_MSG_CHANNEL_REQUEST); 67 | buf.putInt(channel.getRecipient()); 68 | buf.putString(Util.str2byte("pty-req")); 69 | buf.putByte((byte)(waitForReply() ? 1 : 0)); 70 | buf.putString(Util.str2byte(ttype)); 71 | buf.putInt(tcol); 72 | buf.putInt(trow); 73 | buf.putInt(twp); 74 | buf.putInt(thp); 75 | buf.putString(terminal_mode); 76 | write(packet); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/ARCFOUR.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2008-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | import com.jcraft.jsch.Cipher; 33 | 34 | import javax.crypto.spec.*; 35 | 36 | public class ARCFOUR implements Cipher{ 37 | private static final int ivsize=8; 38 | private static final int bsize=16; 39 | private javax.crypto.Cipher cipher; 40 | public int getIVSize(){return ivsize;} 41 | public int getBlockSize(){return bsize;} 42 | public void init(int mode, byte[] key, byte[] iv) throws Exception{ 43 | String pad="NoPadding"; 44 | byte[] tmp; 45 | if(key.length>bsize){ 46 | tmp=new byte[bsize]; 47 | System.arraycopy(key, 0, tmp, 0, tmp.length); 48 | key=tmp; 49 | } 50 | 51 | try{ 52 | cipher=javax.crypto.Cipher.getInstance("RC4"); 53 | SecretKeySpec _key = new SecretKeySpec(key, "RC4"); 54 | synchronized(javax.crypto.Cipher.class){ 55 | cipher.init((mode==ENCRYPT_MODE? 56 | javax.crypto.Cipher.ENCRYPT_MODE: 57 | javax.crypto.Cipher.DECRYPT_MODE), 58 | _key); 59 | } 60 | } 61 | catch(Exception e){ 62 | cipher=null; 63 | throw e; 64 | } 65 | } 66 | public void update(byte[] foo, int s1, int len, byte[] bar, int s2) throws Exception{ 67 | cipher.update(foo, s1, len, bar, s2); 68 | } 69 | public boolean isCBC(){return false; } 70 | } 71 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/HMAC.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2012-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | import com.jcraft.jsch.MAC; 33 | import javax.crypto.*; 34 | import javax.crypto.spec.*; 35 | 36 | abstract class HMAC implements MAC { 37 | protected String name; 38 | protected int bsize; 39 | protected String algorithm; 40 | private Mac mac; 41 | 42 | public int getBlockSize() { 43 | return bsize; 44 | }; 45 | 46 | public void init(byte[] key) throws Exception { 47 | if(key.length>bsize){ 48 | byte[] tmp = new byte[bsize]; 49 | System.arraycopy(key, 0, tmp, 0, bsize); 50 | key = tmp; 51 | } 52 | SecretKeySpec skey = new SecretKeySpec(key, algorithm); 53 | mac = Mac.getInstance(algorithm); 54 | mac.init(skey); 55 | } 56 | 57 | private final byte[] tmp = new byte[4]; 58 | public void update(int i){ 59 | tmp[0] = (byte)(i>>>24); 60 | tmp[1] = (byte)(i>>>16); 61 | tmp[2] = (byte)(i>>>8); 62 | tmp[3] = (byte)i; 63 | update(tmp, 0, 4); 64 | } 65 | 66 | public void update(byte foo[], int s, int l){ 67 | mac.update(foo, s, l); 68 | } 69 | 70 | public void doFinal(byte[] buf, int offset){ 71 | try{ 72 | mac.doFinal(buf, offset); 73 | } 74 | catch(ShortBufferException e){ 75 | System.err.println(e); 76 | } 77 | } 78 | 79 | public String getName(){ 80 | return name; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /examples/KeyGen.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /** 3 | * This progam will demonstrate the DSA keypair generation. 4 | * $ CLASSPATH=.:../build javac KeyGen.java 5 | * $ CLASSPATH=.:../build java KeyGen rsa output_keyfile comment 6 | * or 7 | * $ CLASSPATH=.:../build java KeyGen dsa output_keyfile comment 8 | * You will be asked a passphrase for output_keyfile. 9 | * If everything works fine, you will get the DSA or RSA keypair, 10 | * output_keyfile and output_keyfile+".pub". 11 | * The private key and public key are in the OpenSSH format. 12 | * 13 | */ 14 | import com.jcraft.jsch.*; 15 | import javax.swing.*; 16 | 17 | class KeyGen{ 18 | public static void main(String[] arg){ 19 | int key_size = 1024; 20 | if(arg.length<3){ 21 | System.err.println( 22 | "usage: java KeyGen rsa output_keyfile comment\n"+ 23 | " java KeyGen dsa output_keyfile comment\n"+ 24 | " java KeyGen ecdsa-sha2-256 output_keyfile comment\n"+ 25 | " java KeyGen ecdsa-sha2-384 output_keyfile comment\n"+ 26 | " java KeyGen ecdsa-sha2-521 output_keyfile comment"); 27 | System.exit(-1); 28 | } 29 | String _type=arg[0]; 30 | int type=0; 31 | if(_type.equals("rsa")){type=KeyPair.RSA;} 32 | else if(_type.equals("dsa")){type=KeyPair.DSA;} 33 | else if(_type.equals("ecdsa-sha2-nistp256")){ 34 | type=KeyPair.ECDSA; 35 | key_size=256; 36 | } 37 | else if(_type.equals("ecdsa-sha2-nistp384")){ 38 | type=KeyPair.ECDSA; 39 | key_size=384; 40 | } 41 | else if(_type.equals("ecdsa-sha2-nistp521")){ 42 | type=KeyPair.ECDSA; 43 | key_size=521; 44 | } 45 | else { 46 | System.err.println( 47 | "usage: java KeyGen rsa output_keyfile comment\n"+ 48 | " java KeyGen dsa output_keyfile comment\n"+ 49 | " java KeyGen ecdsa-sha2-256 output_keyfile comment\n"+ 50 | " java KeyGen ecdsa-sha2-384 output_keyfile comment\n"+ 51 | " java KeyGen ecdsa-sha2-521 output_keyfile comment"); 52 | System.exit(-1); 53 | } 54 | String filename=arg[1]; 55 | String comment=arg[2]; 56 | 57 | JSch jsch=new JSch(); 58 | 59 | String passphrase=""; 60 | JTextField passphraseField=(JTextField)new JPasswordField(20); 61 | Object[] ob={passphraseField}; 62 | int result= 63 | JOptionPane.showConfirmDialog(null, ob, "Enter passphrase (empty for no passphrase)", 64 | JOptionPane.OK_CANCEL_OPTION); 65 | if(result==JOptionPane.OK_OPTION){ 66 | passphrase=passphraseField.getText(); 67 | } 68 | 69 | try{ 70 | KeyPair kpair=KeyPair.genKeyPair(jsch, type, key_size); 71 | kpair.setPassphrase(passphrase); 72 | kpair.writePrivateKey(filename); 73 | kpair.writePublicKey(filename+".pub", comment); 74 | System.out.println("Finger print: "+kpair.getFingerPrint()); 75 | kpair.dispose(); 76 | } 77 | catch(Exception e){ 78 | System.out.println(e); 79 | } 80 | System.exit(0); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/ARCFOUR128.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2008-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | import com.jcraft.jsch.Cipher; 33 | 34 | import javax.crypto.spec.*; 35 | 36 | public class ARCFOUR128 implements Cipher{ 37 | private static final int ivsize=8; 38 | private static final int bsize=16; 39 | private static final int skip=1536; 40 | private javax.crypto.Cipher cipher; 41 | public int getIVSize(){return ivsize;} 42 | public int getBlockSize(){return bsize;} 43 | public void init(int mode, byte[] key, byte[] iv) throws Exception{ 44 | byte[] tmp; 45 | if(key.length>bsize){ 46 | tmp=new byte[bsize]; 47 | System.arraycopy(key, 0, tmp, 0, tmp.length); 48 | key=tmp; 49 | } 50 | try{ 51 | cipher=javax.crypto.Cipher.getInstance("RC4"); 52 | SecretKeySpec _key = new SecretKeySpec(key, "RC4"); 53 | synchronized(javax.crypto.Cipher.class){ 54 | cipher.init((mode==ENCRYPT_MODE? 55 | javax.crypto.Cipher.ENCRYPT_MODE: 56 | javax.crypto.Cipher.DECRYPT_MODE), 57 | _key); 58 | } 59 | byte[] foo=new byte[1]; 60 | for(int i=0; ibsize){ 46 | tmp=new byte[bsize]; 47 | System.arraycopy(key, 0, tmp, 0, tmp.length); 48 | key=tmp; 49 | } 50 | try{ 51 | cipher=javax.crypto.Cipher.getInstance("RC4"); 52 | SecretKeySpec _key = new SecretKeySpec(key, "RC4"); 53 | synchronized(javax.crypto.Cipher.class){ 54 | cipher.init((mode==ENCRYPT_MODE? 55 | javax.crypto.Cipher.ENCRYPT_MODE: 56 | javax.crypto.Cipher.DECRYPT_MODE), 57 | _key); 58 | } 59 | byte[] foo=new byte[1]; 60 | for(int i=0; iivsize){ 45 | tmp=new byte[ivsize]; 46 | System.arraycopy(iv, 0, tmp, 0, tmp.length); 47 | iv=tmp; 48 | } 49 | if(key.length>bsize){ 50 | tmp=new byte[bsize]; 51 | System.arraycopy(key, 0, tmp, 0, tmp.length); 52 | key=tmp; 53 | } 54 | try{ 55 | SecretKeySpec keyspec=new SecretKeySpec(key, "AES"); 56 | cipher=javax.crypto.Cipher.getInstance("AES/CBC/"+pad); 57 | synchronized(javax.crypto.Cipher.class){ 58 | cipher.init((mode==ENCRYPT_MODE? 59 | javax.crypto.Cipher.ENCRYPT_MODE: 60 | javax.crypto.Cipher.DECRYPT_MODE), 61 | keyspec, new IvParameterSpec(iv)); 62 | } 63 | } 64 | catch(Exception e){ 65 | cipher=null; 66 | throw e; 67 | } 68 | } 69 | public void update(byte[] foo, int s1, int len, byte[] bar, int s2) throws Exception{ 70 | cipher.update(foo, s1, len, bar, s2); 71 | } 72 | public boolean isCBC(){return true; } 73 | } 74 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/AES192CTR.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2008-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | import com.jcraft.jsch.Cipher; 33 | import javax.crypto.spec.*; 34 | 35 | public class AES192CTR implements Cipher{ 36 | private static final int ivsize=16; 37 | private static final int bsize=24; 38 | private javax.crypto.Cipher cipher; 39 | public int getIVSize(){return ivsize;} 40 | public int getBlockSize(){return bsize;} 41 | public void init(int mode, byte[] key, byte[] iv) throws Exception{ 42 | String pad="NoPadding"; 43 | byte[] tmp; 44 | if(iv.length>ivsize){ 45 | tmp=new byte[ivsize]; 46 | System.arraycopy(iv, 0, tmp, 0, tmp.length); 47 | iv=tmp; 48 | } 49 | if(key.length>bsize){ 50 | tmp=new byte[bsize]; 51 | System.arraycopy(key, 0, tmp, 0, tmp.length); 52 | key=tmp; 53 | } 54 | try{ 55 | SecretKeySpec keyspec=new SecretKeySpec(key, "AES"); 56 | cipher=javax.crypto.Cipher.getInstance("AES/CTR/"+pad); 57 | synchronized(javax.crypto.Cipher.class){ 58 | cipher.init((mode==ENCRYPT_MODE? 59 | javax.crypto.Cipher.ENCRYPT_MODE: 60 | javax.crypto.Cipher.DECRYPT_MODE), 61 | keyspec, new IvParameterSpec(iv)); 62 | } 63 | } 64 | catch(Exception e){ 65 | cipher=null; 66 | throw e; 67 | } 68 | } 69 | public void update(byte[] foo, int s1, int len, byte[] bar, int s2) throws Exception{ 70 | cipher.update(foo, s1, len, bar, s2); 71 | } 72 | public boolean isCBC(){return false; } 73 | } 74 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/AES256CBC.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2005-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | import com.jcraft.jsch.Cipher; 33 | import javax.crypto.spec.*; 34 | 35 | public class AES256CBC implements Cipher{ 36 | private static final int ivsize=16; 37 | private static final int bsize=32; 38 | private javax.crypto.Cipher cipher; 39 | public int getIVSize(){return ivsize;} 40 | public int getBlockSize(){return bsize;} 41 | public void init(int mode, byte[] key, byte[] iv) throws Exception{ 42 | String pad="NoPadding"; 43 | byte[] tmp; 44 | if(iv.length>ivsize){ 45 | tmp=new byte[ivsize]; 46 | System.arraycopy(iv, 0, tmp, 0, tmp.length); 47 | iv=tmp; 48 | } 49 | if(key.length>bsize){ 50 | tmp=new byte[bsize]; 51 | System.arraycopy(key, 0, tmp, 0, tmp.length); 52 | key=tmp; 53 | } 54 | try{ 55 | SecretKeySpec keyspec=new SecretKeySpec(key, "AES"); 56 | cipher=javax.crypto.Cipher.getInstance("AES/CBC/"+pad); 57 | synchronized(javax.crypto.Cipher.class){ 58 | cipher.init((mode==ENCRYPT_MODE? 59 | javax.crypto.Cipher.ENCRYPT_MODE: 60 | javax.crypto.Cipher.DECRYPT_MODE), 61 | keyspec, new IvParameterSpec(iv)); 62 | } 63 | } 64 | catch(Exception e){ 65 | cipher=null; 66 | throw e; 67 | } 68 | } 69 | public void update(byte[] foo, int s1, int len, byte[] bar, int s2) throws Exception{ 70 | cipher.update(foo, s1, len, bar, s2); 71 | } 72 | public boolean isCBC(){return true; } 73 | } 74 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/AES256CTR.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2008-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | import com.jcraft.jsch.Cipher; 33 | import javax.crypto.spec.*; 34 | 35 | public class AES256CTR implements Cipher{ 36 | private static final int ivsize=16; 37 | private static final int bsize=32; 38 | private javax.crypto.Cipher cipher; 39 | public int getIVSize(){return ivsize;} 40 | public int getBlockSize(){return bsize;} 41 | public void init(int mode, byte[] key, byte[] iv) throws Exception{ 42 | String pad="NoPadding"; 43 | byte[] tmp; 44 | if(iv.length>ivsize){ 45 | tmp=new byte[ivsize]; 46 | System.arraycopy(iv, 0, tmp, 0, tmp.length); 47 | iv=tmp; 48 | } 49 | if(key.length>bsize){ 50 | tmp=new byte[bsize]; 51 | System.arraycopy(key, 0, tmp, 0, tmp.length); 52 | key=tmp; 53 | } 54 | try{ 55 | SecretKeySpec keyspec=new SecretKeySpec(key, "AES"); 56 | cipher=javax.crypto.Cipher.getInstance("AES/CTR/"+pad); 57 | synchronized(javax.crypto.Cipher.class){ 58 | cipher.init((mode==ENCRYPT_MODE? 59 | javax.crypto.Cipher.ENCRYPT_MODE: 60 | javax.crypto.Cipher.DECRYPT_MODE), 61 | keyspec, new IvParameterSpec(iv)); 62 | } 63 | } 64 | catch(Exception e){ 65 | cipher=null; 66 | throw e; 67 | } 68 | } 69 | public void update(byte[] foo, int s1, int len, byte[] bar, int s2) throws Exception{ 70 | cipher.update(foo, s1, len, bar, s2); 71 | } 72 | public boolean isCBC(){return false; } 73 | } 74 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/AES128CBC.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2005-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | import com.jcraft.jsch.Cipher; 33 | import javax.crypto.spec.*; 34 | 35 | public class AES128CBC implements Cipher{ 36 | private static final int ivsize=16; 37 | private static final int bsize=16; 38 | private javax.crypto.Cipher cipher; 39 | public int getIVSize(){return ivsize;} 40 | public int getBlockSize(){return bsize;} 41 | public void init(int mode, byte[] key, byte[] iv) throws Exception{ 42 | String pad="NoPadding"; 43 | byte[] tmp; 44 | if(iv.length>ivsize){ 45 | tmp=new byte[ivsize]; 46 | System.arraycopy(iv, 0, tmp, 0, tmp.length); 47 | iv=tmp; 48 | } 49 | if(key.length>bsize){ 50 | tmp=new byte[bsize]; 51 | System.arraycopy(key, 0, tmp, 0, tmp.length); 52 | key=tmp; 53 | } 54 | 55 | try{ 56 | SecretKeySpec keyspec=new SecretKeySpec(key, "AES"); 57 | cipher=javax.crypto.Cipher.getInstance("AES/CBC/"+pad); 58 | synchronized(javax.crypto.Cipher.class){ 59 | cipher.init((mode==ENCRYPT_MODE? 60 | javax.crypto.Cipher.ENCRYPT_MODE: 61 | javax.crypto.Cipher.DECRYPT_MODE), 62 | keyspec, new IvParameterSpec(iv)); 63 | } 64 | } 65 | catch(Exception e){ 66 | cipher=null; 67 | throw e; 68 | } 69 | } 70 | public void update(byte[] foo, int s1, int len, byte[] bar, int s2) throws Exception{ 71 | cipher.update(foo, s1, len, bar, s2); 72 | } 73 | 74 | public boolean isCBC(){return true; } 75 | } 76 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/AES128CTR.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2008-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | import com.jcraft.jsch.Cipher; 33 | import javax.crypto.spec.*; 34 | 35 | public class AES128CTR implements Cipher{ 36 | private static final int ivsize=16; 37 | private static final int bsize=16; 38 | private javax.crypto.Cipher cipher; 39 | public int getIVSize(){return ivsize;} 40 | public int getBlockSize(){return bsize;} 41 | public void init(int mode, byte[] key, byte[] iv) throws Exception{ 42 | String pad="NoPadding"; 43 | byte[] tmp; 44 | if(iv.length>ivsize){ 45 | tmp=new byte[ivsize]; 46 | System.arraycopy(iv, 0, tmp, 0, tmp.length); 47 | iv=tmp; 48 | } 49 | if(key.length>bsize){ 50 | tmp=new byte[bsize]; 51 | System.arraycopy(key, 0, tmp, 0, tmp.length); 52 | key=tmp; 53 | } 54 | 55 | try{ 56 | SecretKeySpec keyspec=new SecretKeySpec(key, "AES"); 57 | cipher=javax.crypto.Cipher.getInstance("AES/CTR/"+pad); 58 | synchronized(javax.crypto.Cipher.class){ 59 | cipher.init((mode==ENCRYPT_MODE? 60 | javax.crypto.Cipher.ENCRYPT_MODE: 61 | javax.crypto.Cipher.DECRYPT_MODE), 62 | keyspec, new IvParameterSpec(iv)); 63 | } 64 | } 65 | catch(Exception e){ 66 | cipher=null; 67 | throw e; 68 | } 69 | } 70 | public void update(byte[] foo, int s1, int len, byte[] bar, int s2) throws Exception{ 71 | cipher.update(foo, s1, len, bar, s2); 72 | } 73 | 74 | public boolean isCBC(){return false; } 75 | } 76 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/BlowfishCBC.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | import com.jcraft.jsch.Cipher; 33 | import javax.crypto.spec.*; 34 | 35 | public class BlowfishCBC implements Cipher{ 36 | private static final int ivsize=8; 37 | private static final int bsize=16; 38 | private javax.crypto.Cipher cipher; 39 | public int getIVSize(){return ivsize;} 40 | public int getBlockSize(){return bsize;} 41 | public void init(int mode, byte[] key, byte[] iv) throws Exception{ 42 | String pad="NoPadding"; 43 | // if(padding) pad="PKCS5Padding"; 44 | byte[] tmp; 45 | if(iv.length>ivsize){ 46 | tmp=new byte[ivsize]; 47 | System.arraycopy(iv, 0, tmp, 0, tmp.length); 48 | iv=tmp; 49 | } 50 | if(key.length>bsize){ 51 | tmp=new byte[bsize]; 52 | System.arraycopy(key, 0, tmp, 0, tmp.length); 53 | key=tmp; 54 | } 55 | try{ 56 | SecretKeySpec skeySpec = new SecretKeySpec(key, "Blowfish"); 57 | cipher=javax.crypto.Cipher.getInstance("Blowfish/CBC/"+pad); 58 | synchronized(javax.crypto.Cipher.class){ 59 | cipher.init((mode==ENCRYPT_MODE? 60 | javax.crypto.Cipher.ENCRYPT_MODE: 61 | javax.crypto.Cipher.DECRYPT_MODE), 62 | skeySpec, new IvParameterSpec(iv)); 63 | } 64 | } 65 | catch(Exception e){ 66 | throw e; 67 | } 68 | } 69 | public void update(byte[] foo, int s1, int len, byte[] bar, int s2) throws Exception{ 70 | cipher.update(foo, s1, len, bar, s2); 71 | } 72 | public boolean isCBC(){return true; } 73 | } 74 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/ChannelExec.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public class ChannelExec extends ChannelSession{ 33 | 34 | byte[] command=new byte[0]; 35 | 36 | public void start() throws JSchException{ 37 | Session _session=getSession(); 38 | try{ 39 | sendRequests(); 40 | Request request=new RequestExec(command); 41 | request.request(_session, this); 42 | } 43 | catch(Exception e){ 44 | if(e instanceof JSchException) throw (JSchException)e; 45 | if(e instanceof Throwable) 46 | throw new JSchException("ChannelExec", (Throwable)e); 47 | throw new JSchException("ChannelExec"); 48 | } 49 | 50 | if(io.in!=null){ 51 | thread=new Thread(this); 52 | thread.setName("Exec thread "+_session.getHost()); 53 | if(_session.daemon_thread){ 54 | thread.setDaemon(_session.daemon_thread); 55 | } 56 | thread.start(); 57 | } 58 | } 59 | 60 | public void setCommand(String command){ 61 | this.command=Util.str2byte(command); 62 | } 63 | public void setCommand(byte[] command){ 64 | this.command=command; 65 | } 66 | 67 | void init() throws JSchException { 68 | io.setInputStream(getSession().in); 69 | io.setOutputStream(getSession().out); 70 | } 71 | 72 | public void setErrStream(java.io.OutputStream out){ 73 | setExtOutputStream(out); 74 | } 75 | public void setErrStream(java.io.OutputStream out, boolean dontclose){ 76 | setExtOutputStream(out, dontclose); 77 | } 78 | public java.io.InputStream getErrStream() throws java.io.IOException { 79 | return getExtInputStream(); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /orbit/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 22 | org.wso2.com.jcraft 23 | jsch-project 24 | 0.1.55-wso2v5-SNAPSHOT 25 | ../pom.xml 26 | 27 | 4.0.0 28 | org.wso2.orbit.com.jcraft 29 | jsch 30 | 0.1.55-wso2v5-SNAPSHOT 31 | bundle 32 | JSch Orbit 33 | 34 | A pure Java implementation of SSH2 35 | 36 | http://wso2.org 37 | 38 | 39 | 40 | org.wso2.com.jcraft 41 | jsch 42 | ${project.version} 43 | true 44 | 45 | 46 | 47 | 48 | 49 | 50 | org.apache.felix 51 | maven-bundle-plugin 52 | 2.3.7 53 | true 54 | 55 | 56 | ${project.artifactId} 57 | ${project.artifactId} 58 | 59 | com.jcraft.jsch.*;version="${project.version}" 60 | 61 | 62 | !com.jcraft.jsch.*, 63 | com.jcraft.jzlib;resolution:=optional, 64 | javax.crypto;resolution:=optional, 65 | javax.crypto.interfaces;resolution:=optional, 66 | javax.crypto.spec;resolution:=optional, 67 | org.ietf.jgss;resolution:=optional 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/Identity.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public interface Identity{ 33 | 34 | /** 35 | * Decrypts this identity with the specified pass-phrase. 36 | * @param passphrase the pass-phrase for this identity. 37 | * @return true if the decryption is succeeded 38 | * or this identity is not cyphered. 39 | */ 40 | public boolean setPassphrase(byte[] passphrase) throws JSchException; 41 | 42 | /** 43 | * Returns the public-key blob. 44 | * @return the public-key blob 45 | */ 46 | public byte[] getPublicKeyBlob(); 47 | 48 | /** 49 | * Signs on data with this identity, and returns the result. 50 | * @param data data to be signed 51 | * @return the signature 52 | */ 53 | public byte[] getSignature(byte[] data); 54 | 55 | /** 56 | * @deprecated The decryption should be done automatically in #setPassphase(byte[] passphrase) 57 | * @see #setPassphrase(byte[] passphrase) 58 | */ 59 | public boolean decrypt(); 60 | 61 | /** 62 | * Returns the name of the key algorithm. 63 | * @return "ssh-rsa" or "ssh-dss" 64 | */ 65 | public String getAlgName(); 66 | 67 | /** 68 | * Returns the name of this identity. 69 | * It will be useful to identify this object in the {@link IdentityRepository}. 70 | */ 71 | public String getName(); 72 | 73 | /** 74 | * Returns true if this identity is cyphered. 75 | * @return true if this identity is cyphered. 76 | */ 77 | public boolean isEncrypted(); 78 | 79 | /** 80 | * Disposes internally allocated data, like byte array for the private key. 81 | */ 82 | public void clear(); 83 | } 84 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/KeyPairGenRSA.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | import java.security.*; 33 | import java.security.interfaces.*; 34 | 35 | public class KeyPairGenRSA implements com.jcraft.jsch.KeyPairGenRSA{ 36 | byte[] d; // private 37 | byte[] e; // public 38 | byte[] n; 39 | 40 | byte[] c; // coefficient 41 | byte[] ep; // exponent p 42 | byte[] eq; // exponent q 43 | byte[] p; // prime p 44 | byte[] q; // prime q 45 | 46 | public void init(int key_size) throws Exception{ 47 | KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA"); 48 | keyGen.initialize(key_size, new SecureRandom()); 49 | KeyPair pair = keyGen.generateKeyPair(); 50 | 51 | PublicKey pubKey=pair.getPublic(); 52 | PrivateKey prvKey=pair.getPrivate(); 53 | 54 | d=((RSAPrivateKey)prvKey).getPrivateExponent().toByteArray(); 55 | e=((RSAPublicKey)pubKey).getPublicExponent().toByteArray(); 56 | n=((RSAPrivateKey)prvKey).getModulus().toByteArray(); 57 | 58 | c=((RSAPrivateCrtKey)prvKey).getCrtCoefficient().toByteArray(); 59 | ep=((RSAPrivateCrtKey)prvKey).getPrimeExponentP().toByteArray(); 60 | eq=((RSAPrivateCrtKey)prvKey).getPrimeExponentQ().toByteArray(); 61 | p=((RSAPrivateCrtKey)prvKey).getPrimeP().toByteArray(); 62 | q=((RSAPrivateCrtKey)prvKey).getPrimeQ().toByteArray(); 63 | } 64 | public byte[] getD(){return d;} 65 | public byte[] getE(){return e;} 66 | public byte[] getN(){return n;} 67 | public byte[] getC(){return c;} 68 | public byte[] getEP(){return ep;} 69 | public byte[] getEQ(){return eq;} 70 | public byte[] getP(){return p;} 71 | public byte[] getQ(){return q;} 72 | } 73 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/SignatureRSA.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | import java.math.BigInteger; 33 | import java.security.*; 34 | import java.security.spec.*; 35 | import com.jcraft.jsch.Buffer; 36 | 37 | public class SignatureRSA implements com.jcraft.jsch.SignatureRSA{ 38 | 39 | java.security.Signature signature; 40 | KeyFactory keyFactory; 41 | 42 | public void init() throws Exception{ 43 | signature=java.security.Signature.getInstance("SHA1withRSA"); 44 | keyFactory=KeyFactory.getInstance("RSA"); 45 | } 46 | public void setPubKey(byte[] e, byte[] n) throws Exception{ 47 | RSAPublicKeySpec rsaPubKeySpec = 48 | new RSAPublicKeySpec(new BigInteger(n), 49 | new BigInteger(e)); 50 | PublicKey pubKey=keyFactory.generatePublic(rsaPubKeySpec); 51 | signature.initVerify(pubKey); 52 | } 53 | public void setPrvKey(byte[] d, byte[] n) throws Exception{ 54 | RSAPrivateKeySpec rsaPrivKeySpec = 55 | new RSAPrivateKeySpec(new BigInteger(n), 56 | new BigInteger(d)); 57 | PrivateKey prvKey = keyFactory.generatePrivate(rsaPrivKeySpec); 58 | signature.initSign(prvKey); 59 | } 60 | public byte[] sign() throws Exception{ 61 | byte[] sig=signature.sign(); 62 | return sig; 63 | } 64 | public void update(byte[] foo) throws Exception{ 65 | signature.update(foo); 66 | } 67 | public boolean verify(byte[] sig) throws Exception{ 68 | int i=0; 69 | int j=0; 70 | byte[] tmp; 71 | Buffer buf=new Buffer(sig); 72 | 73 | if(new String(buf.getString()).equals("ssh-rsa")){ 74 | j=buf.getInt(); 75 | i=buf.getOffSet(); 76 | tmp=new byte[j]; 77 | System.arraycopy(sig, i, tmp, 0, j); sig=tmp; 78 | } 79 | 80 | return signature.verify(sig); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/jce/Random.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2002-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch.jce; 31 | 32 | import java.security.SecureRandom; 33 | 34 | public class Random implements com.jcraft.jsch.Random{ 35 | private byte[] tmp=new byte[16]; 36 | private SecureRandom random=null; 37 | public Random(){ 38 | 39 | // We hope that 'new SecureRandom()' will use NativePRNG algorithm 40 | // on Sun's Java5 for GNU/Linux and Solaris. 41 | // It seems NativePRNG refers to /dev/urandom and it must not be blocked, 42 | // but NativePRNG is slower than SHA1PRNG ;-< 43 | // TIPS: By adding option '-Djava.security.egd=file:/dev/./urandom' 44 | // SHA1PRNG will be used instead of NativePRNG. 45 | // On MacOSX, 'new SecureRandom()' will use NativePRNG algorithm and 46 | // it is also slower than SHA1PRNG. 47 | // On Windows, 'new SecureRandom()' will use SHA1PRNG algorithm. 48 | random=new SecureRandom(); 49 | 50 | /* 51 | try{ 52 | random=SecureRandom.getInstance("SHA1PRNG"); 53 | return; 54 | } 55 | catch(java.security.NoSuchAlgorithmException e){ 56 | // System.err.println(e); 57 | } 58 | 59 | // The following code is for IBM's JCE 60 | try{ 61 | random=SecureRandom.getInstance("IBMSecureRandom"); 62 | return; 63 | } 64 | catch(java.security.NoSuchAlgorithmException ee){ 65 | //System.err.println(ee); 66 | } 67 | */ 68 | } 69 | public void fill(byte[] foo, int start, int len){ 70 | /* 71 | // This case will not become true in our usage. 72 | if(start==0 && foo.length==len){ 73 | random.nextBytes(foo); 74 | return; 75 | } 76 | */ 77 | if(len>tmp.length){ tmp=new byte[len]; } 78 | random.nextBytes(tmp); 79 | System.arraycopy(tmp, 0, foo, start, len); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /jsch/src/main/java/com/jcraft/jsch/ChannelSubsystem.java: -------------------------------------------------------------------------------- 1 | /* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ 2 | /* 3 | Copyright (c) 2005-2018 ymnk, JCraft,Inc. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution. 14 | 15 | 3. The names of the authors may not be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 19 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 21 | INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 24 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | package com.jcraft.jsch; 31 | 32 | public class ChannelSubsystem extends ChannelSession{ 33 | boolean xforwading=false; 34 | boolean pty=false; 35 | boolean want_reply=true; 36 | String subsystem=""; 37 | public void setXForwarding(boolean foo){ xforwading=foo; } 38 | public void setPty(boolean foo){ pty=foo; } 39 | public void setWantReply(boolean foo){ want_reply=foo; } 40 | public void setSubsystem(String foo){ subsystem=foo; } 41 | public void start() throws JSchException{ 42 | Session _session=getSession(); 43 | try{ 44 | Request request; 45 | if(xforwading){ 46 | request=new RequestX11(); 47 | request.request(_session, this); 48 | } 49 | if(pty){ 50 | request=new RequestPtyReq(); 51 | request.request(_session, this); 52 | } 53 | request=new RequestSubsystem(); 54 | ((RequestSubsystem)request).request(_session, this, subsystem, want_reply); 55 | } 56 | catch(Exception e){ 57 | if(e instanceof JSchException){ throw (JSchException)e; } 58 | if(e instanceof Throwable) 59 | throw new JSchException("ChannelSubsystem", (Throwable)e); 60 | throw new JSchException("ChannelSubsystem"); 61 | } 62 | if(io.in!=null){ 63 | thread=new Thread(this); 64 | thread.setName("Subsystem for "+_session.host); 65 | if(_session.daemon_thread){ 66 | thread.setDaemon(_session.daemon_thread); 67 | } 68 | thread.start(); 69 | } 70 | } 71 | 72 | void init() throws JSchException { 73 | io.setInputStream(getSession().in); 74 | io.setOutputStream(getSession().out); 75 | } 76 | 77 | public void setErrStream(java.io.OutputStream out){ 78 | setExtOutputStream(out); 79 | } 80 | public java.io.InputStream getErrStream() throws java.io.IOException { 81 | return getExtInputStream(); 82 | } 83 | } 84 | --------------------------------------------------------------------------------