Skip to content

Commit a577426

Browse files
ssh: send (and rename) keyboard-interactive name field to the client
The server side implementation was not actually populating the SSH_MSG_USERAUTH_INFO_REQUEST field with the KeyboardInteractiveChallenge argument, although the client side was deserializing it and passing it to the KeyboardInteractiveChallenge callback. Anyway, the first field of SSH_MSG_USERAUTH_INFO_REQUEST is "name", not "user". Maybe the confusion was due to the first field of SSH_MSG_USERAUTH_REQUEST being the user. RFC 4256, Section 3.3, says this about it One possibility is to use the name field (possibly prefixed with the application's name) as the title of a dialog window in which the prompt(s) are presented. and examples include "CRYPTOCard Authentication", "Password Authentication", and "Password Expired". Co-authored-by: Kevin Wallace <[email protected]> Change-Id: Ic6ec0dfea2122704603c44f42898a980689a15c9 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/372234 Trust: Filippo Valsorda <[email protected]> Run-TryBot: Filippo Valsorda <[email protected]> Reviewed-by: Roland Shoemaker <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 1baeb1c commit a577426

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

ssh/client_auth.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,10 @@ func handleBannerResponse(c packetConn, packet []byte) error {
380380
// disabling echoing (e.g. for passwords), and return all the answers.
381381
// Challenge may be called multiple times in a single session. After
382382
// successful authentication, the server may send a challenge with no
383-
// questions, for which the user and instruction messages should be
383+
// questions, for which the name and instruction messages should be
384384
// printed. RFC 4256 section 3.3 details how the UI should behave for
385385
// both CLI and GUI environments.
386-
type KeyboardInteractiveChallenge func(user, instruction string, questions []string, echos []bool) (answers []string, err error)
386+
type KeyboardInteractiveChallenge func(name, instruction string, questions []string, echos []bool) (answers []string, err error)
387387

388388
// KeyboardInteractive returns an AuthMethod using a prompt/response
389389
// sequence controlled by the server.
@@ -465,7 +465,7 @@ func (cb KeyboardInteractiveChallenge) auth(session []byte, user string, c packe
465465
return authFailure, nil, errors.New("ssh: extra data following keyboard-interactive pairs")
466466
}
467467

468-
answers, err := cb(msg.User, msg.Instruction, prompts, echos)
468+
answers, err := cb(msg.Name, msg.Instruction, prompts, echos)
469469
if err != nil {
470470
return authFailure, nil, err
471471
}

ssh/messages.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,11 @@ const msgUserAuthInfoRequest = 60
180180
const msgUserAuthInfoResponse = 61
181181

182182
type userAuthInfoRequestMsg struct {
183-
User string `sshtype:"60"`
184-
Instruction string
185-
DeprecatedLanguage string
186-
NumPrompts uint32
187-
Prompts []byte `ssh:"rest"`
183+
Name string `sshtype:"60"`
184+
Instruction string
185+
Language string
186+
NumPrompts uint32
187+
Prompts []byte `ssh:"rest"`
188188
}
189189

190190
// See RFC 4254, section 5.1.

ssh/server.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ type sshClientKeyboardInteractive struct {
695695
*connection
696696
}
697697

698-
func (c *sshClientKeyboardInteractive) Challenge(user, instruction string, questions []string, echos []bool) (answers []string, err error) {
698+
func (c *sshClientKeyboardInteractive) Challenge(name, instruction string, questions []string, echos []bool) (answers []string, err error) {
699699
if len(questions) != len(echos) {
700700
return nil, errors.New("ssh: echos and questions must have equal length")
701701
}
@@ -707,6 +707,7 @@ func (c *sshClientKeyboardInteractive) Challenge(user, instruction string, quest
707707
}
708708

709709
if err := c.transport.writePacket(Marshal(&userAuthInfoRequestMsg{
710+
Name: name,
710711
Instruction: instruction,
711712
NumPrompts: uint32(len(questions)),
712713
Prompts: prompts,

0 commit comments

Comments
 (0)