FreeBSD/crypto/openssh/authfd.c
/*
 * Adds an identity to the authentication server.
 * This call is intended only for use by ssh-add(1) and like applications.
 */
Adds an identity to the authentication server.
This call is intended only for use by ssh-add(1) and like applications.
Adds an identity to the authentication server . This call is intended only for use by ssh - add ( 1 ) and like applications .
int
ssh_add_identity_constrained(int sock, struct sshkey *key, const char *comment,
    u_int life, u_int confirm)
{
	struct sshbuf *msg;
	int r, constrained = (life || confirm);
	u_char type;
	if ((msg = sshbuf_new()) == NULL)
		return SSH_ERR_ALLOC_FAIL;
	switch (key->type) {
#ifdef WITH_SSH1
	case KEY_RSA1:
		type = constrained ?
		    SSH_AGENTC_ADD_RSA_ID_CONSTRAINED :
		    SSH_AGENTC_ADD_RSA_IDENTITY;
		if ((r = sshbuf_put_u8(msg, type)) != 0 ||
		    (r = ssh_encode_identity_rsa1(msg, key->rsa, comment)) != 0)
			goto out;
		break;
#endif
#ifdef WITH_OPENSSL
	case KEY_RSA:
	case KEY_RSA_CERT:
	case KEY_DSA:
	case KEY_DSA_CERT:
	case KEY_ECDSA:
	case KEY_ECDSA_CERT:
#endif
	case KEY_ED25519:
	case KEY_ED25519_CERT:
		type = constrained ?
		    SSH2_AGENTC_ADD_ID_CONSTRAINED :
		    SSH2_AGENTC_ADD_IDENTITY;
		if ((r = sshbuf_put_u8(msg, type)) != 0 ||
		    (r = ssh_encode_identity_ssh2(msg, key, comment)) != 0)
			goto out;
		break;
	default:
		r = SSH_ERR_INVALID_ARGUMENT;
		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_add_identity_constrained ( int sock , struct sshkey * key , const char * comment , u_int life , u_int confirm ) { struct sshbuf * msg ; int r , constrained = ( life || confirm ) ; u_char type ; if ( ( msg = sshbuf_new ( ) ) == NULL ) return SSH_ERR_ALLOC_FAIL ; switch ( key -> type ) { #ifdef WITH_SSH1 case KEY_RSA1 : type = constrained ? SSH_AGENTC_ADD_RSA_ID_CONSTRAINED : SSH_AGENTC_ADD_RSA_IDENTITY ; if ( ( r = sshbuf_put_u8 ( msg , type ) ) != 0 || ( r = ssh_encode_identity_rsa1 ( msg , key -> rsa , comment ) ) != 0 ) goto out ; break ; #endif #ifdef WITH_OPENSSL case KEY_RSA : case KEY_RSA_CERT : case KEY_DSA : case KEY_DSA_CERT : case KEY_ECDSA : case KEY_ECDSA_CERT : #endif case KEY_ED25519 : case KEY_ED25519_CERT : type = constrained ? SSH2_AGENTC_ADD_ID_CONSTRAINED : SSH2_AGENTC_ADD_IDENTITY ; if ( ( r = sshbuf_put_u8 ( msg , type ) ) != 0 || ( r = ssh_encode_identity_ssh2 ( msg , key , comment ) ) != 0 ) goto out ; break ; default : r = SSH_ERR_INVALID_ARGUMENT ; 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 ; }
Adds an identity to the authentication server.
Adds an identity to the authentication server .