rv = SECITEM_CopyItem(arena, &pubk->u.fortezza.keaParams.prime, &pubk->u.fortezza.params.prime); if (rv != SECSuccess) return rv; rv = SECITEM_CopyItem(arena, &pubk->u.fortezza.keaParams.subPrime, &pubk->u.fortezza.params.subPrime); if (rv != SECSuccess) return rv; rv = SECITEM_CopyItem(arena, &pubk->u.fortezza.keaParams.base, &pubk->u.fortezza.params.base); if (rv != SECSuccess) return rv;
if (SECSuccess == rv) { rv = SECITEM_CopyItem(arena, &pubk->u.fortezza.keaParams.prime, &pubk->u.fortezza.params.prime); } if (SECSuccess == rv) { rv = SECITEM_CopyItem(arena, &pubk->u.fortezza.keaParams.subPrime, &pubk->u.fortezza.params.subPrime); } if (SECSuccess == rv) { rv = SECITEM_CopyItem(arena, &pubk->u.fortezza.keaParams.base, &pubk->u.fortezza.params.base); }
SECKEY_FortezzaDecodePQGtoOld(PRArenaPool *arena, SECKEYPublicKey *pubk,                              SECItem *params) {        SECStatus rv;	SECKEYPQGDualParams dual_params;    if (params == NULL) return SECFailure;         if (params->data == NULL) return SECFailure;    /* Check if params use the standard format.     * The value 0xa1 will appear in the first byte of the parameter data     * if the PQG parameters are not using the standard format. This     * code should be changed to use a better method to detect non-standard     * parameters.    */    if ((params->data[0] != 0xa1) &&        (params->data[0] != 0xa0)) {            /* PQG params are in the standard format */	    /* Store DSA PQG parameters */	    prepare_pqg_params_for_asn1(&pubk->u.fortezza.params);            rv = SEC_ASN1DecodeItem(arena, &pubk->u.fortezza.params,                              SECKEY_PQGParamsTemplate,                              params);	    if (rv == SECSuccess) {	        /* Copy the DSA PQG parameters to the KEA PQG parameters. */	        rv = SECITEM_CopyItem(arena, &pubk->u.fortezza.keaParams.prime,                                      &pubk->u.fortezza.params.prime);                if (rv != SECSuccess) return rv;                rv = SECITEM_CopyItem(arena, &pubk->u.fortezza.keaParams.subPrime,                                      &pubk->u.fortezza.params.subPrime);                if (rv != SECSuccess) return rv;                rv = SECITEM_CopyItem(arena, &pubk->u.fortezza.keaParams.base,                                      &pubk->u.fortezza.params.base);                if (rv != SECSuccess) return rv;            }    } else {	dual_params.CommParams.prime.len = 0;        dual_params.CommParams.subPrime.len = 0;	dual_params.CommParams.base.len = 0;	dual_params.DiffParams.DiffDSAParams.prime.len = 0;        dual_params.DiffParams.DiffDSAParams.subPrime.len = 0;	dual_params.DiffParams.DiffDSAParams.base.len = 0;        /* else the old fortezza-only wrapped format is used. */	if (params->data[0] == 0xa1) {            rv = SEC_ASN1DecodeItem(arena, &dual_params, 				SECKEY_FortezzaPreParamTemplate, params);	} else {            rv = SEC_ASN1DecodeItem(arena, &dual_params, 	   			    SECKEY_FortezzaAltPreParamTemplate, params);        }        if (rv < 0) return rv;	        if ( (dual_params.CommParams.prime.len > 0) &&             (dual_params.CommParams.subPrime.len > 0) &&              (dual_params.CommParams.base.len > 0) ) {            /* copy in common params */	    	    rv = SECITEM_CopyItem(arena, &pubk->u.fortezza.params.prime,                                  &dual_params.CommParams.prime);            if (rv != SECSuccess) return rv;            rv = SECITEM_CopyItem(arena, &pubk->u.fortezza.params.subPrime,                                  &dual_params.CommParams.subPrime);            if (rv != SECSuccess) return rv;            rv = SECITEM_CopyItem(arena, &pubk->u.fortezza.params.base,                                  &dual_params.CommParams.base);	    /* Copy the DSA PQG parameters to the KEA PQG parameters. */	    rv = SECITEM_CopyItem(arena, &pubk->u.fortezza.keaParams.prime,                                  &pubk->u.fortezza.params.prime);            if (rv != SECSuccess) return rv;            rv = SECITEM_CopyItem(arena, &pubk->u.fortezza.keaParams.subPrime,                                  &pubk->u.fortezza.params.subPrime);            if (rv != SECSuccess) return rv;            rv = SECITEM_CopyItem(arena, &pubk->u.fortezza.keaParams.base,                                  &pubk->u.fortezza.params.base);            if (rv != SECSuccess) return rv;        } else {	    /* else copy in different params */	    /* copy DSA PQG parameters */	    rv = SECITEM_CopyItem(arena, &pubk->u.fortezza.params.prime,                                  &dual_params.DiffParams.DiffDSAParams.prime);            if (rv != SECSuccess) return rv;            rv = SECITEM_CopyItem(arena, &pubk->u.fortezza.params.subPrime,                                  &dual_params.DiffParams.DiffDSAParams.subPrime);            if (rv != SECSuccess) return rv;            rv = SECITEM_CopyItem(arena, &pubk->u.fortezza.params.base,                                  &dual_params.DiffParams.DiffDSAParams.base);	    /* copy KEA PQG parameters */	    rv = SECITEM_CopyItem(arena, &pubk->u.fortezza.keaParams.prime,                                  &dual_params.DiffParams.DiffKEAParams.prime);            if (rv != SECSuccess) return rv;            rv = SECITEM_CopyItem(arena, &pubk->u.fortezza.keaParams.subPrime,                                  &dual_params.DiffParams.DiffKEAParams.subPrime);            if (rv != SECSuccess) return rv;            rv = SECITEM_CopyItem(arena, &pubk->u.fortezza.keaParams.base,                                  &dual_params.DiffParams.DiffKEAParams.base);        }           }    return rv;}