(cx->signalg == SEC_OID_ANSIX962_ECDSA_SIGNATURE_WITH_SHA1_DIGEST)) {
(cx->signalg == SEC_OID_ANSIX962_EC_PUBLIC_KEY)) {
SGN_End(SGNContext *cx, SECItem *result){    unsigned char digest[32];    unsigned part1, signatureLen;    SECStatus rv;    SECItem digder, sigitem;    PRArenaPool *arena = 0;    SECKEYPrivateKey *privKey = cx->key;    SGNDigestInfo *di = 0;    result->data = 0;    digder.data = 0;    /* Finish up digest function */    if (cx->hashcx == NULL) {	PORT_SetError(SEC_ERROR_INVALID_ARGS);	return SECFailure;    }    (*cx->hashobj->end)(cx->hashcx, digest, &part1, sizeof(digest));    if (privKey->keyType == rsaKey) {	arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);	if ( !arena ) {	    rv = SECFailure;	    goto loser;	}    	/* Construct digest info */	di = SGN_CreateDigestInfo(cx->hashalg, digest, part1);	if (!di) {	    rv = SECFailure;	    goto loser;	}	/* Der encode the digest as a DigestInfo */	rv = DER_Encode(arena, &digder, SGNDigestInfoTemplate, di);	if (rv != SECSuccess) {	    goto loser;	}    } else {	digder.data = digest;	digder.len = part1;    }    /*    ** Encrypt signature after constructing appropriate PKCS#1 signature    ** block    */    signatureLen = PK11_SignatureLen(privKey);    sigitem.len = signatureLen;    sigitem.data = (unsigned char*) PORT_Alloc(signatureLen);    if (sigitem.data == NULL) {	rv = SECFailure;	goto loser;    }    rv = PK11_Sign(privKey, &sigitem, &digder);    if (rv != SECSuccess) {	PORT_Free(sigitem.data);	sigitem.data = NULL;	goto loser;    }    if ((cx->signalg == SEC_OID_ANSIX9_DSA_SIGNATURE) ||        (cx->signalg == SEC_OID_ANSIX962_ECDSA_SIGNATURE_WITH_SHA1_DIGEST)) {        /* DSAU_EncodeDerSigWithLen works for DSA and ECDSA */	rv = DSAU_EncodeDerSigWithLen(result, &sigitem, signatureLen); 	PORT_Free(sigitem.data);	if (rv != SECSuccess)	    goto loser;    } else {	result->len = sigitem.len;	result->data = sigitem.data;    }  loser:    SGN_DestroyDigestInfo(di);    if (arena != NULL) {	PORT_FreeArena(arena, PR_FALSE);    }    return rv;}