FreeBSD/crypto/openssh/authfd.c
/*
 * Add/remove an token-based identity from the authentication server.
 * This call is intended only for use by ssh-add(1) and like applications.
 */
Add/remove an token-based identity from the authentication server.
This call is intended only for use by ssh-add(1) and like applications.
Add / remove an token - based identity from the authentication server . This call is intended only for use by ssh - add ( 1 ) and like applications .
int
ssh_update_card(int sock, int add, const char *reader_id, const char *pin,
    u_int life, u_int confirm)
{
	struct sshbuf *msg;
	int r, constrained = (life || confirm);
	u_char type;
	if (add) {
		type = constrained ?
		    SSH_AGENTC_ADD_SMARTCARD_KEY_CONSTRAINED :
		    SSH_AGENTC_ADD_SMARTCARD_KEY;
	} else
		type = SSH_AGENTC_REMOVE_SMARTCARD_KEY;
	if ((msg = sshbuf_new()) == NULL)
		return SSH_ERR_ALLOC_FAIL;
	if ((r = sshbuf_put_u8(msg, type)) != 0 ||
	    (r = sshbuf_put_cstring(msg, reader_id)) != 0 ||
	    (r = sshbuf_put_cstring(msg, pin)) != 0)
		goto out;
	if (constrained &&
	    (r = encode_constraints(msg, life, confirm)) != 0)
		goto out;
	if ((r = ssh_request_reply(sock, msg, msg)) != 0)
		goto out;
	if ((r = sshbuf_get_u8(msg, &type)) != 0)
		goto out;
	r = decode_reply(type);
 out:
	sshbuf_free(msg);
	return r;
}
int ssh_update_card ( int sock , int add , const char * reader_id , const char * pin , u_int life , u_int confirm ) { struct sshbuf * msg ; int r , constrained = ( life || confirm ) ; u_char type ; if ( add ) { type = constrained ? SSH_AGENTC_ADD_SMARTCARD_KEY_CONSTRAINED : SSH_AGENTC_ADD_SMARTCARD_KEY ; } else type = SSH_AGENTC_REMOVE_SMARTCARD_KEY ; if ( ( msg = sshbuf_new ( ) ) == NULL ) return SSH_ERR_ALLOC_FAIL ; if ( ( r = sshbuf_put_u8 ( msg , type ) ) != 0 || ( r = sshbuf_put_cstring ( msg , reader_id ) ) != 0 || ( r = sshbuf_put_cstring ( msg , pin ) ) != 0 ) goto out ; if ( constrained && ( r = encode_constraints ( msg , life , confirm ) ) != 0 ) goto out ; if ( ( r = ssh_request_reply ( sock , msg , msg ) ) != 0 ) goto out ; if ( ( r = sshbuf_get_u8 ( msg , & type ) ) != 0 ) goto out ; r = decode_reply ( type ) ; out : sshbuf_free ( msg ) ; return r ; }
Add/remove an token-based identity from the authentication server.
Add / remove an token - based identity from the authentication server .