コード例 #1
0
ファイル: rsaalg.c プロジェクト: BGCX261/znos-git
/* generate an rsa secret key with same params as a public key */
static void*
rsa_genfrompk(void *vpub)
{
	RSApub *pub;

	pub = vpub;
	return rsagen(mpsignif(pub->n), mpsignif(pub->ek), 0);
}
コード例 #2
0
ファイル: sshserve.c プロジェクト: aahud/harvey
void
main(int argc, char **argv)
{
	char *f[16];
	int i;
	Conn c;

	fmtinstall('B', mpfmt);
	fmtinstall('H', encodefmt);
	atexit(atexitkiller);
	atexitkill(getpid());

	memset(&c, 0, sizeof c);

	ARGBEGIN{
	case 'D':
		debuglevel = atoi(EARGF(usage()));
		break;
	case 'A':
		authlist = EARGF(usage());
		break;
	case 'c':
		cipherlist = EARGF(usage());
		break;
	default:
		usage();
	}ARGEND

	if(argc != 1)
		usage();
	c.host = argv[0];

	sshlog("connect from %s", c.host);

	/* limit of 768 bits in remote host key? */
	c.serverpriv = rsagen(768, 6, 0);
	if(c.serverpriv == nil)
		sysfatal("rsagen failed: %r");
	c.serverkey = &c.serverpriv->pub;

	c.nokcipher = getfields(cipherlist, f, nelem(f), 1, ", ");
	c.okcipher = emalloc(sizeof(Cipher*)*c.nokcipher);
	for(i=0; i<c.nokcipher; i++)
		c.okcipher[i] = findcipher(f[i], allcipher, nelem(allcipher));

	c.nokauthsrv = getfields(authlist, f, nelem(f), 1, ", ");
	c.okauthsrv = emalloc(sizeof(Authsrv*)*c.nokauthsrv);
	for(i=0; i<c.nokauthsrv; i++)
		c.okauthsrv[i] = findauthsrv(f[i], allauthsrv, nelem(allauthsrv));

	sshserverhandshake(&c);

	fromnet(&c);
}
コード例 #3
0
ファイル: rsaalg.c プロジェクト: BGCX261/znos-git
/* generate an rsa secret key */
static void*
rsa_gen(int len)
{
	RSApriv *key;

	for(;;){
		key = rsagen(len, 6, 0);
		if(mpsignif(key->pub.n) == len)
			return key;
		rsaprivfree(key);
	}
}