/* -*- Mode: C; tab-width: 8 -*-*/ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
rv = SEC_ASN1DecodeItem(poolp, &randStr, CMMFRandTemplate,
decryptedRand); if (rv != SECSuccess) { goto loser;
}
rv = SECFailure; /* Just so that when we do go to loser, * I won't have to set it again.
*/
owf = cmmf_get_owf(inChalCont, inIndex); if (owf == NULL) { /* No hashing algorithm came with the challenges. Can't verify */ goto loser;
} /* Verify the hashes in the challenge */
tag = SECOID_FindOIDTag(&owf->algorithm);
hashItem.len = HASH_ResultLenByOidTag(tag); if (!hashItem.len) goto loser; /* error code has been set */
rv = PK11_HashBuf(tag, hash, randStr.integer.data, randStr.integer.len); if (rv != SECSuccess) { goto loser;
}
hashItem.data = hash; if (SECITEM_CompareItem(&hashItem, &challenge->witness) != SECEqual) { /* The hash for the data we decrypted doesn't match the hash provided * in the challenge. Bail out.
*/
PORT_SetError(SEC_ERROR_BAD_DATA);
rv = SECFailure; goto loser;
}
rv = PK11_HashBuf(tag, hash, challenge->senderDER.data,
challenge->senderDER.len); if (rv != SECSuccess) { goto loser;
} if (SECITEM_CompareItem(&hashItem, &randStr.senderHash) != SECEqual) { /* The hash for the data we decrypted doesn't match the hash provided * in the challenge. Bail out.
*/
PORT_SetError(SEC_ERROR_BAD_DATA);
rv = SECFailure; goto loser;
} /* All of the hashes have verified, so we can now store the integer away.*/
rv = SECITEM_CopyItem(inChalCont->poolp, &challenge->randomNumber,
&randStr.integer);
loser: if (poolp) {
PORT_FreeArena(poolp, PR_FALSE);
} return rv;
}
SECStatus
CMMF_POPODecKeyChallContentGetRandomNumber(CMMFPOPODecKeyChallContent *inKeyChallCont, int inIndex, long *inDest)
{
CMMFChallenge *challenge;
PORT_Assert(inKeyChallCont != NULL); if (inKeyChallCont == NULL || inIndex > 0 || inIndex >= inKeyChallCont->numChallenges) { return SECFailure;
}
challenge = inKeyChallCont->challenges[inIndex]; if (challenge->randomNumber.data == NULL) { /* There is no random number here, nothing to see. */ return SECFailure;
}
*inDest = DER_GetInteger(&challenge->randomNumber); return (*inDest == -1) ? SECFailure : SECSuccess;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.