diff --git a/src/main/java/net/schmizz/sshj/DefaultConfig.java b/src/main/java/net/schmizz/sshj/DefaultConfig.java index d788bd8f..ca446afb 100644 --- a/src/main/java/net/schmizz/sshj/DefaultConfig.java +++ b/src/main/java/net/schmizz/sshj/DefaultConfig.java @@ -56,6 +56,8 @@ import net.schmizz.sshj.transport.mac.HMACMD5; import net.schmizz.sshj.transport.mac.HMACMD596; import net.schmizz.sshj.transport.mac.HMACSHA1; import net.schmizz.sshj.transport.mac.HMACSHA196; +import net.schmizz.sshj.transport.mac.HMACSHA2256; +import net.schmizz.sshj.transport.mac.HMACSHA2512; import net.schmizz.sshj.transport.random.BouncyCastleRandom; import net.schmizz.sshj.transport.random.JCERandom; import net.schmizz.sshj.transport.random.SingletonRandomFactory; @@ -167,7 +169,7 @@ public class DefaultConfig protected void initMACFactories() { setMACFactories(new HMACSHA1.Factory(), new HMACSHA196.Factory(), new HMACMD5.Factory(), - new HMACMD596.Factory()); + new HMACMD596.Factory(), new HMACSHA2256.Factory(), new HMACSHA2512.Factory()); } protected void initCompressionFactories() { diff --git a/src/main/java/net/schmizz/sshj/transport/mac/HMACSHA2256.java b/src/main/java/net/schmizz/sshj/transport/mac/HMACSHA2256.java new file mode 100644 index 00000000..6482c6e4 --- /dev/null +++ b/src/main/java/net/schmizz/sshj/transport/mac/HMACSHA2256.java @@ -0,0 +1,60 @@ +/* + * Copyright 2010-2012 sshj contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file may incorporate work covered by the following copyright and + * permission notice: + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package net.schmizz.sshj.transport.mac; + +/** HMAC-SHA1 MAC */ +public class HMACSHA2256 + extends BaseMAC { + + /** Named factory for the HMAC-SHA1 MAC */ + public static class Factory + implements net.schmizz.sshj.common.Factory.Named { + + @Override + public MAC create() { + return new HMACSHA2256(); + } + + @Override + public String getName() { + return "hmac-sha2-256"; + } + } + + public HMACSHA2256() { + super("HmacSHA256", 20, 20); + } +} diff --git a/src/main/java/net/schmizz/sshj/transport/mac/HMACSHA2512.java b/src/main/java/net/schmizz/sshj/transport/mac/HMACSHA2512.java new file mode 100644 index 00000000..e0bcd75f --- /dev/null +++ b/src/main/java/net/schmizz/sshj/transport/mac/HMACSHA2512.java @@ -0,0 +1,60 @@ +/* + * Copyright 2010-2012 sshj contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file may incorporate work covered by the following copyright and + * permission notice: + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package net.schmizz.sshj.transport.mac; + +/** HMAC-SHA1 MAC */ +public class HMACSHA2512 + extends BaseMAC { + + /** Named factory for the HMAC-SHA1 MAC */ + public static class Factory + implements net.schmizz.sshj.common.Factory.Named { + + @Override + public MAC create() { + return new HMACSHA2512(); + } + + @Override + public String getName() { + return "hmac-sha2-512"; + } + } + + public HMACSHA2512() { + super("HmacSHA512", 20, 20); + } +}