static CRMFPKIArchiveOptions * crmf_create_arch_rem_gen_privkey(PRBool archiveRemGenPrivKey) { unsigned char value; SECItem *dummy; CRMFPKIArchiveOptions *newArchOptions; value = (archiveRemGenPrivKey) ? hexTrue : hexFalse; newArchOptions = PORT_ZNew(CRMFPKIArchiveOptions); if (newArchOptions == NULL) { goto loser; } dummy = SEC_ASN1EncodeItem(NULL, &newArchOptions->option.archiveRemGenPrivKey, &value, SEC_ASN1_GET(SEC_BooleanTemplate)); PORT_Assert(dummy == &newArchOptions->option.archiveRemGenPrivKey); if (dummy != &newArchOptions->option.archiveRemGenPrivKey) { SECITEM_FreeItem(dummy, PR_TRUE); goto loser; } newArchOptions->archOption = crmfArchiveRemGenPrivKey; return newArchOptions; loser: if (newArchOptions != NULL) { CRMF_DestroyPKIArchiveOptions(newArchOptions); } return NULL; }
static CRMFPKIArchiveOptions * crmf_create_encr_pivkey_option(CRMFEncryptedKey *inEncryptedKey) { CRMFPKIArchiveOptions *newArchOpt; SECStatus rv; newArchOpt = PORT_ZNew(CRMFPKIArchiveOptions); if (newArchOpt == NULL) { goto loser; } rv = crmf_copy_encryptedkey(NULL, inEncryptedKey, &newArchOpt->option.encryptedKey); if (rv != SECSuccess) { goto loser; } newArchOpt->archOption = crmfEncryptedPrivateKey; return newArchOpt; loser: if (newArchOpt != NULL) { CRMF_DestroyPKIArchiveOptions(newArchOpt); } return NULL; }
CRMFPKIArchiveOptions * CRMF_ControlGetPKIArchiveOptions(CRMFControl *inControl) { CRMFPKIArchiveOptions *newOpt = NULL; SECStatus rv; PORT_Assert(inControl != NULL); if (inControl == NULL || CRMF_ControlGetControlType(inControl) != crmfPKIArchiveOptionsControl) { goto loser; } newOpt = PORT_ZNew(CRMFPKIArchiveOptions); if (newOpt == NULL) { goto loser; } rv = crmf_copy_pkiarchiveoptions(NULL, newOpt, &inControl->value.archiveOptions); if (rv != SECSuccess) { goto loser; } loser: if (newOpt != NULL) { CRMF_DestroyPKIArchiveOptions(newOpt); } return NULL; }
static CRMFPKIArchiveOptions * crmf_create_keygen_param_option(SECItem *inKeyGenParams) { CRMFPKIArchiveOptions *newArchOptions; SECStatus rv; newArchOptions = PORT_ZNew(CRMFPKIArchiveOptions); if (newArchOptions == NULL) { goto loser; } newArchOptions->archOption = crmfKeyGenParameters; rv = SECITEM_CopyItem(NULL, &newArchOptions->option.keyGenParameters, inKeyGenParams); if (rv != SECSuccess) { goto loser; } return newArchOptions; loser: if (newArchOptions != NULL) { CRMF_DestroyPKIArchiveOptions(newArchOptions); } return NULL; }