您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ sshbuf_put_u8函数代码示例

51自学网 2021-06-03 08:19:19
  C++
这篇教程C++ sshbuf_put_u8函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中sshbuf_put_u8函数的典型用法代码示例。如果您正苦于以下问题:C++ sshbuf_put_u8函数的具体用法?C++ sshbuf_put_u8怎么用?C++ sshbuf_put_u8使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了sshbuf_put_u8函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: kex_prop2buf

/* put algorithm proposal into buffer */intkex_prop2buf(struct sshbuf *b, char *proposal[PROPOSAL_MAX]){	u_int i;	int r;	sshbuf_reset(b);	/*	 * add a dummy cookie, the cookie will be overwritten by	 * kex_send_kexinit(), each time a kexinit is set	 */	for (i = 0; i < KEX_COOKIE_LEN; i++) {		if ((r = sshbuf_put_u8(b, 0)) != 0)			return r;	}	for (i = 0; i < PROPOSAL_MAX; i++) {		if ((r = sshbuf_put_cstring(b, proposal[i])) != 0)			return r;	}	if ((r = sshbuf_put_u8(b, 0)) != 0 ||	/* first_kex_packet_follows */	    (r = sshbuf_put_u32(b, 0)) != 0)	/* uint32 reserved */		return r;	return 0;}
开发者ID:djmdjm,项目名称:libopenssh,代码行数:26,


示例2: kexgex_hash

intkexgex_hash(    int hash_alg,    const char *client_version_string,    const char *server_version_string,    const u_char *ckexinit, size_t ckexinitlen,    const u_char *skexinit, size_t skexinitlen,    const u_char *serverhostkeyblob, size_t sbloblen,    int min, int wantbits, int max,    const BIGNUM *prime,    const BIGNUM *gen,    const BIGNUM *client_dh_pub,    const BIGNUM *server_dh_pub,    const BIGNUM *shared_secret,    u_char **hash, size_t *hashlen){	struct sshbuf *b;	static u_char digest[SSH_DIGEST_MAX_LENGTH];	int r;	if ((b = sshbuf_new()) == NULL)		return SSH_ERR_ALLOC_FAIL;	if ((r = sshbuf_put_cstring(b, client_version_string)) != 0 ||	    (r = sshbuf_put_cstring(b, server_version_string)) != 0 ||	    /* kexinit messages: fake header: len+SSH2_MSG_KEXINIT */	    (r = sshbuf_put_u32(b, ckexinitlen+1)) != 0 ||	    (r = sshbuf_put_u8(b, SSH2_MSG_KEXINIT)) != 0 ||	    (r = sshbuf_put(b, ckexinit, ckexinitlen)) != 0 ||	    (r = sshbuf_put_u32(b, skexinitlen+1)) != 0 ||	    (r = sshbuf_put_u8(b, SSH2_MSG_KEXINIT)) != 0 ||	    (r = sshbuf_put(b, skexinit, skexinitlen)) != 0 ||	    (r = sshbuf_put_string(b, serverhostkeyblob, sbloblen)) != 0 ||	    (min != -1 && (r = sshbuf_put_u32(b, min)) != 0) ||	    (r = sshbuf_put_u32(b, wantbits)) != 0 ||	    (max != -1 && (r = sshbuf_put_u32(b, max)) != 0) ||	    (r = sshbuf_put_bignum2(b, prime)) != 0 ||	    (r = sshbuf_put_bignum2(b, gen)) != 0 ||	    (r = sshbuf_put_bignum2(b, client_dh_pub)) != 0 ||	    (r = sshbuf_put_bignum2(b, server_dh_pub)) != 0 ||	    (r = sshbuf_put_bignum2(b, shared_secret)) != 0) {		sshbuf_free(b);		return r;	}#ifdef DEBUG_KEXDH	sshbuf_dump(b, stderr);#endif	if (ssh_digest_buffer(hash_alg, b, digest, sizeof(digest)) != 0) {		sshbuf_free(b);		return SSH_ERR_LIBCRYPTO_ERROR;	}	sshbuf_free(b);	*hash = digest;	*hashlen = ssh_digest_bytes(hash_alg);#ifdef DEBUG_KEXDH	dump_digest("hash", digest, *hashlen);#endif	return 0;}
开发者ID:djmdjm,项目名称:libopenssh,代码行数:59,


示例3: ssh_tty_make_modes

/* * Encodes terminal modes for the terminal referenced by fd * or tiop in a portable manner, and appends the modes to a packet * being constructed. */voidssh_tty_make_modes(struct ssh *ssh, int fd, struct termios *tiop){	struct termios tio;	struct sshbuf *buf;	int r, ibaud, obaud;	if ((buf = sshbuf_new()) == NULL)		fatal("%s: sshbuf_new failed", __func__);	if (tiop == NULL) {		if (fd == -1) {			debug("%s: no fd or tio", __func__);			goto end;		}		if (tcgetattr(fd, &tio) == -1) {			logit("tcgetattr: %.100s", strerror(errno));			goto end;		}	} else		tio = *tiop;	/* Store input and output baud rates. */	obaud = speed_to_baud(cfgetospeed(&tio));	ibaud = speed_to_baud(cfgetispeed(&tio));	if ((r = sshbuf_put_u8(buf, TTY_OP_OSPEED)) != 0 ||	    (r = sshbuf_put_u32(buf, obaud)) != 0 ||	    (r = sshbuf_put_u8(buf, TTY_OP_ISPEED)) != 0 ||	    (r = sshbuf_put_u32(buf, ibaud)) != 0)		fatal("%s: buffer error: %s", __func__, ssh_err(r));	/* Store values of mode flags. */#define TTYCHAR(NAME, OP) /	if ((r = sshbuf_put_u8(buf, OP)) != 0 || /	    (r = sshbuf_put_u32(buf, tio.c_cc[NAME])) != 0) /		fatal("%s: buffer error: %s", __func__, ssh_err(r)); /#define SSH_TTYMODE_IUTF8 42  /* for SSH_BUG_UTF8TTYMODE */#define TTYMODE(NAME, FIELD, OP) /	if (OP == SSH_TTYMODE_IUTF8 && (datafellows & SSH_BUG_UTF8TTYMODE)) { /		debug3("%s: SSH_BUG_UTF8TTYMODE", __func__); /	} else if ((r = sshbuf_put_u8(buf, OP)) != 0 || /	    (r = sshbuf_put_u32(buf, ((tio.FIELD & NAME) != 0))) != 0) /		fatal("%s: buffer error: %s", __func__, ssh_err(r)); /#include "ttymodes.h"#undef TTYCHAR#undef TTYMODEend:	/* Mark end of mode data. */	if ((r = sshbuf_put_u8(buf, TTY_OP_END)) != 0 ||	    (r = sshpkt_put_stringb(ssh, buf)) != 0)		fatal("%s: packet error: %s", __func__, ssh_err(r));	sshbuf_free(buf);}
开发者ID:mfriedl,项目名称:openssh,代码行数:63,


示例4: ssh_add_identity_constrained

/* * Adds an identity to the authentication server. * This call is intended only for use by ssh-add(1) and like applications. */intssh_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_RSA_CERT_V00:	case KEY_DSA:	case KEY_DSA_CERT:	case KEY_DSA_CERT_V00:	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;}
开发者ID:LTD-Beget,项目名称:openssh-portable,代码行数:61,


示例5: kex_ecdh_hash

intkex_ecdh_hash(    const EVP_MD *evp_md,    const EC_GROUP *ec_group,    const char *client_version_string,    const char *server_version_string,    const u_char *ckexinit, size_t ckexinitlen,    const u_char *skexinit, size_t skexinitlen,    const u_char *serverhostkeyblob, size_t sbloblen,    const EC_POINT *client_dh_pub,    const EC_POINT *server_dh_pub,    const BIGNUM *shared_secret,    u_char **hash, size_t *hashlen){	struct sshbuf *b;	EVP_MD_CTX md;	static u_char digest[EVP_MAX_MD_SIZE];	int r;	if ((b = sshbuf_new()) == NULL)		return SSH_ERR_ALLOC_FAIL;	if ((r = sshbuf_put_cstring(b, client_version_string)) != 0 ||	    (r = sshbuf_put_cstring(b, server_version_string)) != 0 ||	    /* kexinit messages: fake header: len+SSH2_MSG_KEXINIT */	    (r = sshbuf_put_u32(b, ckexinitlen+1)) != 0 ||	    (r = sshbuf_put_u8(b, SSH2_MSG_KEXINIT)) != 0 ||	    (r = sshbuf_put(b, ckexinit, ckexinitlen)) != 0 ||	    (r = sshbuf_put_u32(b, skexinitlen+1)) != 0 ||	    (r = sshbuf_put_u8(b, SSH2_MSG_KEXINIT)) != 0 ||	    (r = sshbuf_put(b, skexinit, skexinitlen)) != 0 ||	    (r = sshbuf_put_string(b, serverhostkeyblob, sbloblen)) != 0 ||	    (r = sshbuf_put_ec(b, client_dh_pub, ec_group)) != 0 ||	    (r = sshbuf_put_ec(b, server_dh_pub, ec_group)) != 0 ||	    (r = sshbuf_put_bignum2(b, shared_secret)) != 0) {		sshbuf_free(b);		return r;	}#ifdef DEBUG_KEX	sshbuf_dump(b, stderr);#endif	if (EVP_DigestInit(&md, evp_md) != 1 ||	    EVP_DigestUpdate(&md, sshbuf_ptr(b), sshbuf_len(b)) != 1 ||	    EVP_DigestFinal(&md, digest, NULL) != 1) {		sshbuf_free(b);		return SSH_ERR_LIBCRYPTO_ERROR;	}	sshbuf_free(b);#ifdef DEBUG_KEX	dump_digest("hash", digest, EVP_MD_size(evp_md));#endif	*hash = digest;	*hashlen = EVP_MD_size(evp_md);	return 0;}
开发者ID:hshoexer,项目名称:libopenssh,代码行数:54,


示例6: kex_ecdh_hash

intkex_ecdh_hash(    int hash_alg,    const EC_GROUP *ec_group,    const char *client_version_string,    const char *server_version_string,    const u_char *ckexinit, size_t ckexinitlen,    const u_char *skexinit, size_t skexinitlen,    const u_char *serverhostkeyblob, size_t sbloblen,    const EC_POINT *client_dh_pub,    const EC_POINT *server_dh_pub,    const BIGNUM *shared_secret,    u_char *hash, size_t *hashlen){	struct sshbuf *b;	int r;	if (*hashlen < ssh_digest_bytes(hash_alg))		return SSH_ERR_INVALID_ARGUMENT;	if ((b = sshbuf_new()) == NULL)		return SSH_ERR_ALLOC_FAIL;	if ((r = sshbuf_put_cstring(b, client_version_string)) != 0 ||	    (r = sshbuf_put_cstring(b, server_version_string)) != 0 ||	    /* kexinit messages: fake header: len+SSH2_MSG_KEXINIT */	    (r = sshbuf_put_u32(b, ckexinitlen+1)) != 0 ||	    (r = sshbuf_put_u8(b, SSH2_MSG_KEXINIT)) != 0 ||	    (r = sshbuf_put(b, ckexinit, ckexinitlen)) != 0 ||	    (r = sshbuf_put_u32(b, skexinitlen+1)) != 0 ||	    (r = sshbuf_put_u8(b, SSH2_MSG_KEXINIT)) != 0 ||	    (r = sshbuf_put(b, skexinit, skexinitlen)) != 0 ||	    (r = sshbuf_put_string(b, serverhostkeyblob, sbloblen)) != 0 ||	    (r = sshbuf_put_ec(b, client_dh_pub, ec_group)) != 0 ||	    (r = sshbuf_put_ec(b, server_dh_pub, ec_group)) != 0 ||	    (r = sshbuf_put_bignum2(b, shared_secret)) != 0) {		sshbuf_free(b);		return r;	}#ifdef DEBUG_KEX	sshbuf_dump(b, stderr);#endif	if (ssh_digest_buffer(hash_alg, b, hash, *hashlen) != 0) {		sshbuf_free(b);		return SSH_ERR_LIBCRYPTO_ERROR;	}	sshbuf_free(b);	*hashlen = ssh_digest_bytes(hash_alg);#ifdef DEBUG_KEX	dump_digest("hash", hash, *hashlen);#endif	return 0;}
开发者ID:ajinkya93,项目名称:OpenBSD,代码行数:51,


示例7: ssh_gssapi_last_error

char *ssh_gssapi_last_error(Gssctxt *ctxt, OM_uint32 *major_status,    OM_uint32 *minor_status){	OM_uint32 lmin;	gss_buffer_desc msg = GSS_C_EMPTY_BUFFER;	OM_uint32 ctx;	struct sshbuf *b;	char *ret;	int r;	if ((b = sshbuf_new()) == NULL)		fatal("%s: sshbuf_new failed", __func__);	if (major_status != NULL)		*major_status = ctxt->major;	if (minor_status != NULL)		*minor_status = ctxt->minor;	ctx = 0;	/* The GSSAPI error */	do {		gss_display_status(&lmin, ctxt->major,		    GSS_C_GSS_CODE, ctxt->oid, &ctx, &msg);		if ((r = sshbuf_put(b, msg.value, msg.length)) != 0 ||		    (r = sshbuf_put_u8(b, '/n')) != 0)			fatal("%s: buffer error: %s", __func__, ssh_err(r));		gss_release_buffer(&lmin, &msg);	} while (ctx != 0);	/* The mechanism specific error */	do {		gss_display_status(&lmin, ctxt->minor,		    GSS_C_MECH_CODE, ctxt->oid, &ctx, &msg);		if ((r = sshbuf_put(b, msg.value, msg.length)) != 0 ||		    (r = sshbuf_put_u8(b, '/n')) != 0)			fatal("%s: buffer error: %s", __func__, ssh_err(r));		gss_release_buffer(&lmin, &msg);	} while (ctx != 0);	if ((r = sshbuf_put_u8(b, '/n')) != 0)		fatal("%s: buffer error: %s", __func__, ssh_err(r));	ret = xstrdup((const char *)sshbuf_ptr(b));	sshbuf_free(b);	return (ret);}
开发者ID:djmdjm,项目名称:libopenssh,代码行数:50,


示例8: kbdint_alloc

static struct kbdintctxt *kbdint_alloc(const char *devs){	struct kbdintctxt *kbdintctxt;	struct sshbuf *b;	int i, r;	kbdintctxt = xcalloc(1, sizeof(struct kbdintctxt));	if (strcmp(devs, "") == 0) {		if ((b = sshbuf_new()) == NULL)			fatal("%s: sshbuf_new failed", __func__);		for (i = 0; devices[i]; i++) {			if ((r = sshbuf_putf(b, "%s%s",			    sshbuf_len(b) ? "," : "", devices[i]->name)) != 0)				fatal("%s: buffer error: %s",				    __func__, ssh_err(r));		}		if ((r = sshbuf_put_u8(b, 0)) != 0)			fatal("%s: buffer error: %s", __func__, ssh_err(r));		kbdintctxt->devices = xstrdup((const char *)sshbuf_ptr(b));		sshbuf_free(b);	} else {		kbdintctxt->devices = xstrdup(devs);	}	debug("kbdint_alloc: devices '%s'", kbdintctxt->devices);	kbdintctxt->ctxt = NULL;	kbdintctxt->device = NULL;	kbdintctxt->nreq = 0;	return kbdintctxt;}
开发者ID:djmdjm,项目名称:libopenssh,代码行数:31,


示例9: ssh_update_card

/* * Add/remove an token-based identity from the authentication server. * This call is intended only for use by ssh-add(1) and like applications. */intssh_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;}
开发者ID:nbagwe,项目名称:openssh-portable,代码行数:37,


示例10: process_init

static voidprocess_init(void){	struct sshbuf *msg;	int r;	if ((r = sshbuf_get_u32(iqueue, &version)) != 0)		fatal("%s: buffer error: %s", __func__, ssh_err(r));	verbose("received client version %u", version);	if ((msg = sshbuf_new()) == NULL)		fatal("%s: sshbuf_new failed", __func__);	if ((r = sshbuf_put_u8(msg, SSH2_FXP_VERSION)) != 0 ||	    (r = sshbuf_put_u32(msg, SSH2_FILEXFER_VERSION)) != 0 ||	    /* POSIX rename extension */	    (r = sshbuf_put_cstring(msg, "[email
C++ sshbuf_reset函数代码示例
C++ sshbuf_put_u32函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。