bool RSAPrivateKey::deserialise(ByteString& serialised)
{
	ByteString dP = ByteString::chainDeserialise(serialised);
	ByteString dQ = ByteString::chainDeserialise(serialised);
	ByteString dPQ = ByteString::chainDeserialise(serialised);
	ByteString dDP1 = ByteString::chainDeserialise(serialised);
	ByteString dDQ1 = ByteString::chainDeserialise(serialised);
	ByteString dD = ByteString::chainDeserialise(serialised);
	ByteString dN = ByteString::chainDeserialise(serialised);
	ByteString dE = ByteString::chainDeserialise(serialised);

	if ((dD.size() == 0) ||
	    (dN.size() == 0) ||
	    (dE.size() == 0))
	{
		return false;
	}

	setP(dP);
	setQ(dQ);
	setPQ(dPQ);
	setDP1(dDP1);
	setDQ1(dDQ1);
	setD(dD);
	setN(dN);
	setE(dE);

	return true;
}
예제 #2
0
// Set from OpenSSL representation
void OSSLRSAPrivateKey::setFromOSSL(const RSA* inRSA)
{
	if (inRSA->p)
	{
		ByteString inP = OSSL::bn2ByteString(inRSA->p);
		setP(inP);
	}
	if (inRSA->q)
	{
		ByteString inQ = OSSL::bn2ByteString(inRSA->q);
		setQ(inQ);
	}
	if (inRSA->dmp1)
	{
		ByteString inDP1 = OSSL::bn2ByteString(inRSA->dmp1);
		setDP1(inDP1);
	}
	if (inRSA->dmq1)
	{
		ByteString inDQ1 = OSSL::bn2ByteString(inRSA->dmq1);
		setDQ1(inDQ1);
	}
	if (inRSA->iqmp)
	{
		ByteString inPQ = OSSL::bn2ByteString(inRSA->iqmp);
		setPQ(inPQ);
	}
	if (inRSA->d)
	{
		ByteString inD = OSSL::bn2ByteString(inRSA->d);
		setD(inD);
	}
	if (inRSA->n)
	{
		ByteString inN = OSSL::bn2ByteString(inRSA->n);
		setN(inN);
	}
	if (inRSA->e)
	{
		ByteString inE = OSSL::bn2ByteString(inRSA->e);
		setE(inE);
	}
}
예제 #3
0
// Set from Botan representation
void BotanRSAPrivateKey::setFromBotan(const Botan::RSA_PrivateKey* inRSA)
{
	ByteString inP = BotanUtil::bigInt2ByteString(inRSA->get_p());
	setP(inP);
	ByteString inQ = BotanUtil::bigInt2ByteString(inRSA->get_q());
	setQ(inQ);
	ByteString inDP1 = BotanUtil::bigInt2ByteString(inRSA->get_d1());
	setDP1(inDP1);
	ByteString inDQ1 = BotanUtil::bigInt2ByteString(inRSA->get_d2());
	setDQ1(inDQ1);
	ByteString inPQ = BotanUtil::bigInt2ByteString(inRSA->get_c());
	setPQ(inPQ);
	ByteString inD = BotanUtil::bigInt2ByteString(inRSA->get_d());
	setD(inD);
	ByteString inN = BotanUtil::bigInt2ByteString(inRSA->get_n());
	setN(inN);
	ByteString inE = BotanUtil::bigInt2ByteString(inRSA->get_e());
	setE(inE);
}
// Set from Botan representation
void BotanRSAPrivateKey::setFromBotan(const Botan::RSA_PrivateKey* rsa)
{
	ByteString p = BotanUtil::bigInt2ByteString(rsa->get_p());
	setP(p);
	ByteString q = BotanUtil::bigInt2ByteString(rsa->get_q());
	setQ(q);
	ByteString dp1 = BotanUtil::bigInt2ByteString(rsa->get_d1());
	setDP1(dp1);
	ByteString dq1 = BotanUtil::bigInt2ByteString(rsa->get_d2());
	setDQ1(dq1);
	ByteString pq = BotanUtil::bigInt2ByteString(rsa->get_c());
	setPQ(pq);
	ByteString d = BotanUtil::bigInt2ByteString(rsa->get_d());
	setD(d);
	ByteString n = BotanUtil::bigInt2ByteString(rsa->get_n());
	setN(n);
	ByteString e = BotanUtil::bigInt2ByteString(rsa->get_e());
	setE(e);
}