File 0389-ssh-Fixup-the-ssh_file-src-and-doc-in-maint-regardin.patch of Package erlang
From ecafec2bea5c5263d50e0e3364155aba91170ce8 Mon Sep 17 00:00:00 2001
From: Hans Nilsson <hans@erlang.org>
Date: Mon, 14 Feb 2022 07:57:32 +0100
Subject: [PATCH] ssh: Fixup the ssh_file (src and doc) in maint regarding
Edwards curves
They are already changed in master
---
lib/ssh/doc/src/ssh_file.xml | 49 +++++++++++++++---------------
lib/ssh/src/ssh_file.erl | 59 ++++++++++++++++++++++++++++--------
2 files changed, 70 insertions(+), 38 deletions(-)
diff --git a/lib/ssh/doc/src/ssh_file.xml b/lib/ssh/doc/src/ssh_file.xml
index 941d68d297..8f52f17826 100644
--- a/lib/ssh/doc/src/ssh_file.xml
+++ b/lib/ssh/doc/src/ssh_file.xml
@@ -220,6 +220,24 @@ key :: % encoded key from eg ssh_host_*.pub
</desc>
</datatype>
+ <datatype>
+ <name name="key"/>
+ <desc>
+ <p>The key representation.</p>
+ </desc>
+ </datatype>
+
+ <datatype>
+ <name name="experimental_openssh_key_v1"/>
+ <name name="openssh_key_v1_attributes"/>
+ <desc>
+ <p>Types for the experimental implementaition of the <c>openssh_key_v1</c> format.
+ The <c>#ECPoint{}</c> and <c>ECPrivateKey{}</c> are not used for Edwards curves
+ (ed25519 and ed448), but will be in next major release.
+ </p>
+ </desc>
+ </datatype>
+
</datatypes>
<funcs>
@@ -349,19 +367,8 @@ key :: % encoded key from eg ssh_host_*.pub
</func>
<func>
- <name since="OTP 24.0">decode(SshBin, ssh2_pubkey) -> Key</name>
- <name since="OTP 24.0">decode(SshBin, rfc4716_key) -> ResultRfc4716</name>
- <name since="OTP 24.0">decode(SshBin, openssh_key) -> ResultOpenSsh</name>
- <name since="OTP 24.0">decode(SshBin, public_key) -> ResultRfc4716 | ResultOpenSsh</name>
- <fsummary>Decodes an SSH binary.</fsummary>
- <type>
- <v>SshBin = binary()</v>
- <v>ResultRfc4716 = [{Key, [{headers,Hdrs}]}] | Error</v>
- <v>ResultOpenSsh = [{Key, [{comment,string()}]}] | Error</v>
- <v>Key = <seetype marker="public_key:public_key#public_key">public_key:public_key()</seetype></v>
- <v>Hdrs = [{Tag::string(), Value::string()}]</v>
- <v>Error = {error,term()}</v>
- </type>
+ <name since="OTP 24.0" name="decode" arity="2"/>
+ <fsummary></fsummary>
<desc>
<p>Decodes an SSH file-binary.</p>
<p>If <c>Type</c> is <c>public_key</c> the binary can be either
@@ -374,22 +381,13 @@ key :: % encoded key from eg ssh_host_*.pub
<item>openssh_public_key -> openssh_key</item>
</list>
</note>
+ <note><p>The implementation of the <c>openssh_key_v1</c> format is still experimental.</p></note>
</desc>
</func>
<func>
- <name since="OTP 24.0">encode(Key, ssh2_pubkey) -> Result</name>
- <name since="OTP 24.0">encode(KeyAttrsRfc4716, rfc4716_key) -> Result</name>
- <name since="OTP 24.0">encode(KeyAttrsOpenSsh, openssh_key) -> Result</name>
- <fsummary>Encodes a list of SSH file entries to a binary.</fsummary>
- <type>
- <v>Key = <seetype marker="public_key:public_key#public_key">public_key:public_key()</seetype></v>
- <v>Result = binary() | Error</v>
- <v>KeyAttrsRfc4716 = [{Key, [{headers,Hdrs}]}] | Error</v>
- <v>KeyAttrsOpenSsh = [{Key, [{comment,string()}]}] | Error</v>
- <v>Hdrs = [{Tag::string(), Value::string()}]</v>
- <v>Error = {error,term()}</v>
- </type>
+ <name since="OTP 24.0" name="encode" arity="2"/>
+ <fsummary></fsummary>
<desc>
<p>Encodes a list of SSH file entries (public keys and attributes) to a binary.</p>
<note>
@@ -400,6 +398,7 @@ key :: % encoded key from eg ssh_host_*.pub
<item>openssh_public_key -> openssh_key</item>
</list>
</note>
+ <note><p>The implementation of the <c>openssh_key_v1</c> format is still experimental.</p></note>
</desc>
</func>
diff --git a/lib/ssh/src/ssh_file.erl b/lib/ssh/src/ssh_file.erl
index 3e3a2a770f..721fbd774e 100644
--- a/lib/ssh/src/ssh_file.erl
+++ b/lib/ssh/src/ssh_file.erl
@@ -65,6 +65,13 @@
-type optimize_key_lookup() :: {optimize, time|space} .
+-type key() :: public_key:public_key() | public_key:private_key() .
+-type experimental_openssh_key_v1() :: [{key()
+ | {ed_pri, ed25519|ed448, Pub::binary(), Priv::binary()}
+ | {ed_pub, ed25519|ed448, Key::binary()},
+ openssh_key_v1_attributes()}].
+-type openssh_key_v1_attributes() :: [{atom(),term()}].
+
%%%================================================================
%%%
%%% API
@@ -155,7 +162,7 @@ add_host_key(Hosts0, Port, Key, Opts) ->
%%%---------------- UTILITY API -----------------------------------
%%% In public key before OTP-24.0 as ssh_decode/2 and ssh_encode/2
--spec decode(SshBin, Type) -> Decoded
+-spec decode(SshBin, Type) -> Decoded | {error,term()}
when SshBin :: binary(),
Type :: ssh2_pubkey
| public_key
@@ -164,12 +171,27 @@ add_host_key(Hosts0, Port, Key, Opts) ->
| openssh_key_v1 % Experimental
| known_hosts
| auth_keys,
- Decoded :: public_key:public_key()
- | [{public_key:public_key(), [{headers,Attrs}]}]
- | [{public_key:public_key(), [{comment,string()}]}]
- | {error, term()},
- Attrs :: {Key::string()|atom(), Value::string()}
- .
+ Decoded :: Decoded_ssh2_pubkey
+ | Decoded_public
+ | Decoded_openssh
+ | Decoded_rfc4716
+ | Decoded_openssh_key_v1
+ | Decoded_known_hosts
+ | Decoded_auth_keys,
+
+ Decoded_ssh2_pubkey :: public_key:public_key(),
+ Decoded_public :: Decoded_rfc4716
+ | Decoded_openssh_key_v1
+ | Decoded_openssh,
+ Decoded_openssh :: [{public_key:public_key(), [{comment,string()}]}],
+ Decoded_rfc4716 :: [{key(), [{headers,Attrs}]}],
+ Decoded_openssh_key_v1 :: experimental_openssh_key_v1(),
+ Decoded_known_hosts :: [{public_key:public_key(), [{comment,string()}
+ | {hostnames,[string()]}]}],
+ Decoded_auth_keys :: [{public_key:public_key(), [{comment,string()}
+ | {options,[string()]}]}],
+ Attrs :: {Key::string(), Value::string()} .
+
decode(KeyBin, ssh2_pubkey) when is_binary(KeyBin) ->
ssh_message:ssh2_pubkey_decode(KeyBin);
@@ -285,12 +307,23 @@ decode(_KeyBin, _Type) ->
| openssh_key_v1 % Experimental
| known_hosts
| auth_keys,
- InData :: public_key:public_key()
- | [{public_key:public_key(), [{headers,Attrs}]}]
- | [{public_key:public_key(), [{comment,string()}]}]
- | {error, term()},
- Attrs :: {Key::string()|atom(), Value::string()}
- .
+ InData :: InData_ssh2_pubkey
+ | InData_openssh
+ | InData_rfc4716
+ | InData_openssh_key_v1
+ | InData_known_hosts
+ | InData_auth_keys,
+
+ InData_ssh2_pubkey :: public_key:public_key(),
+ InData_openssh :: [{public_key:public_key(), [{comment,string()}]}],
+ InData_rfc4716 :: [{key(), [{headers,Attrs}]}],
+ InData_openssh_key_v1 :: experimental_openssh_key_v1(),
+ InData_known_hosts :: [{public_key:public_key(), [{comment,string()}
+ | {hostnames,[string()]}]}],
+ InData_auth_keys :: [{public_key:public_key(), [{comment,string()}
+ | {options,[string()]}]}],
+ Attrs :: {Key::string(), Value::string()} .
+
encode(Key, ssh2_pubkey) ->
ssh_message:ssh2_pubkey_encode(Key);
--
2.34.1