@@ -30,6 +30,9 @@ private OpenSSHPublicKeyUtil()
3030 private static final String ED_25519 = "ssh-ed25519" ;
3131 private static final String DSS = "ssh-dss" ;
3232
33+ private static final String FIDO2_EC_P256 =
"[email protected] " ;
34+ private static final String FIDO_ED_25519 =
"[email protected] " ;
35+
3336 /**
3437 * Parse a public key.
3538 * <p>
@@ -167,6 +170,29 @@ else if (magic.startsWith(ECDSA))
167170 curve .decodePoint (pointRaw ),
168171 new ECNamedDomainParameters (oid , x9ECParameters ));
169172 }
173+ else if (magic .equals (FIDO2_EC_P256 ))
174+ {
175+ String curveName = buffer .readString ();
176+
177+ ASN1ObjectIdentifier oid = SSHNamedCurves .getByName (curveName );
178+ X9ECParameters x9ECParameters = SSHNamedCurves .getParameters (oid );
179+
180+ if (x9ECParameters == null )
181+ {
182+ throw new IllegalStateException ("unable to find curve for " + magic + " using curve name " + curveName );
183+ }
184+
185+ ECCurve curve = x9ECParameters .getCurve ();
186+
187+ byte [] pointRaw = buffer .readBlock ();
188+
189+ // TODO: at the moment we have no use for this, but it's there.
190+ String application = buffer .readString ();
191+
192+ result = new ECPublicKeyParameters (
193+ curve .decodePoint (pointRaw ),
194+ new ECNamedDomainParameters (oid , x9ECParameters ));
195+ }
170196 else if (ED_25519 .equals (magic ))
171197 {
172198 byte [] pubKeyBytes = buffer .readBlock ();
@@ -177,6 +203,19 @@ else if (ED_25519.equals(magic))
177203
178204 result = new Ed25519PublicKeyParameters (pubKeyBytes , 0 );
179205 }
206+ else if (FIDO2_EC_P256 .equals (magic ))
207+ {
208+ byte [] pubKeyBytes = buffer .readBlock ();
209+ if (pubKeyBytes .length != Ed25519PublicKeyParameters .KEY_SIZE )
210+ {
211+ throw new IllegalStateException ("public key value of wrong length" );
212+ }
213+
214+ // TODO: at the moment we have no use for this, but it's there.
215+ String application = buffer .readString ();
216+
217+ result = new Ed25519PublicKeyParameters (pubKeyBytes , 0 );
218+ }
180219
181220 if (result == null )
182221 {
0 commit comments