static void setField_Version (
	DecodedItem			&item,
	const CssmData		&fieldValue)
{
	DecodedCert &cert = dynamic_cast<DecodedCert &>(item);
	CSSM_DATA &vers = cert.mCert.tbs.version;
	tbsSetCheck(vers.Data, fieldValue, 0, "version");
	cert.coder().allocCopyItem(fieldValue, vers);
}
static void setField_Version (
	DecodedItem			&item,
	const CssmData		&fieldValue)
{
	DecodedCert &cert = dynamic_cast<DecodedCert &>(item);
	tbsSetCheck(cert.certificateToSign->version, fieldValue, sizeof(uint32),
		"version");

}
static void setField_SerialNumber (
	DecodedItem			&item,
	const CssmData		&fieldValue)
{
	DecodedCert &cert = dynamic_cast<DecodedCert &>(item);
	CSSM_DATA &sn = cert.mCert.tbs.serialNumber;
	tbsSetCheck(sn.Data, fieldValue, 0, "SerialNumber");
	cert.coder().allocCopyItem(fieldValue, sn);
}
static void setField_IssuerUniqueId (
	DecodedItem			&item,
	const CssmData		&fieldValue)
{
	DecodedCert &cert = dynamic_cast<DecodedCert &>(item);
	CSSM_DATA &dstBits = cert.mCert.tbs.issuerID;
	tbsSetCheck(dstBits.Data, fieldValue, 0, "IssuerUniqueID");
	cert.coder().allocCopyItem(fieldValue, dstBits);
	dstBits.Length *= 8;
}
static void setField_NotAfter (
	DecodedItem			&item,
	const CssmData		&fieldValue)
{
	DecodedCert &cert = dynamic_cast<DecodedCert &>(item);
	NSS_Time &dstTime = cert.mCert.tbs.validity.notAfter;
	tbsSetCheck(dstTime.item.Data, fieldValue,
		sizeof(CSSM_X509_TIME), "NotAfter");
	setField_TimeNSS(fieldValue, dstTime, cert.coder());
}
static void setField_TbsAlgId (
	DecodedItem			&item,
	const CssmData		&fieldValue)
{
	DecodedCert &cert = dynamic_cast<DecodedCert &>(item);
	CSSM_X509_ALGORITHM_IDENTIFIER &dstAlgId = cert.mCert.tbs.signature;
	tbsSetCheck(dstAlgId.algorithm.Data, fieldValue,
		sizeof(CSSM_X509_ALGORITHM_IDENTIFIER), "TBS_AlgId");
	setField_AlgIdNSS(fieldValue, dstAlgId, cert.coder());
}
Ejemplo n.º 7
0
static void setField_NextUpdate (
	DecodedItem 		&item,
	const CssmData		&fieldValue)
{
	DecodedCrl &crl = dynamic_cast<DecodedCrl &>(item);
	NSS_Time &dstTime = crl.mCrl.tbs.nextUpdate;
	tbsSetCheck(dstTime.item.Data, fieldValue, 
		sizeof(CSSM_X509_TIME), "NotBefore");
	setField_TimeNSS(fieldValue, dstTime, crl.coder());
}
static void setField_Subject  (
	DecodedItem			&item,
	const CssmData		&fieldValue)
{
	DecodedCert &cert = dynamic_cast<DecodedCert &>(item);
	const CSSM_X509_NAME *cssmName = (const CSSM_X509_NAME *)fieldValue.Data;
	NSS_Name &nssName = cert.mCert.tbs.subject;
	tbsSetCheck(nssName.rdns, fieldValue, sizeof(CSSM_X509_NAME),
		"SubjectName");
	CL_cssmNameToNss(*cssmName, nssName, cert.coder());
}
Ejemplo n.º 9
0
static void setField_Issuer  (
	DecodedItem 		&item,	
	const CssmData		&fieldValue)
{
	DecodedCrl &crl = dynamic_cast<DecodedCrl &>(item);
	const CSSM_X509_NAME *cssmName = (const CSSM_X509_NAME *)fieldValue.Data;
	NSS_Name &nssName = crl.mCrl.tbs.issuer;
	tbsSetCheck(nssName.rdns, fieldValue, sizeof(CSSM_X509_NAME),
		"IssuerName");
	CL_cssmNameToNss(*cssmName, nssName, crl.coder());
}
static void setField_PublicKeyStruct (
	DecodedItem			&item,
	const CssmData		&fieldValue)
{
	DecodedCert &cert = dynamic_cast<DecodedCert &>(item);
	CSSM_X509_SUBJECT_PUBLIC_KEY_INFO &dstKeyInfo =
		cert.mCert.tbs.subjectPublicKeyInfo;
	tbsSetCheck(dstKeyInfo.subjectPublicKey.Data, fieldValue,
		sizeof(CSSM_KEY), "PubKeyStruct");

	CSSM_KEY_PTR cssmKey = (CSSM_KEY_PTR)fieldValue.data();
	if((cssmKey->KeyData.Data == NULL) ||
	   (cssmKey->KeyData.Data == 0)) {
		CssmError::throwMe(CSSMERR_CL_INVALID_FIELD_POINTER);
	}
	CL_CSSMKeyToSubjPubKeyInfoNSS(*cssmKey, dstKeyInfo, cert.coder());
}
static void setField_PublicKeyInfo (
	DecodedItem			&item,
	const CssmData		&fieldValue)
{
	DecodedCert &cert = dynamic_cast<DecodedCert &>(item);
	CSSM_X509_SUBJECT_PUBLIC_KEY_INFO &dstKeyInfo =
		cert.mCert.tbs.subjectPublicKeyInfo;
	tbsSetCheck(dstKeyInfo.subjectPublicKey.Data, fieldValue,
		sizeof(CSSM_X509_SUBJECT_PUBLIC_KEY_INFO), "PubKeyInfo");

	CSSM_X509_SUBJECT_PUBLIC_KEY_INFO *srcKeyInfo =
		(CSSM_X509_SUBJECT_PUBLIC_KEY_INFO *)fieldValue.Data;
	if((srcKeyInfo->subjectPublicKey.Data == NULL) ||
	   (srcKeyInfo->subjectPublicKey.Length == 0)) {
		CssmError::throwMe(CSSMERR_CL_INVALID_FIELD_POINTER);
	}

	ArenaAllocator arenaAlloc(cert.coder());
	CL_copySubjPubKeyInfo(*srcKeyInfo, false,	// length in bytes here
		dstKeyInfo, true,						// length in bits
		arenaAlloc);
}