static SECStatus OurVerifyData(unsigned char *buf, int len, SECKEYPublicKey *key, SECItem *sig, SECAlgorithmID *sigAlgorithm) { SECStatus rv; VFYContext *cx; SECOidData *sigAlgOid, *oiddata; SECOidTag sigAlgTag; SECOidTag hashAlgTag; int showDigestOid=0; cx = VFY_CreateContextWithAlgorithmID(key, sig, sigAlgorithm, &hashAlgTag, NULL); if (cx == NULL) return SECFailure; sigAlgOid = SECOID_FindOID(&sigAlgorithm->algorithm); if (sigAlgOid == 0) return SECFailure; sigAlgTag = sigAlgOid->offset; if (showDigestOid) { oiddata = SECOID_FindOIDByTag(hashAlgTag); if ( oiddata ) { printf("PROBLEM: (cont) Digest OID is %s\n", oiddata->desc); } else { SECU_PrintAsHex(stdout, &oiddata->oid, "PROBLEM: UNKNOWN OID", 0); } } rv = VFY_Begin(cx); if (rv == SECSuccess) { rv = VFY_Update(cx, buf, len); if (rv == SECSuccess) rv = VFY_End(cx); } VFY_DestroyContext(cx, PR_TRUE); return rv; }
CryptoX_Result CryptoMac_VerifyUpdate(CryptoX_SignatureHandle* aInputData, void* aBuf, unsigned int aLen) { if (!OnLionOrLater()) { return VFY_Update((VFYContext*)*aInputData, (const unsigned char*)aBuf, aLen); } if (aLen == 0) { return CryptoX_Success; } if (!aInputData || !*aInputData) { return CryptoX_Error; } CryptoX_Result result = CryptoX_Error; CFDataAppendBytes((CFMutableDataRef)*aInputData, (const UInt8 *) aBuf, aLen); if (*aInputData) { result = CryptoX_Success; } return result; }