} else { requiredUsage |= KU_KEY_ENCIPHERMENT; }   requiredUsage &= (~KU_KEY_AGREEMENT_OR_ENCIPHERMENT);  SECKEY_DestroyPublicKey(key);
break; case ecKey:  if (!(cert->keyUsage & (KU_DIGITAL_SIGNATURE | KU_KEY_AGREEMENT))) goto loser; break; default: goto loser; }
CERT_CheckKeyUsage(CERTCertificate *cert, unsigned int requiredUsage){    if (!cert) {        PORT_SetError(SEC_ERROR_INVALID_ARGS);	return SECFailure;    }    /* choose between key agreement or key encipherment based on key     * type in cert     */    if ( requiredUsage & KU_KEY_AGREEMENT_OR_ENCIPHERMENT ) {	SECKEYPublicKey *key = CERT_ExtractPublicKey(cert);	if (!key)	    return SECFailure;	if ( ( key->keyType == keaKey ) || ( key->keyType == fortezzaKey ) ||	     ( key->keyType == dhKey ) ) {	    requiredUsage |= KU_KEY_AGREEMENT;	} else {	    requiredUsage |= KU_KEY_ENCIPHERMENT;	} 	/* now turn off the special bit */	requiredUsage &= (~KU_KEY_AGREEMENT_OR_ENCIPHERMENT);		SECKEY_DestroyPublicKey(key);    }    if ( ( cert->keyUsage & requiredUsage ) != requiredUsage ) {	return(SECFailure);    }    return(SECSuccess);}