File 3941-Fix-OpenSSH-encoding-of-Ed25519-Ed448.patch of Package erlang
From 032780e579cc35b48a42d01a4dab376a8833248b Mon Sep 17 00:00:00 2001
From: Jon Carstens <jjcarstens@me.com>
Date: Wed, 15 Dec 2021 09:57:06 -0700
Subject: [PATCH] Fix OpenSSH encoding of Ed25519/Ed448
---
lib/ssh/src/ssh_file.erl | 9 ++-------
lib/ssh/src/ssh_message.erl | 11 +++++++----
2 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/lib/ssh/src/ssh_file.erl b/lib/ssh/src/ssh_file.erl
index 676ef333e1..3e3a2a770f 100644
--- a/lib/ssh/src/ssh_file.erl
+++ b/lib/ssh/src/ssh_file.erl
@@ -1018,13 +1018,8 @@ openssh_key_v1_decode(<<?DEC_BIN(Encrypted,_L)>>,
openssh_key_v1_decode_priv_keys(Plain, N, N, [], [])
of
{PrivKeys, _Comments} ->
- lists:map(fun({ {ed_pub,A,Pub}, {ed_pri,A,Pub,Pri0} }) ->
- Pri = binary:part(Pri0, {0,size(Pri0)-size(Pub)}),
- {{ed_pub,A,Pub}, {ed_pri,A,Pub,Pri}};
- (Pair) ->
- Pair
- end, lists:zip(PubKeys, PrivKeys))
- %% end, lists:zip3(PubKeys, PrivKeys,_ Comments))
+ lists:zip(PubKeys, PrivKeys)
+ %% lists:zip3(PubKeys, PrivKeys,_ Comments))
catch
error:{decryption, DecryptError} ->
error({decryption, DecryptError})
diff --git a/lib/ssh/src/ssh_message.erl b/lib/ssh/src/ssh_message.erl
index 8c9a32b25f..0f30ab2cf5 100644
--- a/lib/ssh/src/ssh_message.erl
+++ b/lib/ssh/src/ssh_message.erl
@@ -686,7 +686,7 @@ ssh2_privkey_encode({ed_pri, Alg, Pub, Priv}) ->
Name = atom_to_binary(Alg),
<<?STRING(<<"ssh-",Name/binary>>),
?STRING(Pub),
- ?STRING(Priv)>>.
+ ?STRING(<<Priv/binary,Pub/binary>>)>>.
%%%--------
ssh2_privkey_decode2(<<?UINT32(7), "ssh-rsa",
@@ -736,12 +736,16 @@ ssh2_privkey_decode2(<<?UINT32(TL), "ecdsa-sha2-",KeyRest/binary>>) ->
}, Rest};
ssh2_privkey_decode2(<<?UINT32(11), "ssh-ed25519",
?DEC_BIN(Pub,_Lpub),
- ?DEC_BIN(Priv,_Lpriv),
+ 64:32/unsigned-big-integer,
+ Priv:32/binary,
+ _Pub:32/binary,
Rest/binary>>) ->
{{ed_pri, ed25519, Pub, Priv}, Rest};
ssh2_privkey_decode2(<<?UINT32(9), "ssh-ed448",
?DEC_BIN(Pub,_Lpub),
- ?DEC_BIN(Priv,_Lpriv),
+ 114:32/unsigned-big-integer,
+ Priv:57/binary,
+ _Pub:57/binary,
Rest/binary>>) ->
{{ed_pri, ed448, Pub, Priv}, Rest}.
@@ -938,4 +942,3 @@ ssh_dbg_format(raw_messages, {return_from,{?MODULE,encode,1},BytesPT}) ->
?wr_record(ssh_msg_channel_failure);
wr_record(R) -> io_lib:format('~p~n',[R]).
-
--
2.31.1