[
https://issues.apache.org/jira/browse/SSHD-704?focusedWorklogId=597409&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-597409
]
ASF GitHub Bot logged work on SSHD-704:
---------------------------------------
Author: ASF GitHub Bot
Created on: 16/May/21 18:23
Start Date: 16/May/21 18:23
Worklog Time Spent: 10m
Work Description: jvz commented on a change in pull request #177:
URL: https://github.com/apache/mina-sshd/pull/177#discussion_r633122293
##########
File path:
sshd-core/src/main/java/org/apache/sshd/common/kex/MontgomeryCurve.java
##########
@@ -0,0 +1,158 @@
+/*
+ * 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 org.apache.sshd.common.kex;
+
+import java.io.IOException;
+import java.io.StreamCorruptedException;
+import java.io.UncheckedIOException;
+import java.security.GeneralSecurityException;
+import java.security.InvalidKeyException;
+import java.security.KeyFactory;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.PublicKey;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.X509EncodedKeySpec;
+
+import javax.crypto.KeyAgreement;
+
+import org.apache.sshd.common.OptionalFeature;
+import org.apache.sshd.common.digest.BuiltinDigests;
+import org.apache.sshd.common.digest.Digest;
+import org.apache.sshd.common.digest.DigestFactory;
+import org.apache.sshd.common.keyprovider.KeySizeIndicator;
+import org.apache.sshd.common.util.io.der.ASN1Object;
+import org.apache.sshd.common.util.io.der.DERParser;
+import org.apache.sshd.common.util.security.SecurityUtils;
+
+/**
+ * Provides implementation details for Montgomery curves and their key
exchange algorithms Curve25519/X25519 and
+ * Curve448/X448 specified in RFC 7748 and RFC 8731. Montgomery curves provide
improved security and flexibility over
+ * Weierstrass curves used in ECDH.
+ *
+ * @see <a href="https://www.rfc-editor.org/info/rfc7748">RFC 7748</a>
+ * @see <a href="https://www.rfc-editor.org/info/rfc8731">RFC 8731</a>
+ */
+public enum MontgomeryCurve implements KeySizeIndicator, OptionalFeature {
+
+ /**
+ * X25519 uses Curve25519 and SHA-256 with a 32-byte key size.
+ */
+ x25519("X25519", 32, BuiltinDigests.sha256,
+ new byte[] { 0x30, 0x2a, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x6e,
0x03, 0x21, 0x00 }),
Review comment:
While I originally considered this idea to be a bit hacky, I've since
seen it in more than one other XDH implementation for Java. The X.509 encoded
form of an X25519 or X448 key are always going to have the same prefix data
(the algorithm id and key length in some ASN.1 format). Thus, we can portably
use the `X509EncodedKeySpec` class to serialize and deserialize XDH public keys
without needing a full ASN.1/DER encoding library like in BouncyCastle.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 597409)
Time Spent: 1h 10m (was: 1h)
> Add support for [email protected] key exchange
> ----------------------------------------------------------
>
> Key: SSHD-704
> URL: https://issues.apache.org/jira/browse/SSHD-704
> Project: MINA SSHD
> Issue Type: Improvement
> Affects Versions: 1.4.0
> Reporter: Lyor Goldstein
> Priority: Major
> Labels: features
> Attachments: Curve25519.java, Curve25519SHA256AbstractDH.java,
> Curve25519SHA256DHFactory.java, Curve25519SHA256KeyExchange.java,
> Curve25519SHA256KeyExchangeFactory.java
>
> Time Spent: 1h 10m
> Remaining Estimate: 0h
>
> See
> * [[email protected] kexy exchange
> specification|https://git.libssh.org/projects/libssh.git/tree/doc/[email protected]]
> * [Secure Shell (SSH) Key Exchange Method using Curve25519 and
> Curve448|https://tools.ietf.org/html/draft-ietf-curdle-ssh-curves-06]
> * [JEP 324: Key Agreement with Curve25519 and
> Curve448|http://openjdk.java.net/jeps/324]
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]