Adding public key authenication to AmigaSSH

The SSH client for the Amiga does not support public key authentication yet. How hard is it, to add that feature?
First we have to check if the server announced support for it and check the server's user auth response:
0000: 
00 00 00 2f
 
70 75 62 6c 69 63 6b 65 79 2c 67 73
  
.../
publickey,gs
0016: 
73 61 70 69 2d 6b 65 79 65 78 2c 67 73 73 61 70
  
sapi-keyex,gssap
0032: 
69 2d 77 69 74 68 2d 6d 69 63 2c 70 61 73 73 77
  
i-with-mic,passw
0048: 
6f 72 64
 00                                      
ord
.
If publickey is present, we sent a user auth request containing the public key to check if the public key is authorized:
0000: 00 00 00 00 00 
32
 
00 00 00 06 73 74 65 66 61 6e
  .....
2
....stefan
0016: 
00 00 00 0e 73 73 68 2d 63 6f 6e 6e 65 63 74 69
  
....ssh-connecti
0032: 
6f 6e
 
00 00 00 09 70 75 62 6c 69 63 6b 65 79
 
00
  
on
....publickey
.
0048: 
00 00 00 0b 73 73 68 2d 65 64 32 35 35 31 39
 
00
  
....ssh-ed25519
.
0064: 
00 00 33 00 00 00 0b 73 73 68 2d 65 64 32 35 35
  
..3....ssh-ed255
0080: 
31 39 00 00 00 20 b0 8f 1f 63 74 ac 39 5d 0c 58
  
19... ...ct.9].X
0096: 
20 da 00 05 e1 1e c3 e7 be 37 99 a2 34 a8 ad 28
  
 ........7..4..(
0112: 
00 39 ec 7c 4f 5e
                                
.9.|O^
If the server accepts the key, the answer says the public key is ok (ssh_msg_userauth_pk_ok = 60) and contains the sent key type plus public key blob.
We send again a user auth request containing a signature.
0000: 00 00 00 00 00 
32
 
00 00 00 06 73 74 65 66 61 6e
  .....
2
....stefan
0016: 
00 00 00 0e 73 73 68 2d 63 6f 6e 6e 65 63 74 69
  
....ssh-connecti
0032: 
6f 6e
 
00 00 00 23 70 75 62 6c 69 63 6b 65 79 2d
  
on
...#publickey-
0048: 
68 6f 73 74 62 6f 75 6e 64 2d 76 30 30 40 6f 70
  
hostbound-v00@op
0064: 
65 6e 73 73 68 2e 63 6f 6d
 
01
 
00 00 00 0b 73 73
  
enssh.com
.
....ss
0080: 
68 2d 65 64 32 35 35 31 39
 
00 00 00 33 00 00 00
  
h-ed25519
...3...
0096: 
0b 73 73 68 2d 65 64 32 35 35 31 39 00 00 00 20
  
.ssh-ed25519... 
0112: 
b0 8f 1f 63 74 ac 39 5d 0c 58 20 da 00 05 e1 1e
  
...ct.9].X .....
0128: 
c3 e7 be 37 99 a2 34 a8 ad 28 00 39 ec 7c 4f 5e
  
...7..4..(.9.|O^
0144: 
00 00 00 33 00 00 00 0b 73 73 68 2d 65 64 32 35
  
...3....ssh-ed25
0160: 
35 31 39 00 00 00 20 e0 d9 93 3f b3 e5 23 b7 e4
  
519... ...?..#..
0176: 
fe b1 65 5c 45 ef ba 8d f7 01 d7 20 0e 29 5b 9d
  
..e\E...... .)[.
0192: 
71 a8 c1 35 98 02 0e
 
00 00 00 53 00 00 00 0b 73
  
q..5......S....s
0208: 
73 68 2d 65 64 32 35 35 31 39 00 00 00 40 24 ce
  
sh-ed25519...@$.
0224: 
78 5c fc 18 7a e4 3b fc 37 0f 31 83 2d 17 1b 95
  
x\..z.;.7.1.-...
0240: 
10 0e ed 3b a1 ed 48 41 85 08 53 fe 97 87 0f ff
  
...;..HA..S.....
0256: 
8b 22 94 c4 3e a4 9b 20 9f 2f f3 5f 11 50 fd 76
  
."..>.. ./._.P.v
0272: 
ba 94 9f cd 00 b0 2e b2 4c f1 78 e2 73 03      
  
........L.x.s.
All data is present, we only need the signature. The signature of what exactly?
After some digging, I found that the message to sign contains Now simply call the sign method with this message and the users secret key. And put the 64 byte signature into the signature blob. If the server replied that the public key is ok, then this will succeed and you are logged in.
Don't forget to add your public key to the server's authorized-keys file of the user!